From d6beefe6e0ccd2d37178404d50afe36faadcad50 Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Fri, 12 Nov 2021 13:44:10 -0300
Subject: fix example of successful recovery so the content of the secret can
 be decoded correctly

---
 .../src/pages/home/RecoveryFinishedScreen.tsx      | 38 ++++++++++++----------
 1 file changed, 21 insertions(+), 17 deletions(-)

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

diff --git a/packages/anastasis-webui/src/pages/home/RecoveryFinishedScreen.tsx b/packages/anastasis-webui/src/pages/home/RecoveryFinishedScreen.tsx
index dba2aa446..d83482559 100644
--- a/packages/anastasis-webui/src/pages/home/RecoveryFinishedScreen.tsx
+++ b/packages/anastasis-webui/src/pages/home/RecoveryFinishedScreen.tsx
@@ -1,18 +1,19 @@
-import { bytesToString, decodeCrock } from "@gnu-taler/taler-util";
+import { bytesToString, decodeCrock, encodeCrock } from "@gnu-taler/taler-util";
 import { h, VNode } from "preact";
 import { useEffect, useState } from "preact/hooks";
+import { stringToBytes } from "qrcode-generator";
 import { QR } from "../../components/QR";
 import { useAnastasisContext } from "../../context/anastasis";
 import { AnastasisClientFrame } from "./index";
 
 export function RecoveryFinishedScreen(): VNode {
   const reducer = useAnastasisContext();
-  const [copied, setCopied] = useState(false)
+  const [copied, setCopied] = useState(false);
   useEffect(() => {
     setTimeout(() => {
-      setCopied(false)
-    },1000)
-  }, [copied])
+      setCopied(false);
+    }, 1000);
+  }, [copied]);
 
   if (!reducer) {
     return <div>no reducer in context</div>;
@@ -44,29 +45,32 @@ export function RecoveryFinishedScreen(): VNode {
     );
   }
   const secret = bytesToString(decodeCrock(encodedSecret.value));
-  const contentURI = `data:${encodedSecret.mime},${secret}`
+  const contentURI = `data:${encodedSecret.mime},${secret}`;
   // const fileName = encodedSecret['filename']
   // data:plain/text;base64,asdasd
   return (
     <AnastasisClientFrame title="Recovery Success" hideNav>
       <h2 class="subtitle">Your secret was recovered</h2>
-      {secretName && <p class="block">
-        <b>Secret name:</b> {secretName}
-      </p>}
+      {secretName && (
+        <p class="block">
+          <b>Secret name:</b> {secretName}
+        </p>
+      )}
       <div class="block buttons" disabled={copied}>
-        <button class="button" onClick={() => {
-          navigator.clipboard.writeText(secret); 
-          setCopied(true)
-        }}>
-          { !copied ? 'Copy' : 'Copied'}
+        <button
+          class="button"
+          onClick={() => {
+            navigator.clipboard.writeText(secret);
+            setCopied(true);
+          }}
+        >
+          {!copied ? "Copy" : "Copied"}
         </button>
         <a class="button is-info" download="secret.txt" href={contentURI}>
           <div class="icon is-small ">
             <i class="mdi mdi-download" />
           </div>
-          <span>
-            Save as
-          </span>
+          <span>Save as</span>
         </a>
       </div>
       <div class="block">
-- 
cgit v1.2.3

