X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=resources%2Fjs%2Fcomponents%2Fpages%2FTournament.js;h=5a9c8b05c207ce74db4c159559bdef5b5511b106;hb=a907ef7c6676fef11f42933b2d79bdd496b20122;hp=64c890609333608f1701941676849ec8308d28f7;hpb=d748feb96453d74aeffec648d6f5f68d9ef3b520;p=alttp.git diff --git a/resources/js/components/pages/Tournament.js b/resources/js/components/pages/Tournament.js index 64c8906..5a9c8b0 100644 --- a/resources/js/components/pages/Tournament.js +++ b/resources/js/components/pages/Tournament.js @@ -7,7 +7,7 @@ import ErrorMessage from '../common/ErrorMessage'; import Loading from '../common/Loading'; import NotFound from '../pages/NotFound'; import Detail from '../tournament/Detail'; -import { patchResult } from '../../helpers/Tournament'; +import { patchResult, patchRound, sortParticipants } from '../../helpers/Tournament'; const Tournament = () => { const params = useParams(); @@ -24,7 +24,7 @@ const Tournament = () => { .then(response => { setError(null); setLoading(false); - setTournament(response.data); + setTournament(sortParticipants(response.data)); }) .catch(error => { setError(error); @@ -48,6 +48,11 @@ const Tournament = () => { rounds: [...tournament.rounds, e.round], })); } + }) + .listen('RoundChanged', e => { + if (e.round) { + setTournament(tournament => patchRound(tournament, e.round)); + } }); return () => { window.Echo.leave(`Tournament.${id}`);