From 9fb0e7d0b386a1b10a39d0b664131590cd0c3a68 Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Thu, 22 Dec 2022 18:38:21 -0300
Subject: prevent form submit

---
 packages/demobank-ui/src/pages/RegistrationPage.tsx | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

(limited to 'packages/demobank-ui/src/pages/RegistrationPage.tsx')

diff --git a/packages/demobank-ui/src/pages/RegistrationPage.tsx b/packages/demobank-ui/src/pages/RegistrationPage.tsx
index 9d84cdf44..183fa993e 100644
--- a/packages/demobank-ui/src/pages/RegistrationPage.tsx
+++ b/packages/demobank-ui/src/pages/RegistrationPage.tsx
@@ -84,7 +84,13 @@ function RegistrationForm(): VNode {
       <h1 class="nav">{i18n.str`Welcome to ${bankUiSettings.bankName}!`}</h1>
       <article>
         <div class="register-div">
-          <form class="register-form" noValidate>
+          <form
+            class="register-form"
+            noValidate
+            onSubmit={(e) => {
+              e.preventDefault();
+            }}
+          >
             <div class="pure-form">
               <h2>{i18n.str`Please register!`}</h2>
               <p class="unameFieldLabel registerFieldLabel formFieldLabel">
@@ -144,8 +150,10 @@ function RegistrationForm(): VNode {
               <br />
               <button
                 class="pure-button pure-button-primary btn-register"
+                type="submit"
                 disabled={!!errors}
-                onClick={() => {
+                onClick={(e) => {
+                  e.preventDefault();
                   if (!username || !password) return;
                   registrationCall(
                     { username, password },
@@ -164,7 +172,8 @@ function RegistrationForm(): VNode {
               {/* FIXME: should use a different color */}
               <button
                 class="pure-button pure-button-secondary btn-cancel"
-                onClick={() => {
+                onClick={(e) => {
+                  e.preventDefault();
                   setUsername(undefined);
                   setPassword(undefined);
                   setRepeatPassword(undefined);
-- 
cgit v1.2.3

