From f5f3d3e23cac9c425c20019cb89baa212154f2ed Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Fri, 26 May 2023 17:32:33 -0300
Subject: compute some error on submit

---
 .../src/pages/CreateAccount.tsx                    | 29 ++++++++++++++++------
 1 file changed, 21 insertions(+), 8 deletions(-)

(limited to 'packages/exchange-backoffice-ui/src/pages/CreateAccount.tsx')

diff --git a/packages/exchange-backoffice-ui/src/pages/CreateAccount.tsx b/packages/exchange-backoffice-ui/src/pages/CreateAccount.tsx
index 41a1d20ff..5dcb8b21d 100644
--- a/packages/exchange-backoffice-ui/src/pages/CreateAccount.tsx
+++ b/packages/exchange-backoffice-ui/src/pages/CreateAccount.tsx
@@ -1,5 +1,8 @@
 import { TranslatedString } from "@gnu-taler/taler-util";
-import { useTranslationContext } from "@gnu-taler/web-util/browser";
+import {
+  notifyError,
+  useTranslationContext,
+} from "@gnu-taler/web-util/browser";
 import { VNode, h } from "preact";
 import { createNewForm } from "../handlers/forms.js";
 
@@ -41,16 +44,26 @@ export function CreateAccount({
                     : undefined,
                 },
                 repeat: {
-                  // error: !v.repeat
-                  //   ? i18n.str`required`
-                  //   // : v.repeat !== v.password
-                  //   // ? i18n.str`doesn't match`
-                  //   : undefined,
+                  error: !v.repeat
+                    ? i18n.str`required`
+                    : v.repeat !== v.password
+                    ? i18n.str`doesn't match`
+                    : undefined,
                 },
               };
             }}
-            onSubmit={async (v) => {
-              onNewAccount(v.password);
+            onSubmit={async (v, s) => {
+              console.log(v, s);
+              const error = s?.password?.error ?? s?.repeat?.error;
+              console.log(error);
+              if (error) {
+                notifyError(
+                  "Can't create account" as TranslatedString,
+                  error as TranslatedString,
+                );
+              } else {
+                onNewAccount(v.password!);
+              }
             }}
           >
             <div class="mb-4">
-- 
cgit v1.2.3

