Fix schedule flight details 404: use Modern.js $.tsx splat route convention
The [...flights]/page.tsx catch-all generated an incorrect route pattern (schedule/:/flights) instead of a React Router splat (schedule/*). Modern.js convention for catch-all routes is $.tsx at the directory level, not [...param]/page.tsx. Moved to $.tsx and updated param access to use the "*" splat key. Fixes: /ru/schedule/SU0012-20220527 and multi-leg URLs now resolve.
This commit is contained in:
@@ -49,13 +49,12 @@ function parseFlightSegments(segments: string[]): IScheduleFlightId[] {
|
||||
}
|
||||
|
||||
export default function ScheduleDetailsRoute(): JSX.Element {
|
||||
const routeParams = useParams<{ flights: string; lang: string }>();
|
||||
const routeParams = useParams<{ "*": string; lang: string }>();
|
||||
const locale = routeParams.lang ?? "ru";
|
||||
const canonicalOrigin = getEnv().PROD_ORIGIN;
|
||||
|
||||
// Modern.js catch-all provides the remaining path as a single string
|
||||
// joined by "/". We split it back to segments.
|
||||
const rawFlights = routeParams.flights ?? "";
|
||||
// Modern.js $.tsx splat route provides the remaining path via "*" param.
|
||||
const rawFlights = routeParams["*"] ?? "";
|
||||
const segments = rawFlights.split("/").filter(Boolean);
|
||||
const flights = parseFlightSegments(segments);
|
||||
|
||||
Reference in New Issue
Block a user