Skip to content

Commit

Permalink
[#152] improve form
Browse files Browse the repository at this point in the history
  • Loading branch information
Sworzen1 committed Feb 28, 2024
1 parent 1293672 commit abf69be
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@ 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), []);

const onClickBackButton = useCallback(() => setStep(1), []);

return (
<BgCard
actionButtonLabel={t("continue")}
actionButtonLabel={isSkipButton ? t("skip") : t("continue")}
onClickActionButton={onClickContinue}
isActionButtonDisabled={isContinueButtonDisabled}
onClickBackButton={onClickBackButton}
>
<Typography
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -92,6 +96,8 @@ export const useRegisterAsdRepFormContext = () => {
control,
errors,
isValid,
isContinueButtonDisabled,
isSkipButton,
watch,
submitForm: handleSubmit(onSubmit),
};
Expand Down

0 comments on commit abf69be

Please sign in to comment.