Skip to content

Commit

Permalink
fix: check all validations in PersonalInfoForm
Browse files Browse the repository at this point in the history
  • Loading branch information
ooooorobo committed Dec 23, 2024
1 parent bc5398b commit 46a24a2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/processes/my_profile/PersonalInfoForm/PersonalInfoForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,12 @@ export const PersonalInfoForm = ({ onClickNextForm }: { onClickNextForm?: () =>
const currentStep = useMemo(() => PersonalInfoStepMap[step], [step]);
const canShowNext = useMemo(() => step < PersonalInfoStepEnum.HEIGHT || onClickNextForm, [onClickNextForm, step]);

const canClickNext = useMemo(
() => (step < PersonalInfoStepEnum.HEIGHT || onClickNextForm) && currentStep?.canGoNext(personalInfoData),
[currentStep, onClickNextForm, personalInfoData, step],
);
const canClickNext = useMemo(() => {
const isValid = Object.values(PersonalInfoStepMap)
.slice(0, step + 1)
.every((v) => v.canGoNext(personalInfoData));
return (step < PersonalInfoStepEnum.HEIGHT || onClickNextForm) && isValid;
}, [onClickNextForm, personalInfoData, step]);

const onClickNext = () => {
step < PersonalInfoStepEnum.HEIGHT ? setStep((prev) => prev + 1) : onClickNextForm?.();
Expand Down

0 comments on commit 46a24a2

Please sign in to comment.