From 2ec2161a7e1c0787b5e9ea14311f19c6b6a52d63 Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Fri, 22 Oct 2021 01:31:46 -0300
Subject: some storybook exmaples

---
 .../src/pages/home/BackupFinishedScreen.tsx        | 26 +++++++++++++++-------
 1 file changed, 18 insertions(+), 8 deletions(-)

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

diff --git a/packages/anastasis-webui/src/pages/home/BackupFinishedScreen.tsx b/packages/anastasis-webui/src/pages/home/BackupFinishedScreen.tsx
index 6c2770947..218f1d1fd 100644
--- a/packages/anastasis-webui/src/pages/home/BackupFinishedScreen.tsx
+++ b/packages/anastasis-webui/src/pages/home/BackupFinishedScreen.tsx
@@ -1,23 +1,33 @@
 import { h, VNode } from "preact";
-import { BackupReducerProps, AnastasisClientFrame } from "./index";
+import { useAnastasisContext } from "../../context/anastasis";
+import { AnastasisClientFrame } from "./index";
 
-export function BackupFinishedScreen(props: BackupReducerProps): VNode {
+export function BackupFinishedScreen(): VNode {
+  const reducer = useAnastasisContext()
+  if (!reducer) {
+    return <div>no reducer in context</div>
+  }
+  if (!reducer.currentReducerState || reducer.currentReducerState.backup_state === undefined) {
+    return <div>invalid state</div>
+  }
+  const details = reducer.currentReducerState.success_details
   return (<AnastasisClientFrame hideNext title="Backup finished">
     <p>
-      Your backup of secret "{props.backupState.secret_name ?? "??"}" was
+      Your backup of secret "{reducer.currentReducerState.secret_name ?? "??"}" was
       successful.
     </p>
     <p>The backup is stored by the following providers:</p>
-    <ul>
-      {Object.keys(props.backupState.success_details!).map((x, i) => {
-        const sd = props.backupState.success_details![x];
+
+    {details && <ul>
+      {Object.keys(details).map((x, i) => {
+        const sd = details[x];
         return (
           <li key={i}>
             {x} (Policy version {sd.policy_version})
           </li>
         );
       })}
-    </ul>
-    <button onClick={() => props.reducer.reset()}>Back to start</button>
+    </ul>}
+    <button onClick={() => reducer.reset()}>Back to start</button>
   </AnastasisClientFrame>);
 }
-- 
cgit v1.2.3

