import { h, VNode } from "preact"; import { RecoveryReducerProps, AnastasisClientFrame } from "./index"; export function ChallengeOverviewScreen(props: RecoveryReducerProps): VNode { const { recoveryState, reducer } = props; const policies = recoveryState.recovery_information!.policies; const chArr = recoveryState.recovery_information!.challenges; const challenges: { [uuid: string]: { type: string; instructions: string; cost: string; }; } = {}; for (const ch of chArr) { challenges[ch.uuid] = { type: ch.type, cost: ch.cost, instructions: ch.instructions, }; } return (

Policies

{policies.map((x, i) => { return (

Policy #{i + 1}

{x.map((x, j) => { const ch = challenges[x.uuid]; const feedback = recoveryState.challenge_feedback?.[x.uuid]; return (

{ch.type} ({ch.instructions})

Status: {feedback?.state ?? "unknown"}

{feedback?.state !== "solved" ? ( ) : null}
); })}
); })}
); }