-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: building out constructor standings for season results
- Loading branch information
1 parent
0e08921
commit 7064c7c
Showing
8 changed files
with
186 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,78 @@ | ||
'use client'; | ||
|
||
import { useAtom } from 'jotai'; | ||
|
||
import { constructorStandingsAtom, fetchStandings } from '@/atoms/results'; | ||
|
||
import { RaceSchedule } from './RaceResults'; | ||
import { | ||
constructorsData, | ||
ConstuctorHeadings, | ||
driverData, | ||
DriverHeadings, | ||
} from '../lib/placerholder-results'; | ||
import { driverData, DriverHeadings } from '../lib/placerholder-results'; | ||
import { IConstructorStandings, positionEnding } from '../lib/utils'; | ||
import { Table } from '../ui/Table'; | ||
import { Tabs } from '../ui/Tabs'; | ||
|
||
const ConstuctorHeadings = ['position', 'points', 'wins', 'name']; | ||
|
||
const ConstructorCard = ({ data }: { data: IConstructorStandings }) => ( | ||
<div className='card overflow-hidden bg-base-100 shadow-xl'> | ||
<div className='card-body px-0 pb-4 pt-2'> | ||
<h3 className='card-title max-w-64'> | ||
{positionEnding(data.pos)} {data.name} | ||
</h3> | ||
<div className='flex'> | ||
<p className='flex-1'> | ||
Points: | ||
<br /> | ||
{data.points} | ||
</p> | ||
<p className='flex-1'> | ||
Wins: | ||
<br /> | ||
{data.wins} | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
|
||
const ConstructorResults = () => { | ||
const [constructorStandings] = useAtom(constructorStandingsAtom); | ||
useAtom(fetchStandings); | ||
|
||
return ( | ||
<> | ||
<div className='mt-8 grid gap-8 lg:hidden'> | ||
{constructorStandings.map((constructor) => ( | ||
<ConstructorCard key={constructor.name} data={constructor} /> | ||
))} | ||
</div> | ||
<div className='hidden lg:block'> | ||
<Table | ||
key='Constructors Championship' | ||
headings={ConstuctorHeadings} | ||
data={constructorStandings} | ||
/> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
const tabHeaders = ['Races', 'Drivers', 'Constructors']; | ||
const tabs = [ | ||
<RaceSchedule key='Race Results' />, | ||
|
||
<div key='Drivers Championship' className='rounded bg-base-100 p-4'> | ||
<Table headings={DriverHeadings} data={driverData} /> | ||
</div>, | ||
<div key='Constructors Championship' className='rounded bg-base-100 p-4'> | ||
<Table headings={ConstuctorHeadings} data={constructorsData} />, | ||
</div>, | ||
<Table | ||
key='Drivers Championship' | ||
headings={DriverHeadings} | ||
data={driverData} | ||
/>, | ||
]; | ||
|
||
export default function ResultsPage() { | ||
return ( | ||
<main className='min-h-screen'> | ||
<Tabs headers={tabHeaders} containers={tabs} /> | ||
<main> | ||
<Tabs | ||
headers={tabHeaders} | ||
containers={[...tabs, <ConstructorResults key='ConstructorResults' />]} | ||
/> | ||
</main> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.