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 { 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
|
||||
|
|
Loading…
Reference in New Issue