diff options
Diffstat (limited to 'packages/challenger-ui/src/components')
-rw-r--r-- | packages/challenger-ui/src/components/CheckChallengeIsUpToDate.tsx | 29 |
1 files changed, 5 insertions, 24 deletions
diff --git a/packages/challenger-ui/src/components/CheckChallengeIsUpToDate.tsx b/packages/challenger-ui/src/components/CheckChallengeIsUpToDate.tsx index 5ac7998d8..1ff7197bf 100644 --- a/packages/challenger-ui/src/components/CheckChallengeIsUpToDate.tsx +++ b/packages/challenger-ui/src/components/CheckChallengeIsUpToDate.tsx @@ -28,42 +28,23 @@ import { useChallengeSession } from "../hooks/challenge.js"; import { SessionId, useSessionState } from "../hooks/session.js"; interface Props { - nonce: string; + session?: SessionId | undefined; children: ComponentChildren; - sessionId?: SessionId; onCompleted?: () => void; onChangeLeft?: () => void; onNoMoreChanges?: () => void; - onNoInfo: () => void; } export function CheckChallengeIsUpToDate({ - sessionId: sessionFromParam, - nonce, + session, children, onCompleted, onChangeLeft, onNoMoreChanges, - onNoInfo, }: Props): VNode { const { state } = useSessionState(); const { i18n } = useTranslationContext(); - const sessionId = sessionFromParam - ? sessionFromParam - : !state - ? undefined - : { - clientId: state.clientId, - redirectURL: state.redirectURL, - state: state.state, - }; - - const result = useChallengeSession(nonce, sessionId); - - if (!sessionId) { - onNoInfo(); - return <Loading />; - } + const result = useChallengeSession(session ?? state); if (!result) { return <Loading />; @@ -111,7 +92,7 @@ export function CheckChallengeIsUpToDate({ } } - if (onCompleted && "redirectURL" in result.body) { + if (onCompleted && result.body.solved) { onCompleted(); return <Loading />; } @@ -121,7 +102,7 @@ export function CheckChallengeIsUpToDate({ return <Loading />; } - if (onChangeLeft && !result.body.changes_left) { + if (onChangeLeft && result.body.changes_left) { onChangeLeft(); return <Loading />; } |