summaryrefslogtreecommitdiff
path: root/packages/anastasis-webui/src/pages/home/SolveQuestionEntry.tsx
blob: 6393958b38d92fc97672b567b37b53cb1a30c291 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { h, VNode } from "preact";
import { useState } from "preact/hooks";
import { AnastasisClientFrame, LabeledInput } from "./index";
import { SolveEntryProps } from "./SolveScreen";

export function SolveQuestionEntry(props: SolveEntryProps): VNode {
  const [answer, setAnswer] = useState("");
  const { reducer, challenge, feedback } = props;
  const next = (): void => reducer.transition("solve_challenge", {
    answer,
  });
  return (
    <AnastasisClientFrame
      title="Recovery: Solve challenge"
      onNext={() => next()}
    >
      <p>Feedback: {JSON.stringify(feedback)}</p>
      <p>Question: {challenge.instructions}</p>
      <LabeledInput label="Answer" grabFocus bind={[answer, setAnswer]} />
    </AnastasisClientFrame>
  );
}