diff --git a/README.md b/README.md index b909354..0cbf0fd 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ Table of Contents: - [Contribution Guidelines](#contribution-guidelines) - [Tests](#tests) - [Deployment](#deployment) +- [URL Structure](#url-structure) - [Resources](#resources) ## Setting up the project @@ -97,6 +98,19 @@ This project is using [conventional commits](https://www.conventionalcommits.org // TODO [vercel](https://vercel.com/) +## URL Structure + +``` +`/` +├── Results of past seasons +└──`[season]` -> year + └── `[location]` -> race location of race in season + └── `[session]` -> session of race + └── `[driver]` -> driverId in race session + ├── `/` -> ??? + └── `/telemetry` -> ??? +``` + ## Resources Key tools in use: `daisy-ui`, `tailwindcss`, `react`, `nextjs`, `pnpm`, `cypress` diff --git a/src/app/[season]/[location]/[driver]/[session]/page.tsx b/src/app/[season]/[location]/[driver]/[session]/page.tsx new file mode 100644 index 0000000..5583775 --- /dev/null +++ b/src/app/[season]/[location]/[driver]/[session]/page.tsx @@ -0,0 +1,7 @@ +export default function SessionPage({ + params, +}: { + params: { session: string }; +}) { + return

{params.session}

; +} diff --git a/src/app/[season]/[location]/[driver]/[session]/telemetry/page.tsx b/src/app/[season]/[location]/[driver]/[session]/telemetry/page.tsx new file mode 100644 index 0000000..5103797 --- /dev/null +++ b/src/app/[season]/[location]/[driver]/[session]/telemetry/page.tsx @@ -0,0 +1,3 @@ +export default function TelemetryPage() { + return

Telemetry

; +} diff --git a/src/app/[season]/[location]/[driver]/page.tsx b/src/app/[season]/[location]/[driver]/page.tsx new file mode 100644 index 0000000..f89aa92 --- /dev/null +++ b/src/app/[season]/[location]/[driver]/page.tsx @@ -0,0 +1,3 @@ +export default function DriverPage({ params }: { params: { driver: string } }) { + return

{params.driver}

; +} diff --git a/src/app/[season]/[location]/page.tsx b/src/app/[season]/[location]/page.tsx index 1bd34b6..3bc2d8b 100644 --- a/src/app/[season]/[location]/page.tsx +++ b/src/app/[season]/[location]/page.tsx @@ -25,34 +25,18 @@ export default function ResultsPage({ const [races] = useAtom(seasonRacesAtom); const [_, setRace] = useAtom(raceAtom); + // On Mount we need to update the race to use the url params useEffect(() => { setRace( - races.find((race) => race.Location === params.location) || 'All Races', + races.find((race) => race.Location.toLowerCase() === params.location) || + 'All Races', ); }, [races, params.location, setRace]); - // useAtom(fetchStandings); - // useAtom(fetchSessionResults); useAtom(fetchSessionResults); - // const [constructorStandings] = useAtom(constructorStandingsAtom); - // const [driverStandings] = useAtom(driverStandingsAtom); const [drivers] = useAtom(allDriversAtom); const [constructors] = useAtom(allConstructorAtom); - // const [driverStandings] = useAtom(driverStandingsAtom); - - // const [, handleRaceChange] = useAtom(handleRaceChangeAtom); - // const [allRaces] = useAtom(seasonRacesAtom) - - // if (!params) return <>; - // Get all - - // if (allRaces && allRaces.length > 0) { - // console.log('all races', allRaces[parseInt(params.round) - 1]) - - // handleRaceChange(allRaces[parseInt(params.round) - 1]); - // } - return (
{ const [, handleResultsSubmit] = useAtom(handleMainFilterSubmit); // useAtom(fetchSeasons); - // useAtom(toggleTelemetryDisableAtom); + useAtom(toggleTelemetryDisableAtom); // useAtom(fetchSessionResults); const changePath = (url: string) => { @@ -51,9 +54,10 @@ export const MainFilters = () => { if (pathname !== '/') router.push(url); }; - const handleSubmit = () => { + const handleSubmit = (e: React.MouseEvent) => { + const telemetry = (e.target as HTMLButtonElement).innerHTML === 'Telemetry'; const url = handleResultsSubmit(); - router.push('/' + url); + router.push('/' + url + (telemetry && '/telemetry')); }; return ( @@ -70,10 +74,11 @@ export const MainFilters = () => {
-