import { LabeledTextField } from "app/core/components/LabeledTextField" import { Form, FORM_ERROR } from "app/core/components/Form" import signup from "app/auth/mutations/signup" import { Signup } from "app/auth/validations" import { useMutation } from "@blitzjs/rpc" type SignupFormProps = { onSuccess?: () => void } export const SignupForm = (props: SignupFormProps) => { const [signupMutation] = useMutation(signup) return (

Create an Account

{ try { await signupMutation(values) props.onSuccess?.() } catch (error: any) { if (error.code === "P2002" && error.meta?.target?.includes("email")) { // This error comes from Prisma return { email: "This email is already being used" } } else { return { [FORM_ERROR]: error.toString() } } } }} >
) } export default SignupForm