fix: redirect to root in resistant not found
parent
1b25d19a0f
commit
102d73e338
|
@ -1,4 +1,5 @@
|
|||
import { Resistant } from "./Resistant";
|
||||
import { getResistantsPageUrl } from "./getResistantsPageUrl";
|
||||
|
||||
export const getResistantPageUrl = (resistant: Resistant) =>
|
||||
`https://www.enfance-libre.fr/#/${resistant.id}`;
|
||||
`${getResistantsPageUrl()}/#/${resistant.id}`;
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
export const getResistantsPageUrl = () =>
|
||||
`https://www.enfance-libre.fr/resistants`;
|
|
@ -1,6 +1,7 @@
|
|||
import { redirect, useNavigate, useParams } from "react-router";
|
||||
import { getResistantPhotoUrl } from "../getResistantPhotoUrl";
|
||||
import { resistants } from "../resistants";
|
||||
import { getResistantsPageUrl } from "../getResistantsPageUrl";
|
||||
|
||||
export const PageResistant = () => {
|
||||
const { idResistant } = useParams();
|
||||
|
@ -9,7 +10,7 @@ export const PageResistant = () => {
|
|||
const resistant = resistants.find((r) => r.id === idResistant);
|
||||
|
||||
if (!resistant) {
|
||||
redirect("/");
|
||||
redirect(getResistantsPageUrl());
|
||||
return <>Résistant introuvable</>;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue