import NotFound from '../pages/NotFound';
import Detail from '../components/tournament/Detail';
import {
+ canLoadMoreRounds,
+ getLastRound,
patchApplication,
patchParticipant,
patchResult,
};
}, [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) {
<title>{tournament.title}</title>
</Helmet>
<CanonicalLinks base={`/tournaments/${tournament.id}`} />
- <Detail addRound={addRound} tournament={tournament} />
+ <Detail
+ addRound={addRound}
+ moreRounds={canLoadMoreRounds(tournament) ? moreRounds : null}
+ tournament={tournament}
+ />
</ErrorBoundary>;
};