X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;ds=sidebyside;f=resources%2Fjs%2Fpages%2FTournament.js;h=ecaab6c97807bf1968b7e1732cf8c7d624a0a85b;hb=f18af7cfb219ab9c07635ea8bbae80f2a9cee78e;hp=7e651fedcdf521a915c4ce06f2b93c8f2f5d0e4a;hpb=9ef9d8cef9ab9ab844082d3d128c2f1fd30a1770;p=alttp.git diff --git a/resources/js/pages/Tournament.js b/resources/js/pages/Tournament.js index 7e651fe..ecaab6c 100644 --- a/resources/js/pages/Tournament.js +++ b/resources/js/pages/Tournament.js @@ -10,6 +10,8 @@ import Loading from '../components/common/Loading'; import NotFound from '../pages/NotFound'; import Detail from '../components/tournament/Detail'; import { + canLoadMoreRounds, + getLastRound, patchApplication, patchParticipant, patchResult, @@ -19,7 +21,7 @@ import { sortParticipants, } from '../helpers/Tournament'; -const Tournament = () => { +export const Component = () => { const params = useParams(); const { id } = params; @@ -97,6 +99,21 @@ const Tournament = () => { }; }, [id]); + const moreRounds = React.useCallback(async () => { + const last_round = getLastRound(tournament); + if (!last_round) return; + console.log(last_round); + const last_known = last_round.number; + const rsp = await axios.get( + `/api/tournaments/${id}/more-rounds`, + { params: { last_known } }, + ); + setTournament(tournament => ({ + ...tournament, + rounds: [...tournament.rounds, ...rsp.data], + })); + }, [id, tournament]); + useEffect(() => { const cb = (e) => { if (e.user) { @@ -132,8 +149,10 @@ const Tournament = () => {