From e851ee79a5f1c33be5c10cddbfec3aed571ccb1c Mon Sep 17 00:00:00 2001 From: cdOut <88325488+cdOut@users.noreply.github.com> Date: Wed, 27 Mar 2024 13:02:55 +0100 Subject: [PATCH] add error for submit button when no purpose selected --- src/languages/en.ts | 1 + src/languages/es.ts | 1 + .../BaseOnboardingPurpose.tsx | 28 +++++++++++++------ 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 4cb55c286980..c24a81026d55 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1300,6 +1300,7 @@ export default { whatsYourName: "What's your name?", purpose: { title: 'What do you want to do today?', + error: 'Please make a selection before continuing', [CONST.ONBOARDING_CHOICES.TRACK]: 'Track business spend for taxes', [CONST.ONBOARDING_CHOICES.EMPLOYER]: 'Get paid back by my employer', [CONST.ONBOARDING_CHOICES.MANAGE_TEAM]: "Manage my team's expenses", diff --git a/src/languages/es.ts b/src/languages/es.ts index 55b0bd7a1e49..77a826030362 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -1302,6 +1302,7 @@ export default { whatsYourName: '¿Cómo te llamas?', purpose: { title: '¿Qué quieres hacer hoy?', + error: 'Por favor, haga una selección antes de continuar.', [CONST.ONBOARDING_CHOICES.TRACK]: 'Seguimiento fiscal de los gastos de las empresas', [CONST.ONBOARDING_CHOICES.EMPLOYER]: 'Cobrar de mi empresa', [CONST.ONBOARDING_CHOICES.MANAGE_TEAM]: 'Gestionar los gastos de mi equipo', diff --git a/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx b/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx index 4405e73147f7..93f6a23ca1d8 100644 --- a/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx +++ b/src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx @@ -1,7 +1,6 @@ import React, {useCallback, useMemo, useState} from 'react'; import {View} from 'react-native'; import {ScrollView} from 'react-native-gesture-handler'; -import Button from '@components/Button'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import Icon from '@components/Icon'; import * as Expensicons from '@components/Icon/Expensicons'; @@ -20,6 +19,7 @@ import variables from '@styles/variables'; import * as Report from '@userActions/Report'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; +import FormAlertWithSubmitButton from '@components/FormAlertWithSubmitButton'; type ValuesType = T[keyof T]; type SelectedPurposeType = ValuesType | undefined; @@ -47,8 +47,11 @@ function BaseOnboardingPurpose({shouldUseNativeStyles, shouldEnableMaxHeight}: B const {shouldUseNarrowLayout} = useOnboardingLayout(); const [selectedPurpose, setSelectedPurpose] = useState(undefined); const {isSmallScreenWidth, windowHeight} = useWindowDimensions(); + const [error, setError] = useState(false); const theme = useTheme(); + const errorMessage = error ? 'onboarding.purpose.error' : ''; + const maxHeight = shouldEnableMaxHeight ? windowHeight : undefined; const paddingHorizontal = shouldUseNarrowLayout ? styles.ph8 : styles.ph5; @@ -108,6 +111,7 @@ function BaseOnboardingPurpose({shouldUseNativeStyles, shouldEnableMaxHeight}: B shouldShowRightComponent: isSelected, onPress: () => { setSelectedPurpose(choice); + setError(false); }, }; }); @@ -134,13 +138,21 @@ function BaseOnboardingPurpose({shouldUseNativeStyles, shouldEnableMaxHeight}: B /> -