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 ( { watch, } = useFormContext(); + const isSkipButton = !watch('hash')?.trim() && !watch("url")?.trim() + + const isContinueButtonDisabled = !!Object.keys(errors).length + const onSubmit = useCallback( async (values: UrlAndHashFormValues) => { const { url, hash } = values; + const urlSubmitValue = url ?? ""; const hashSubmitValue = hash ?? ""; setIsLoading(true); @@ -83,6 +88,8 @@ export const useRegisterAsdRepFormContext = () => { control, errors, isValid, + isContinueButtonDisabled, + isSkipButton, watch, submitForm: handleSubmit(onSubmit), };