diff --git a/apps/web/app/(app)/environments/[environmentId]/product/look/components/EditPlacementForm.tsx b/apps/web/app/(app)/environments/[environmentId]/product/look/components/EditPlacementForm.tsx index b6b28023bf..61b8a5c572 100644 --- a/apps/web/app/(app)/environments/[environmentId]/product/look/components/EditPlacementForm.tsx +++ b/apps/web/app/(app)/environments/[environmentId]/product/look/components/EditPlacementForm.tsx @@ -1,13 +1,14 @@ "use client"; import { zodResolver } from "@hookform/resolvers/zod"; -import { Controller, SubmitHandler, useForm } from "react-hook-form"; +import { SubmitHandler, useForm } from "react-hook-form"; import toast from "react-hot-toast"; import { z } from "zod"; import { cn } from "@formbricks/lib/cn"; import { TProduct } from "@formbricks/types/product"; import { Button } from "@formbricks/ui/Button"; +import { Form, FormControl, FormField, FormItem, FormLabel } from "@formbricks/ui/Form"; import { Label } from "@formbricks/ui/Label"; import { getPlacementStyle } from "@formbricks/ui/PreviewSurvey/lib/utils"; import { RadioGroup, RadioGroupItem } from "@formbricks/ui/RadioGroup"; @@ -36,12 +37,7 @@ const editPlacementSchema = z.object({ type EditPlacementFormValues = z.infer; export const EditPlacementForm = ({ product }: EditPlacementProps) => { - const { - watch, - control, - handleSubmit, - formState: { isSubmitting }, - } = useForm({ + const form = useForm({ defaultValues: { placement: product.placement, darkOverlay: product.darkOverlay ?? false, @@ -50,9 +46,10 @@ export const EditPlacementForm = ({ product }: EditPlacementProps) => { resolver: zodResolver(editPlacementSchema), }); - const currentPlacement = watch("placement"); - const darkOverlay = watch("darkOverlay"); - const clickOutsideClose = watch("clickOutsideClose"); + const currentPlacement = form.watch("placement"); + const darkOverlay = form.watch("darkOverlay"); + const clickOutsideClose = form.watch("clickOutsideClose"); + const isSubmitting = form.formState.isSubmitting; const overlayStyle = currentPlacement === "center" && darkOverlay ? "bg-gray-700/80" : "bg-slate-200"; @@ -71,108 +68,126 @@ export const EditPlacementForm = ({ product }: EditPlacementProps) => { }; return ( -
-
- ( - { - field.onChange(value); - }}> - {placements.map((placement) => ( -
- - -
- ))} -
- )} - /> -
+ + +
+ ( + + + { + field.onChange(value); + }} + className="h-full"> + {placements.map((placement) => ( +
+ + +
+ ))} +
+
+
+ )} + />
+ clickOutsideClose ? "" : "cursor-not-allowed", + "relative ml-8 h-40 w-full rounded", + overlayStyle + )}> +
+
-
- {currentPlacement === "center" && ( - <> -
- - ( - { - field.onChange(value === "darkOverlay"); - }} - className="flex space-x-4"> -
- - -
-
- - -
-
- )} - /> -
-
- - ( - { - field.onChange(value === "allow"); - }} - className="flex space-x-4"> -
- - -
-
- - -
-
- )} - /> -
- - )} - -
+ {currentPlacement === "center" && ( + <> +
+ ( + + Centered modal overlay color + + { + field.onChange(value === "darkOverlay"); + }} + className="flex space-x-4"> +
+ + +
+
+ + +
+
+
+
+ )} + /> +
+
+ ( + + + Allow users to exit by clicking outside the study + + + { + field.onChange(value === "allow"); + }} + className="flex space-x-4"> +
+ + +
+
+ + +
+
+
+
+ )} + /> +
+ + )} + + + + ); };