fix: redirect from resistant page to list if isHome
parent
11800ee2be
commit
37c3824413
|
@ -1,11 +1,14 @@
|
||||||
|
import { useContext } from "react";
|
||||||
import { useNavigate, useParams } from "react-router";
|
import { useNavigate, useParams } from "react-router";
|
||||||
import { getResistantPhotoUrl } from "../getResistantPhotoUrl";
|
import { getResistantPhotoUrl } from "../getResistantPhotoUrl";
|
||||||
import { resistants } from "../resistants";
|
import { resistants } from "../resistants";
|
||||||
import { getResistantsPageUrl } from "../getResistantsPageUrl";
|
import { getResistantsPageUrl } from "../getResistantsPageUrl";
|
||||||
|
import { HomeContext } from "../context/HomeContext";
|
||||||
|
|
||||||
export const PageResistant = () => {
|
export const PageResistant = () => {
|
||||||
const { idResistant } = useParams();
|
const { idResistant } = useParams();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const { isHome } = useContext(HomeContext);
|
||||||
|
|
||||||
const resistant = resistants.find((r) => r.id === idResistant);
|
const resistant = resistants.find((r) => r.id === idResistant);
|
||||||
|
|
||||||
|
@ -14,6 +17,11 @@ export const PageResistant = () => {
|
||||||
return <>Résistant introuvable</>;
|
return <>Résistant introuvable</>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isHome) {
|
||||||
|
window.location.assign(getResistantsPageUrl());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<button
|
<button
|
||||||
|
|
Loading…
Reference in New Issue