()
| 39 | type RegisterFormValues = z.infer<typeof registerSchema>; |
| 40 | |
| 41 | export function RegisterForm() { |
| 42 | const router = useRouter(); |
| 43 | |
| 44 | const form = useForm<RegisterFormValues>({ |
| 45 | resolver: zodResolver(registerSchema), |
| 46 | defaultValues: { |
| 47 | email: "", |
| 48 | password: "", |
| 49 | confirmPassword: "", |
| 50 | }, |
| 51 | }); |
| 52 | |
| 53 | const signInGithub = async () => { |
| 54 | await authClient.signIn.social({ |
| 55 | provider: "github", |
| 56 | }, { |
| 57 | onSuccess: () => { |
| 58 | router.push("/"); |
| 59 | }, |
| 60 | onError: () => { |
| 61 | toast.error("Something went wrong"); |
| 62 | }, |
| 63 | }); |
| 64 | }; |
| 65 | |
| 66 | const signInGoogle = async () => { |
| 67 | await authClient.signIn.social({ |
| 68 | provider: "google", |
| 69 | }, { |
| 70 | onSuccess: () => { |
| 71 | router.push("/"); |
| 72 | }, |
| 73 | onError: () => { |
| 74 | toast.error("Something went wrong"); |
| 75 | }, |
| 76 | }); |
| 77 | }; |
| 78 | |
| 79 | const onSubmit = async (values: RegisterFormValues) => { |
| 80 | await authClient.signUp.email( |
| 81 | { |
| 82 | name: values.email, |
| 83 | email: values.email, |
| 84 | password: values.password, |
| 85 | callbackURL: "/", |
| 86 | }, |
| 87 | { |
| 88 | onSuccess: () => { |
| 89 | router.push("/"); |
| 90 | }, |
| 91 | onError: (ctx) => { |
| 92 | toast.error(ctx.error.message); |
| 93 | } |
| 94 | } |
| 95 | ) |
| 96 | }; |
| 97 | |
| 98 | const isPending = form.formState.isSubmitting; |
nothing calls this directly
no outgoing calls
no test coverage detected