diff --git a/README.md b/README.md index 3eecc66..6f8872e 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # www + The frontend for PulseApp. \ No newline at end of file diff --git a/src/app/(pages)/auth/layout.tsx b/src/app/(pages)/auth/layout.tsx new file mode 100644 index 0000000..b66ebc6 --- /dev/null +++ b/src/app/(pages)/auth/layout.tsx @@ -0,0 +1,22 @@ +import { ReactNode } from "react"; +import { Metadata } from "next"; + +/** + * The metadata for this layout. + */ +export const metadata: Metadata = { + title: "Auth", +}; + +/** + * The layout for the auth page. + * + * @param children the children to render + * @returns the layout jsx + */ +const AuthLayout = ({ + children, +}: Readonly<{ + children: ReactNode; +}>): ReactNode => children; +export default AuthLayout; diff --git a/src/components/auth/auth-form.tsx b/src/components/auth/auth-form.tsx index abaae4b..eeeb8a1 100644 --- a/src/components/auth/auth-form.tsx +++ b/src/components/auth/auth-form.tsx @@ -25,22 +25,30 @@ import { TurnstileObject } from "turnstile-types"; /** * Define the form schemas for the various stages. */ +const buildEmailInput = (allowEmpty: boolean) => + z + .string() + .email("Invalid email address") + .refine( + (val) => { + return !allowEmpty || val.length > 0; + }, + { message: "Email is required" } + ); + const EmailSchema = z.object({ - email: z.string().email("Must be a valid email address."), + email: buildEmailInput(false), }); const RegisterSchema = z.object({ - email: z.string().email("Must be a valid email address."), + email: buildEmailInput(true), username: z.string(), password: z.string(), passwordConfirmation: z.string(), }); const LoginSchema = z.object({ - email: z.union([ - z.string().email("Must be a valid email address."), - z.string({ message: "Must be a valid username." }), - ]), + email: buildEmailInput(true), password: z.string(), }); diff --git a/src/components/auth/footer.tsx b/src/components/auth/footer.tsx index 6cb3a75..1de3c9a 100644 --- a/src/components/auth/footer.tsx +++ b/src/components/auth/footer.tsx @@ -8,7 +8,7 @@ import Link from "next/link"; */ const Footer = (): ReactElement => (