fix: redirect from resistant page to list if isHome

proto-module-actu-react
Jalil Arfaoui 2023-05-14 00:20:39 +02:00
parent 11800ee2be
commit 37c3824413
1 changed files with 8 additions and 0 deletions

View File

@ -1,11 +1,14 @@
import { useContext } from "react";
import { useNavigate, useParams } from "react-router";
import { getResistantPhotoUrl } from "../getResistantPhotoUrl";
import { resistants } from "../resistants";
import { getResistantsPageUrl } from "../getResistantsPageUrl";
import { HomeContext } from "../context/HomeContext";
export const PageResistant = () => {
const { idResistant } = useParams();
const navigate = useNavigate();
const { isHome } = useContext(HomeContext);
const resistant = resistants.find((r) => r.id === idResistant);
@ -14,6 +17,11 @@ export const PageResistant = () => {
return <>Résistant introuvable</>;
}
if (isHome) {
window.location.assign(getResistantsPageUrl());
return null;
}
return (
<>
<button