diff --git a/apps/demo-game/src/pages/admin/games/[id].tsx b/apps/demo-game/src/pages/admin/games/[id].tsx index 4a4c89fb..f3b8b1f3 100644 --- a/apps/demo-game/src/pages/admin/games/[id].tsx +++ b/apps/demo-game/src/pages/admin/games/[id].tsx @@ -27,7 +27,7 @@ import { computePeriodStatus, computeSegmentStatus, } from '@gbl-uzh/platform/dist/lib/util' -import { useCallback, useState } from 'react' +import { useCallback, useEffect, useState } from 'react' import { ActivateNextPeriodDocument, ActivateNextSegmentDocument, @@ -59,7 +59,7 @@ import { } from '@uzh-bf/design-system/dist/future' import { FormikMultiSelectField } from '~/components/fields/FormikMultiSelectField' - +import { useToast } from '~/components/ui/use-toast' import { DEFAULT_SEED, GAP_BONDS, @@ -123,6 +123,8 @@ function ManageGame() { const [addCountdown] = useMutation(AddCountdownDocument) + const { toast } = useToast() + const nextPeriod = () => activateNextPeriod({ variables: { @@ -139,6 +141,19 @@ function ManageGame() { refetchQueries: [GameDocument], }) + useEffect(() => { + const game = data?.game + if (game?.status !== GameStatus.Running) return + + const allPlayersReady = game.players.every((player) => player.isReady) + if (allPlayersReady) { + toast({ + title: 'All players are ready!', + description: 'All players are ready to continue.', + }) + } + }, [data?.game]) + const getButton = useCallback(() => { const game = data.game const disabled = game.periods.length === 0