Skip to content

Commit

Permalink
Répare l'état de la case à cocher des CGU
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
marc-rutkowski committed Oct 7, 2024
1 parent 820d82d commit cc2c3a1
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions packages/auth/components/Signup/SignupStep3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,19 @@ const useSignupStep3 = () => {
nom: z.string().min(1, 'Champ requis'),
prenom: z.string().min(1, 'Champ requis'),
telephone: z.string().refine(validateTel),
cgu_acceptees: z.boolean().refine(value => !!value, {
cgu_acceptees: z.boolean().refine((value) => !!value, {
message: "Vous devez accepter le cadre d'utilisation de la plateforme",
}),
});

return useForm({
resolver: zodResolver(validationSchema),
defaultValues: {
nom: '',
prenom: '',
telephone: '',
cgu_acceptees: false,
},
});
};

Expand All @@ -41,19 +47,22 @@ export const SignupStep3 = (props: SignupPropsWithState) => {
const {
handleSubmit,
register,
formState: {isValid, errors},
formState: { isValid, errors },
watch,
} = useSignupStep3();
const eventTracker = useEventTracker('auth/signup/dcp');

const cgu_acceptees = watch('cgu_acceptees');

const {
isLoading,
error,
onSubmit,
formState: {email},
formState: { email },
} = props;

const onSubmitForm = handleSubmit(data => {
onSubmit({...(data as SignupDataStep3), email});
const onSubmitForm = handleSubmit((data) => {
onSubmit({ ...(data as SignupDataStep3), email });
// @ts-expect-error en attendant de gérer le 2ème argument optionnel
eventTracker('cta_submit', {});
});
Expand Down Expand Up @@ -109,6 +118,7 @@ export const SignupStep3 = (props: SignupPropsWithState) => {
</>
}
{...register('cgu_acceptees')}
checked={cgu_acceptees ?? false}
/>
{!!error && (
<FieldMessage messageClassName="mt-4" state="error" message={error} />
Expand Down

0 comments on commit cc2c3a1

Please sign in to comment.