-
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.
- Loading branch information
Showing
13 changed files
with
303 additions
and
16 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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { format } from "date-fns"; | ||
import ukLocale from "date-fns/locale/uk"; | ||
import { Item, StagesItemText, StagesItemWrap } from "./StagesList-styled"; | ||
import { membersApi } from "../../Api/ApiRequest"; | ||
|
||
export const StagesItem = ({ el, index }) => { | ||
const members = membersApi(); | ||
const { member_id } = el?.players?.reduce((acc, curr) => { | ||
if ( | ||
curr.win > acc.win || | ||
(curr.win === acc.win && curr.defeat < acc.defeat) | ||
) { | ||
return curr; | ||
} else { | ||
return acc; | ||
} | ||
}); | ||
|
||
const winner = members.find((member) => member.id === member_id); | ||
const winnerName = winner ? winner.name : "Не знайдено"; | ||
|
||
return ( | ||
<> | ||
<Item id={el.id}> | ||
<StagesItemWrap> | ||
<StagesItemText>{index + 1}.</StagesItemText> | ||
|
||
<StagesItemText> | ||
{format(new Date(el.date), " d MMMM yyyyр.", { | ||
locale: ukLocale, | ||
})} | ||
</StagesItemText> | ||
<StagesItemText> | ||
{el.date === "2024-04-7" || el.date === "2024-04-21" | ||
? "Приховано" | ||
: winnerName} | ||
</StagesItemText> | ||
</StagesItemWrap> | ||
</Item> | ||
</> | ||
); | ||
}; |
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,133 @@ | ||
import styled from "styled-components"; | ||
|
||
export const Section = styled.section` | ||
padding-bottom: 50px; | ||
min-height: 800px; | ||
background-color: var(--secondary-white-color); | ||
`; | ||
|
||
export const List = styled.ul``; | ||
|
||
export const Item = styled.li` | ||
position: relative; | ||
overflow: hidden; | ||
width: 100%; | ||
height: 50px; | ||
&:nth-child(odd) { | ||
background-color: var(--primary-white-color); | ||
} | ||
&:nth-child(even) { | ||
background-color: var(--secondary-white-color); | ||
} | ||
&:hover { | ||
cursor: pointer; | ||
} | ||
@media screen and (min-width: 1200px) { | ||
&:hover { | ||
background-color: var(--primary-black-color); | ||
color: var(--primary-white-color); | ||
} | ||
} | ||
`; | ||
|
||
export const StagesItemWrap = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
padding-left: 24px; | ||
padding-right: 24px; | ||
margin-left: auto; | ||
margin-right: auto; | ||
max-width: 1200px; | ||
width: 100%; | ||
height: 100%; | ||
`; | ||
|
||
export const StagesItemText = styled.p` | ||
overflow: hidden; | ||
display: flex; | ||
justify-content: left; | ||
align-items: center; | ||
height: 100%; | ||
font-size: 16px; | ||
font-weight: 400; | ||
&:nth-child(1) { | ||
width: 35px; | ||
} | ||
&:nth-child(2) { | ||
width: 140px; | ||
flex-grow: 1; | ||
} | ||
&:nth-child(3) { | ||
width: 130px; | ||
justify-content: right; | ||
text-align: right; | ||
@media screen and (min-width: 450px) { | ||
width: 150px; | ||
} | ||
} | ||
`; | ||
|
||
export const Heading = styled.div` | ||
position: relative; | ||
overflow: hidden; | ||
width: 100%; | ||
height: 100px; | ||
background-color: var(--tertiary-white-color); | ||
color: var(--primary-black-color); | ||
`; | ||
|
||
export const HeadingWrap = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
padding-left: 24px; | ||
padding-right: 24px; | ||
margin-left: auto; | ||
margin-right: auto; | ||
max-width: 1200px; | ||
width: 100%; | ||
height: 100%; | ||
`; | ||
|
||
export const HeadingText = styled.div` | ||
overflow: hidden; | ||
display: flex; | ||
justify-content: left; | ||
align-items: center; | ||
height: 100%; | ||
font-size: 16px; | ||
font-weight: 400; | ||
line-height: 1.6; | ||
&:nth-child(1) { | ||
width: 35px; | ||
} | ||
&:nth-child(2) { | ||
width: 140px; | ||
flex-grow: 1; | ||
} | ||
&:nth-child(3) { | ||
width: 120px; | ||
justify-content: right; | ||
text-align: right; | ||
@media screen and (min-width: 450px) { | ||
width: 150px; | ||
} | ||
} | ||
`; |
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,25 @@ | ||
import { useLocation } from "react-router-dom"; | ||
import { TitleSection } from "../TitleSection/TitleSection"; | ||
import { StagesItem } from "./StagesItem"; | ||
import { List, Section } from "./StagesList-styled"; | ||
import { StagesListHeading } from "./StagesListHeading"; | ||
|
||
export const StagesList = () => { | ||
const { state } = useLocation(); | ||
return ( | ||
<> | ||
<Section> | ||
<TitleSection | ||
icon={"#icon-medal"} | ||
title={"Кількість етапів: " + state?.stages?.length} | ||
/> | ||
<List> | ||
<StagesListHeading /> | ||
{state?.stages?.map((el, index) => ( | ||
<StagesItem key={el.date} el={el} index={index} /> | ||
))} | ||
</List> | ||
</Section> | ||
</> | ||
); | ||
}; |
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,16 @@ | ||
import { Heading, HeadingText, HeadingWrap } from "./StagesList-styled"; | ||
|
||
export const StagesListHeading = () => { | ||
return ( | ||
<> | ||
<Heading style={{ height: "50px" }}> | ||
<HeadingWrap> | ||
<HeadingText>№</HeadingText> | ||
<HeadingText>Дата проведення</HeadingText> | ||
|
||
<HeadingText>Переможець</HeadingText> | ||
</HeadingWrap> | ||
</Heading> | ||
</> | ||
); | ||
}; |
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
Oops, something went wrong.