diff --git a/govtool/frontend/src/components/organisms/RegisterAsdRepStepTwo.tsx b/govtool/frontend/src/components/organisms/RegisterAsdRepStepTwo.tsx index 2ef784b41..40a673b9b 100644 --- a/govtool/frontend/src/components/organisms/RegisterAsdRepStepTwo.tsx +++ b/govtool/frontend/src/components/organisms/RegisterAsdRepStepTwo.tsx @@ -18,7 +18,7 @@ interface Props { export const RegisterAsdRepStepTwo = ({ setStep }: Props) => { const { t } = useTranslation(); const { isMobile } = useScreenDimension(); - const { control, errors } = useRegisterAsdRepFormContext(); + const { control, errors,isContinueButtonDisabled, isSkipButton } = useRegisterAsdRepFormContext(); const onClickContinue = useCallback(() => setStep(3), []); @@ -26,8 +26,9 @@ export const RegisterAsdRepStepTwo = ({ setStep }: Props) => { return ( <BgCard - actionButtonLabel={t("continue")} + actionButtonLabel={isSkipButton ? t("skip") : t("continue")} onClickActionButton={onClickContinue} + isActionButtonDisabled={isContinueButtonDisabled} onClickBackButton={onClickBackButton} > <Typography diff --git a/govtool/frontend/src/hooks/forms/useRegisterAsdRepFormContext.tsx b/govtool/frontend/src/hooks/forms/useRegisterAsdRepFormContext.tsx index 92e43b3e5..575e4ce6a 100644 --- a/govtool/frontend/src/hooks/forms/useRegisterAsdRepFormContext.tsx +++ b/govtool/frontend/src/hooks/forms/useRegisterAsdRepFormContext.tsx @@ -25,6 +25,10 @@ export const useRegisterAsdRepFormContext = () => { watch, } = useFormContext<UrlAndHashFormValues>(); + const isSkipButton = !watch('hash')?.trim() && !watch("url")?.trim() + + const isContinueButtonDisabled = !!Object.keys(errors).length + const onSubmit = useCallback( async (values: UrlAndHashFormValues) => { const { url, hash } = values; @@ -92,6 +96,8 @@ export const useRegisterAsdRepFormContext = () => { control, errors, isValid, + isContinueButtonDisabled, + isSkipButton, watch, submitForm: handleSubmit(onSubmit), };