/* This file is part of GNU Anastasis (C) 2021-2022 Anastasis SARL GNU Anastasis is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. GNU Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with GNU Anastasis; see the file COPYING. If not, see */ import { ChallengeFeedback, ChallengeFeedbackStatus, } from "@gnu-taler/anastasis-core"; import { h, VNode } from "preact"; import { Notifications } from "../../components/Notifications.js"; import { useAnastasisContext } from "../../context/anastasis.js"; import { authMethods, KnownAuthMethods } from "./authMethod/index.js"; import { AnastasisClientFrame } from "./index.js"; export function SolveOverviewFeedbackDisplay(props: { feedback?: ChallengeFeedback; }): VNode { const { feedback } = props; if (!feedback) { return
; } switch (feedback.state) { case ChallengeFeedbackStatus.TalerPayment: return ( To pay you can{" "} click here ), }, ]} /> ); case ChallengeFeedbackStatus.IbanInstructions: return ( ); case ChallengeFeedbackStatus.ServerFailure: return ( ); case ChallengeFeedbackStatus.RateLimitExceeded: return ( ); case ChallengeFeedbackStatus.Unsupported: return ( ); case ChallengeFeedbackStatus.TruthUnknown: return ( ); case ChallengeFeedbackStatus.CodeInFile: return ( ); case ChallengeFeedbackStatus.CodeSent: return ( ); case ChallengeFeedbackStatus.IncorrectAnswer: return ( ); case ChallengeFeedbackStatus.Solved: return ( ); } } export function SolveScreen(): VNode { const reducer = useAnastasisContext(); if (!reducer) { return (
no reducer in context
); } if (reducer.currentReducerState?.reducer_type !== "recovery") { return (
invalid state
); } if (!reducer.currentReducerState.recovery_information) { return (
no recovery information found
); } if (!reducer.currentReducerState.selected_challenge_uuid) { return (
invalid state
); } function SolveNotImplemented(): VNode { return (

The challenge selected is not supported for this UI. Please update this version or try using another policy.

{reducer && (
)}
); } const chArr = reducer.currentReducerState.recovery_information.challenges; const selectedUuid = reducer.currentReducerState.selected_challenge_uuid; const selectedChallenge = chArr.find((ch) => ch.uuid === selectedUuid); const SolveDialog = !selectedChallenge || !authMethods[selectedChallenge.type as KnownAuthMethods] ? SolveNotImplemented : authMethods[selectedChallenge.type as KnownAuthMethods].solve ?? SolveNotImplemented; return ; }