From c851b78053d4677388413b40a1f0e8f225329dcd Mon Sep 17 00:00:00 2001
From: Jonas Braathen <jonas.braathen@usit.uio.no>
Date: Mon, 29 Nov 2021 11:19:09 +0100
Subject: [PATCH] Fix consent step button styling and text

---
 frontend/public/locales/en/common.json           |  4 ++--
 frontend/public/locales/nb/common.json           |  3 ++-
 frontend/public/locales/nn/common.json           |  3 ++-
 frontend/src/routes/guest/register/index.tsx     | 16 ++++++++++++++--
 .../src/routes/guest/register/steps/consent.tsx  |  2 --
 5 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/frontend/public/locales/en/common.json b/frontend/public/locales/en/common.json
index 2f2f2063..4a954059 100644
--- a/frontend/public/locales/en/common.json
+++ b/frontend/public/locales/en/common.json
@@ -53,7 +53,6 @@
     "top": "Welcome to Guest Registration.",
     "body": "You are not registered as a host or guest. To become a guest, request an invite from your host. If you should have host access, contact support."
   },
-
   "loading": "Loading...",
   "termsHeader": "Terms",
   "staging": "Staging",
@@ -110,7 +109,8 @@
     "backToFrontPage": "Go to front page",
     "cancelInvitation": "Cancel",
     "resendInvitation": "Send",
-    "ok": "OK"
+    "ok": "OK",
+    "finishRegistration": "Finish registration"
   },
   "registerWizardText": {
     "registerPage": "Enter the contact information for the guest below. All fields are mandatory.",
diff --git a/frontend/public/locales/nb/common.json b/frontend/public/locales/nb/common.json
index ec30342d..989e8c09 100644
--- a/frontend/public/locales/nb/common.json
+++ b/frontend/public/locales/nb/common.json
@@ -109,7 +109,8 @@
     "backToFrontPage": "Tilbake til forsiden",
     "resendInvitation": "Send",
     "cancelInvitation": "Kanseller",
-    "ok": "OK"
+    "ok": "OK",
+    "finishRegistration": "Fullfør registrering"
   },
   "registerWizardText": {
     "registerPage": "Fyll inn kontaktinformasjonen til gjesten under. Alle feltene er obligatoriske.",
diff --git a/frontend/public/locales/nn/common.json b/frontend/public/locales/nn/common.json
index 25d2b543..4024b7a0 100644
--- a/frontend/public/locales/nn/common.json
+++ b/frontend/public/locales/nn/common.json
@@ -110,7 +110,8 @@
     "backToFrontPage": "Tilbake til forsida",
     "resendInvitation": "Send",
     "cancelInvitation": "Kanseller",
-    "ok": "OK"
+    "ok": "OK",
+    "finishRegistration": "Fullfør registrering"
   },
   "registerWizardText": {
     "registerPage": "Fyll inn kontaktinformasjonen til gjesten under. Alle feltene er obligatoriske.",
diff --git a/frontend/src/routes/guest/register/index.tsx b/frontend/src/routes/guest/register/index.tsx
index ae8b4dd8..02194ba0 100644
--- a/frontend/src/routes/guest/register/index.tsx
+++ b/frontend/src/routes/guest/register/index.tsx
@@ -71,6 +71,7 @@ export default function GuestRegister() {
   const history = useHistory()
 
   const guestRegisterRef = useRef<GuestRegisterCallableMethods>(null)
+  const guestConsentRef = useRef<GuestRegisterCallableMethods>(null)
 
   // TODO On submit successful the user should be directed to some page telling
   // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -180,6 +181,11 @@ export default function GuestRegister() {
         guestRegisterRef.current.doSubmit()
       }
     }
+    if (activeStep === Step.ConsentStep) {
+      if (guestConsentRef.current) {
+        guestConsentRef.current.doSubmit()
+      }
+    }
   }
 
   const handleBack = () => {
@@ -304,7 +310,7 @@ export default function GuestRegister() {
           <Suspense fallback={<CircularProgress />}>
             <GuestConsentStep
               nextHandler={handleForwardFromConsent}
-              ref={guestRegisterRef}
+              ref={guestConsentRef}
             />
           </Suspense>
         </Box>
@@ -333,10 +339,16 @@ export default function GuestRegister() {
             {t('button.next')}
           </Button>
         )}
+        {activeStep === Step.ConsentStep && (
+          <Button onClick={handleNext} sx={{ mr: 1 }}>
+            {t('button.finishRegistration')}
+          </Button>
+        )}
         {activeStep === Step.ConsentStep && (
           <Button
             data-testid="button-black"
-            sx={{ color: 'theme.palette.secondary', mr: 1 }}
+            color="secondary"
+            sx={{ mr: 1 }}
             onClick={handleBack}
           >
             {t('button.back')}
diff --git a/frontend/src/routes/guest/register/steps/consent.tsx b/frontend/src/routes/guest/register/steps/consent.tsx
index cf2ad31e..882b17c5 100644
--- a/frontend/src/routes/guest/register/steps/consent.tsx
+++ b/frontend/src/routes/guest/register/steps/consent.tsx
@@ -4,7 +4,6 @@ import { SubmitHandler, useForm, useFieldArray } from 'react-hook-form'
 import { useTranslation } from 'react-i18next'
 import {
   Box,
-  Button,
   FormControl,
   FormGroup,
   FormHelperText,
@@ -167,7 +166,6 @@ const GuestConsentStep = forwardRef(
               </Box>
             )
           })}
-          <Button onClick={onSubmit}>{t('button.save')}</Button>
         </form>
       </Box>
     )
-- 
GitLab