From 5883d42d800c7b444c59d626bcaa5abca7dc83d0 Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Tue, 19 Oct 2021 10:56:52 -0300
Subject: add template from merchant backoffice

---
 .../anastasis-webui/src/pages/home/SolveScreen.tsx | 41 ++++++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 packages/anastasis-webui/src/pages/home/SolveScreen.tsx

(limited to 'packages/anastasis-webui/src/pages/home/SolveScreen.tsx')

diff --git a/packages/anastasis-webui/src/pages/home/SolveScreen.tsx b/packages/anastasis-webui/src/pages/home/SolveScreen.tsx
new file mode 100644
index 000000000..46ff8227d
--- /dev/null
+++ b/packages/anastasis-webui/src/pages/home/SolveScreen.tsx
@@ -0,0 +1,41 @@
+import { h, VNode } from "preact";
+import { AnastasisReducerApi, ChallengeFeedback, ChallengeInfo } from "../../hooks/use-anastasis-reducer";
+import { SolveEmailEntry } from "./SolveEmailEntry";
+import { SolvePostEntry } from "./SolvePostEntry";
+import { SolveQuestionEntry } from "./SolveQuestionEntry";
+import { SolveSmsEntry } from "./SolveSmsEntry";
+import { SolveUnsupportedEntry } from "./SolveUnsupportedEntry";
+import { RecoveryReducerProps } from "./index";
+
+export function SolveScreen(props: RecoveryReducerProps): VNode {
+  const chArr = props.recoveryState.recovery_information!.challenges;
+  const challengeFeedback = props.recoveryState.challenge_feedback ?? {};
+  const selectedUuid = props.recoveryState.selected_challenge_uuid!;
+  const challenges: {
+    [uuid: string]: ChallengeInfo;
+  } = {};
+  for (const ch of chArr) {
+    challenges[ch.uuid] = ch;
+  }
+  const selectedChallenge = challenges[selectedUuid];
+  const dialogMap: Record<string, (p: SolveEntryProps) => h.JSX.Element> = {
+    question: SolveQuestionEntry,
+    sms: SolveSmsEntry,
+    email: SolveEmailEntry,
+    post: SolvePostEntry,
+  };
+  const SolveDialog = dialogMap[selectedChallenge.type] ?? SolveUnsupportedEntry;
+  return (
+    <SolveDialog
+      challenge={selectedChallenge}
+      reducer={props.reducer}
+      feedback={challengeFeedback[selectedUuid]} />
+  );
+}
+
+export interface SolveEntryProps {
+  reducer: AnastasisReducerApi;
+  challenge: ChallengeInfo;
+  feedback?: ChallengeFeedback;
+}
+
-- 
cgit v1.2.3

