}, [id]);
useEffect(() => {
- window.Echo.channel(`Tournament.${id}`)
+ if (!tournament) {
+ return;
+ }
+ window.Echo.channel(`Tournament.${tournament.id}`)
.listen('ApplicationAdded', e => {
if (e.application) {
setTournament(tournament => patchApplication(tournament, e.application));
}
});
return () => {
- window.Echo.leave(`Tournament.${id}`);
+ window.Echo.leave(`Tournament.${tournament.id}`);
};
- }, [id]);
+ }, [tournament?.id]);
const addRound = React.useCallback(async () => {
- await axios.post('/api/rounds', { tournament_id: id });
- }, [id]);
+ await axios.post('/api/rounds', { tournament_id: tournament.id });
+ }, [tournament?.id]);
const moreRounds = React.useCallback(async () => {
const last_round = getLastRound(tournament);