import { h, VNode } from "preact"; import { useAnastasisContext } from "../../context/anastasis"; import { AnastasisClientFrame } from "./index"; export function ChallengeOverviewScreen(): VNode { const reducer = useAnastasisContext() if (!reducer) { return
no reducer in context
} if (!reducer.currentReducerState || reducer.currentReducerState.recovery_state === undefined) { return
invalid state
} const policies = reducer.currentReducerState.recovery_information?.policies ?? []; const chArr = reducer.currentReducerState.recovery_information?.challenges ?? []; const challengeFeedback = reducer.currentReducerState?.challenge_feedback; 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.length &&

No policies found

} {policies.map((row, i) => { return (

Policy #{i + 1}

{row.map(column => { const ch = challenges[column.uuid]; if (!ch) return
There is no challenge for this policy
const feedback = challengeFeedback?.[column.uuid]; return (

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

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

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