-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b918bdd
commit c56ca3b
Showing
8 changed files
with
5,160 additions
and
6,188 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
70 changes: 70 additions & 0 deletions
70
packages/frontend/src/app/components/profile/SeasonStats.tsx
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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import React from "react"; | ||
import SeasonDropdown from "../shared/season-dropdown"; | ||
import { MappedPlayedGame, MappedSeason } from "@/utils/types"; | ||
import { GameHistory } from "./GameHistory"; | ||
|
||
const SeasonStats: React.FC<{ | ||
seasons: MappedSeason[]; | ||
selectedSeason: MappedSeason; | ||
setSelectedSeason: React.Dispatch< | ||
React.SetStateAction<MappedSeason | undefined> | ||
>; | ||
selectedSeasonEnded: boolean; | ||
playedGames: MappedPlayedGame[]; | ||
}> = ({ | ||
seasons, | ||
selectedSeason, | ||
setSelectedSeason, | ||
selectedSeasonEnded, | ||
playedGames, | ||
}) => { | ||
return ( | ||
<div className="mx-4"> | ||
<h3 className="text-heading-3 text-neutral-300 my-2 mb-6"> | ||
Season Stats | ||
</h3> | ||
|
||
<SeasonDropdown | ||
seasons={seasons} | ||
selectedSeason={selectedSeason} | ||
setSelectedSeason={setSelectedSeason} | ||
selectedSeasonEnded={selectedSeasonEnded} | ||
/> | ||
|
||
<div className="flex justify-center items-center border border-neutral-400 p-4 rounded-lg mt-6 gap-x-2"> | ||
{[ | ||
{ | ||
heading: "Won", | ||
value: 1, | ||
}, | ||
{ | ||
heading: "Played", | ||
value: 2, | ||
}, | ||
{ | ||
heading: "Score", | ||
value: 1, | ||
}, | ||
{ | ||
heading: "Rank", | ||
value: 1, | ||
}, | ||
].map(({ heading, value }) => ( | ||
<div | ||
key={heading} | ||
className="flex-1 flex-col gap-y-1 text-center border-r last:border-r-0 px-1" | ||
> | ||
<p className="text-neutral-300 text-body-3">{heading}</p> | ||
<p className="text-neutral-100 text-body-1">{value}</p> | ||
</div> | ||
))} | ||
</div> | ||
|
||
{playedGames.map((game) => ( | ||
<GameHistory key="" playedGame={game} /> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default SeasonStats; |
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
80 changes: 80 additions & 0 deletions
80
packages/frontend/src/app/components/shared/season-dropdown.tsx
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 |
---|---|---|
@@ -0,0 +1,80 @@ | ||
"use client"; | ||
|
||
import ChevronDown from "@/shared/icons/Chevron-Down"; | ||
import Dropdown from "./dropdown"; | ||
import { MappedSeason } from "@/utils/types"; | ||
import { useState } from "react"; | ||
|
||
const SeasonDropdown: React.FC<{ | ||
seasons: MappedSeason[]; | ||
selectedSeason: MappedSeason; | ||
setSelectedSeason: React.Dispatch< | ||
React.SetStateAction<MappedSeason | undefined> | ||
>; | ||
selectedSeasonEnded: boolean; | ||
}> = ({ seasons, selectedSeason, setSelectedSeason, selectedSeasonEnded }) => { | ||
const [dropdownOpen, setDropdownOpen] = useState<boolean>(false); | ||
|
||
return ( | ||
<Dropdown | ||
open={dropdownOpen} | ||
setOpen={setDropdownOpen} | ||
trigger="click" | ||
propagationStop | ||
options={[ | ||
<div | ||
key="seasons-dropdown" | ||
className="bg-neutral-600 mt-2 rounded-lg px-4 max-h-96 overflow-auto" | ||
> | ||
{seasons.map((season, i) => ( | ||
<div | ||
key={season.season_id} | ||
className={`${ | ||
selectedSeason.season_id === season.season_id | ||
? "bg-neutral-500" | ||
: "" | ||
} rounded-lg py-3 px-4 my-4 flex items-center justify-between w-full text-neutral-300 hover:text-neutral-100 transition-all cursor-pointer`} | ||
onClick={() => { | ||
setSelectedSeason(season); | ||
setDropdownOpen(false); | ||
}} | ||
> | ||
<p className="font-medium text-body-1">{season.name}</p> | ||
|
||
{season.ended_on > new Date().toISOString() ? ( | ||
<span className="px-3 py-2 font-medium leading-none text-body-4 text-neutral-500 bg-status-success rounded-2xl"> | ||
LIVE | ||
</span> | ||
) : ( | ||
<p className="text-body-4"> | ||
Ended on {new Date(season.ended_on).getDate()} | ||
</p> | ||
)} | ||
</div> | ||
))} | ||
</div>, | ||
]} | ||
dropdownClassname="w-full" | ||
> | ||
<div className="cursor-pointer border-neutral-400 border rounded-lg p-4 flex items-center justify-between"> | ||
<div className="flex items-center gap-4"> | ||
<span>{selectedSeason.name}</span> | ||
|
||
{selectedSeasonEnded && ( | ||
<span className="px-3 py-2 font-medium leading-none text-body-4 text-neutral-500 bg-status-success rounded-2xl"> | ||
LIVE | ||
</span> | ||
)} | ||
</div> | ||
|
||
<div | ||
className={`text-neutral-300 ${dropdownOpen ? "rotate-180" : ""} transition-all`} | ||
> | ||
<ChevronDown /> | ||
</div> | ||
</div> | ||
</Dropdown> | ||
); | ||
}; | ||
|
||
export default SeasonDropdown; |
Oops, something went wrong.