Skip to content
This repository has been archived by the owner on Jan 28, 2023. It is now read-only.

Commit

Permalink
Vainqueur final (#103)
Browse files Browse the repository at this point in the history
* Renommage en Final Winner le composant pour ne pas confondre avec vainqueur de matchs

* Correction fonctionnement Choix du vainqueur final

* By default, order teams by winOdd
  • Loading branch information
naustra authored Apr 5, 2021
1 parent 24865be commit 0ca12bb
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/hooks/teams.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const useTeam = (id, initialData) => {
}

export const useTeams = () => {
const query = useFirestore().collection('teams')
const query = useFirestore().collection('teams').orderBy('winOdd')

return useFirestoreCollection(query, { initialData: [] }).data?.docs
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import CardContent from '@material-ui/core/CardContent'
import Typography from '@material-ui/core/Typography'
import React, { Suspense } from 'react'
import { useSelectedWinner } from '../../../hooks'
import './Winner.scss'
import WinnerChoice from './WinnerChoice'
import './FinalWinner.scss'
import FinalWinnerChoice from './FinalWinnerChoice'

const Winner = () => {
const FinalWinner = () => {
const [team, saveWinner] = useSelectedWinner()

const handleChange = (e) => {
Expand All @@ -28,15 +28,15 @@ const Winner = () => {
</Typography>
<CardContent>
<Suspense fallback={<></>}>
<WinnerChoice userTeam={team} onValueChange={handleChange} />
<FinalWinnerChoice userTeam={team} onValueChange={handleChange} />
</Suspense>
</CardContent>
</Card>
)
}

Winner.propTypes = {}
FinalWinner.propTypes = {}

Winner.defaultProps = {}
FinalWinner.defaultProps = {}

export default Winner
export default FinalWinner
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import React from 'react'
import { COMPETITION_START_DATE } from '../../../../shared'
import Flag from '../../../../components/Flag'
import { useTeams } from '../../../../hooks'
import './WinnerChoice.scss'
import './FinalWinnerChoice.scss'

const WinnerChoice = ({ userTeam, onValueChange }) => {
const FinalWinnerChoice = ({ userTeam, onValueChange }) => {
const teams = useTeams()

return (
<div className="winner-choice">
{FlagTest(teams, userTeam)}
{FlagDisplay(teams, userTeam)}
<div className="winner-choice-select-container">
<Select
className="winner-choice-select-value"
Expand All @@ -35,15 +35,17 @@ const WinnerChoice = ({ userTeam, onValueChange }) => {
))}
</Select>
</div>
{OddTest(teams, userTeam)}
{OddDisplay(teams, userTeam)}
</div>
)
}

// Affichage du drapeau du pays choisi
const FlagTest = (teams, userTeam) => {
const FlagDisplay = (teams, userTeam) => {
const teamDisplayed = find(teams, (team) => team.id === userTeam)

console.log(teamDisplayed)

return (
teamDisplayed && (
<Flag
Expand All @@ -55,28 +57,28 @@ const FlagTest = (teams, userTeam) => {
}

// Affichage de la cote du pays choisi
const OddTest = (teams, userTeam) => {
const OddDisplay = (teams, userTeam) => {
const teamDisplayed = find(teams, (team) => team.id === userTeam)

return (
teamDisplayed && (
<Tooltip title="Cote pour la victoire finale" placement="right">
<Typography variant="body1" className="winner-choice-odd">
{teamDisplayed.winOdd}
<Typography variant="h1" className="winner-choice-odd">
{teamDisplayed.data().winOdd}
</Typography>
</Tooltip>
)
)
}

WinnerChoice.defaultProps = {
FinalWinnerChoice.defaultProps = {
teams: [],
}

WinnerChoice.propTypes = {
FinalWinnerChoice.propTypes = {
teams: PropTypes.arrayOf(PropTypes.shape({})),
userTeam: PropTypes.string,
onValueChange: PropTypes.func.isRequired,
}

export default WinnerChoice
export default FinalWinnerChoice
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './FinalWinnerChoice'
1 change: 1 addition & 0 deletions src/screens/HomePage/FinalWinner/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './FinalWinner'
4 changes: 2 additions & 2 deletions src/screens/HomePage/HomePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import React from 'react'
import { AuthCheck } from 'reactfire'
import myImage from '../../assets/visuels/bandeauEvenement2.webp'
import './HomePage.scss'
import Winner from './Winner'
import FinalWinner from './FinalWinner'

const HomePage = ({ history }) => {
return (
Expand Down Expand Up @@ -82,7 +82,7 @@ const HomePage = ({ history }) => {
</AuthCheck>
</div>
<AuthCheck>
<Winner />
<FinalWinner />
</AuthCheck>
<img alt="Home" className="home-logo" src={myImage} />
</div>
Expand Down
1 change: 0 additions & 1 deletion src/screens/HomePage/Winner/WinnerChoice/index.js

This file was deleted.

1 change: 0 additions & 1 deletion src/screens/HomePage/Winner/index.js

This file was deleted.

0 comments on commit 0ca12bb

Please sign in to comment.