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

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