-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
14 changed files
with
277 additions
and
159 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,131 +1,37 @@ | ||
import { Match } from '@g-loot/react-tournament-brackets/dist/src/types'; | ||
import { useCallback, useEffect, useState } from 'react'; | ||
import { ITournament } from 'types/admin/adminTournamentTypes'; | ||
import { TournamentGame, TournamentInfo } from 'types/tournamentTypes'; | ||
import { convertTournamentGamesToBracketMatchs } from 'utils/handleTournamentGame'; | ||
import { mockInstance } from 'utils/mockAxios'; | ||
import TournamentBraket from 'components/tournament/TournamentBraket'; | ||
import styles from 'styles/admin/modal/AdminEditTournamentBraket.module.scss'; | ||
|
||
export const simpleSmallBracket: Match[] = [ | ||
{ | ||
id: 19753, | ||
nextMatchId: null, | ||
tournamentRoundText: '3', | ||
startTime: '2021-05-30', | ||
state: 'SCHEDULED', | ||
participants: [], | ||
}, | ||
{ | ||
id: 19754, | ||
nextMatchId: 19753, | ||
tournamentRoundText: '2', | ||
startTime: '2021-05-30', | ||
state: 'SCHEDULED', | ||
participants: [ | ||
{ | ||
id: '14754a1a-932c-4992-8dec-f7f94a339960', | ||
resultText: null, | ||
isWinner: false, | ||
status: null, | ||
name: 'CoKe BoYz', | ||
picture: 'https://avatars.githubusercontent.com/u/93255519?v=4', | ||
}, | ||
], | ||
}, | ||
{ | ||
id: 19755, | ||
nextMatchId: 19754, | ||
tournamentRoundText: '1', | ||
startTime: '2021-05-30', | ||
state: 'SCORE_DONE', | ||
participants: [ | ||
{ | ||
id: '14754a1a-932c-4992-8dec-f7f94a339960', | ||
resultText: 'Won', | ||
isWinner: true, | ||
status: 'PLAYED', | ||
name: 'CoKe BoYz', | ||
picture: 'https://avatars.githubusercontent.com/u/93255519?v=4', | ||
}, | ||
{ | ||
id: 'd16315d4-7f2d-427b-ae75-63a1ae82c0a8', | ||
resultText: 'Lost', | ||
isWinner: false, | ||
status: 'PLAYED', | ||
name: 'Aids Team', | ||
picture: 'https://avatars.githubusercontent.com/u/93255519?v=4', | ||
}, | ||
], | ||
}, | ||
{ | ||
id: 19756, | ||
nextMatchId: 19754, | ||
tournamentRoundText: '1', | ||
startTime: '2021-05-30', | ||
state: 'RUNNING', | ||
participants: [ | ||
{ | ||
id: 'd8b9f00a-0ffa-4527-8316-da701894768e', | ||
resultText: null, | ||
isWinner: false, | ||
status: null, | ||
name: 'Art of kill', | ||
picture: 'https://avatars.githubusercontent.com/u/93255519?v=4', | ||
}, | ||
], | ||
}, | ||
{ | ||
id: 19757, | ||
nextMatchId: 19753, | ||
tournamentRoundText: '2', | ||
startTime: '2021-05-30', | ||
state: 'SCHEDULED', | ||
participants: [], | ||
}, | ||
{ | ||
id: 19758, | ||
nextMatchId: 19757, | ||
tournamentRoundText: '1', | ||
startTime: '2021-05-30', | ||
state: 'SCHEDULED', | ||
participants: [ | ||
{ | ||
id: '9397971f-4b2f-44eb-a094-722eb286c59b', | ||
resultText: null, | ||
isWinner: false, | ||
status: null, | ||
name: 'Crazy Pepes', | ||
picture: 'https://avatars.githubusercontent.com/u/93255519?v=4', | ||
}, | ||
], | ||
}, | ||
{ | ||
id: 19759, | ||
nextMatchId: 19757, | ||
tournamentRoundText: '1', | ||
startTime: '2021-05-30', | ||
state: 'SCHEDULED', | ||
participants: [ | ||
{ | ||
id: '42fecd89-dc83-4821-80d3-718acb50a30c', | ||
resultText: null, | ||
isWinner: false, | ||
status: null, | ||
name: 'BLUEJAYS', | ||
picture: 'https://avatars.githubusercontent.com/u/93255519?v=4', | ||
}, | ||
{ | ||
id: 'df01fe2c-18db-4190-9f9e-aa63364128fe', | ||
resultText: null, | ||
isWinner: false, | ||
status: null, | ||
name: 'Bosphorus', | ||
picture: 'teamlogos/r7zn4gr8eajivapvjyzd', | ||
}, | ||
], | ||
}, | ||
]; | ||
export default function AdminEditTournamentBraket({ | ||
tournamentId, | ||
}: ITournament) { | ||
const [bracketMatchs, setBracketMatchs] = useState<Match[]>([]); | ||
|
||
const fetchTournamentGames = useCallback(async () => { | ||
console.log('Fetching more data...'); | ||
try { | ||
const res = await mockInstance.get(`/tournament/${tournamentId}/games`); | ||
const data: TournamentGame[] = res.data.games; | ||
const bracketMatchs = convertTournamentGamesToBracketMatchs(data); | ||
setBracketMatchs(bracketMatchs); | ||
return data; | ||
} catch (error) { | ||
console.error('Error fetching data:', error); | ||
} | ||
}, []); | ||
|
||
useEffect(() => { | ||
fetchTournamentGames(); | ||
}, [fetchTournamentGames]); | ||
|
||
export default function AdminEditTournamentBraket() { | ||
return ( | ||
<div className={styles['whole']}> | ||
<TournamentBraket singleEliminationBracketMatchs={simpleSmallBracket} /> | ||
<TournamentBraket singleEliminationBracketMatchs={bracketMatchs} /> | ||
</div> | ||
); | ||
} |
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
102 changes: 102 additions & 0 deletions
102
pages/api/pingpong/tournament/[tournamentId]/games/dummyTournamentGame.ts
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,102 @@ | ||
import { TournamentGame } from 'types/tournamentTypes'; | ||
|
||
export const dummyLiveTournamentGames = { | ||
games: [ | ||
{ | ||
tournamentGameId: 19753, | ||
game: null, | ||
status: 'SCHEDULED', | ||
nextTournamentGameId: null, | ||
}, | ||
{ | ||
tournamentGameId: 19754, | ||
game: null, | ||
status: 'SCHEDULED', | ||
nextTournamentGameId: 19753, | ||
}, | ||
{ | ||
tournamentGameId: 19755, | ||
game: { | ||
gameId: 1, | ||
status: 'END', | ||
mode: 'TOURNAMENT', | ||
time: '13', | ||
team1: { | ||
players: [ | ||
{ | ||
intraId: 'CoKe BoYz', | ||
userImageUri: | ||
'https://avatars.githubusercontent.com/u/93255519?v=4', | ||
level: 3, | ||
}, | ||
], | ||
isWin: true, | ||
score: 2, | ||
}, | ||
team2: { | ||
players: [ | ||
{ | ||
intraId: 'Aids Team', | ||
userImageUri: | ||
'https://avatars.githubusercontent.com/u/93255519?v=4', | ||
level: 3, | ||
}, | ||
], | ||
isWin: false, | ||
score: 1, | ||
}, | ||
}, | ||
status: 'SCORE_DONE', | ||
nextTournamentGameId: 19754, | ||
}, | ||
{ | ||
tournamentGameId: 19756, | ||
nextTournamentGameId: 19754, | ||
status: 'RUNNING', | ||
game: null, | ||
}, | ||
{ | ||
tournamentGameId: 19757, | ||
nextTournamentGameId: 19753, | ||
status: 'SCHEDULED', | ||
game: null, | ||
}, | ||
{ | ||
tournamentGameId: 19758, | ||
nextTournamentGameId: 19757, | ||
status: 'SCHEDULED', | ||
game: null, | ||
}, | ||
{ | ||
tournamentGameId: 19759, | ||
nextTournamentGameId: 19757, | ||
status: 'SCHEDULED', | ||
game: { | ||
gameId: 1, | ||
status: 'LIVE', | ||
mode: 'TOURNAMENT', | ||
time: '13', | ||
team1: { | ||
players: [ | ||
{ | ||
intraId: 'BLUEJAYS', | ||
userImageUri: | ||
'https://avatars.githubusercontent.com/u/93255519?v=4', | ||
level: 3, | ||
}, | ||
], | ||
}, | ||
team2: { | ||
players: [ | ||
{ | ||
intraId: 'Bosphorus', | ||
userImageUri: | ||
'https://avatars.githubusercontent.com/u/93255519?v=4', | ||
level: 3, | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
], | ||
}; |
Oops, something went wrong.