diff --git a/crates/lanspread-tauri-deno-ts/src/components/calltoplay/NominationCard.tsx b/crates/lanspread-tauri-deno-ts/src/components/calltoplay/NominationCard.tsx index 9380f1d..5652d21 100644 --- a/crates/lanspread-tauri-deno-ts/src/components/calltoplay/NominationCard.tsx +++ b/crates/lanspread-tauri-deno-ts/src/components/calltoplay/NominationCard.tsx @@ -70,10 +70,14 @@ export const NominationCard = ({ onLaunch, }: Props) => { const [confirmCancel, setConfirmCancel] = useState(false); + const [confirmStart, setConfirmStart] = useState(false); const cardRef = useRef(null); useEffect(() => { if (focused) cardRef.current?.scrollIntoView({ block: 'center', behavior: 'smooth' }); }, [focused]); + useEffect(() => { + setConfirmStart(false); + }, [nomination.id, nomination.state, actorId]); const now = Date.now(); const entries = Object.entries(nomination.participants); @@ -212,6 +216,8 @@ export const NominationCard = ({ actions={actions} onLaunch={onLaunch} now={now} + confirmStart={confirmStart} + onStartConfirmationChange={setConfirmStart} /> @@ -255,6 +261,8 @@ interface CardActionsProps { actions: CallToPlayActions; onLaunch: (game: Game) => void; now: number; + confirmStart: boolean; + onStartConfirmationChange: (confirm: boolean) => void; } const ReadyButtons = ({ nomination, actions, includeThirty = false }: { @@ -278,13 +286,15 @@ const ReadyButtons = ({ nomination, actions, includeThirty = false }: { ); -const CardActions = ({ +export const CardActions = ({ nomination, game, actorId, actions, onLaunch, now, + confirmStart, + onStartConfirmationChange, }: CardActionsProps) => { const myStatus = actorId === null ? undefined : nomination.participants[actorId]; const isMe = myStatus !== undefined; @@ -294,6 +304,11 @@ const CardActions = ({ const isExpired = statusOf(nomination, now) === 'expired'; const scheduled = phaseOf(nomination, now) === 'scheduled' && !isDone && !terminal; const readyCount = readyCountOf(nomination, now); + const startCall = async () => { + onStartConfirmationChange(false); + const accepted = await actions.startNow(nomination.id); + if (accepted && game) onLaunch(game); + }; if (terminal) { return ( @@ -310,12 +325,33 @@ const CardActions = ({ if (isCreator) { return ( <> - + {confirmStart && !isDone + ? ( +
+ Start this call early? +
+ + +
+
+ ) + : ( + + )} {isDone && (