From eb6c3342c17b48893ff2a0a1dbbd9ee239decfec Mon Sep 17 00:00:00 2001 From: Pablo Lara Date: Tue, 4 Feb 2025 12:24:27 +0100 Subject: [PATCH] feat: add checkbox to accept the terms --- ui/components/auth/oss/auth-form.tsx | 44 +++++++++++++++++++++++++--- ui/types/authFormSchema.ts | 7 +++++ 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/ui/components/auth/oss/auth-form.tsx b/ui/components/auth/oss/auth-form.tsx index e215abad4f..4b3a6e416b 100644 --- a/ui/components/auth/oss/auth-form.tsx +++ b/ui/components/auth/oss/auth-form.tsx @@ -1,7 +1,7 @@ "use client"; import { zodResolver } from "@hookform/resolvers/zod"; -import { Link } from "@nextui-org/react"; +import { Checkbox, Link } from "@nextui-org/react"; import { useRouter } from "next/navigation"; import { useForm } from "react-hook-form"; import { z } from "zod"; @@ -11,7 +11,12 @@ import { NotificationIcon, ProwlerExtended } from "@/components/icons"; import { ThemeSwitch } from "@/components/ThemeSwitch"; import { useToast } from "@/components/ui"; import { CustomButton, CustomInput } from "@/components/ui/custom"; -import { Form } from "@/components/ui/form"; +import { + Form, + FormControl, + FormField, + FormMessage, +} from "@/components/ui/form"; import { ApiError, authFormSchema } from "@/types"; export const AuthForm = ({ @@ -213,13 +218,44 @@ export const AuthForm = ({ isDisabled={invitationToken !== null && true} /> )} + + {process.env.NEXT_PUBLIC_IS_CLOUD_ENV === "true" && ( + ( + <> + + field.onChange(e.target.checked)} + > + I agree with the  + + Terms of Service + +  of Prowler + + + + + )} + /> + )} )} - {form.formState.errors?.email && ( + {type === "sign-in" && form.formState.errors?.email && (
-

No user found

+

Invalid email or password

)} diff --git a/ui/types/authFormSchema.ts b/ui/types/authFormSchema.ts index ac0fc46dcf..93f1f7dcfc 100644 --- a/ui/types/authFormSchema.ts +++ b/ui/types/authFormSchema.ts @@ -24,6 +24,13 @@ export const authFormSchema = (type: string) => invitationToken: type === "sign-in" ? z.string().optional() : z.string().optional(), + termsAndConditions: + type === "sign-in" || process.env.NEXT_PUBLIC_IS_CLOUD_ENV !== "true" + ? z.boolean().optional() + : z.boolean().refine((value) => value === true, { + message: "You must accept the terms and conditions.", + }), + // Fields for Sign In and Sign Up email: z.string().email(), password: z.string().min(12, {