From c5fc49b4fae0d15ab0c68434d086947ee3cc89db Mon Sep 17 00:00:00 2001 From: Fred KISSIE Date: Thu, 5 Mar 2026 19:31:19 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20wip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CreatePolicyAuthMethodsSectionForm.tsx | 30 ++++++++++++------- .../CreatePolicyOtpEmailSectionForm.tsx | 6 ++-- .../CreatePolicyRulesSectionForm.tsx | 6 ++-- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/components/resource-policy/CreatePolicyAuthMethodsSectionForm.tsx b/src/components/resource-policy/CreatePolicyAuthMethodsSectionForm.tsx index fb456e823..f881104cb 100644 --- a/src/components/resource-policy/CreatePolicyAuthMethodsSectionForm.tsx +++ b/src/components/resource-policy/CreatePolicyAuthMethodsSectionForm.tsx @@ -43,10 +43,11 @@ import { InputOTPSlot } from "@app/components/ui/input-otp"; +import { cn } from "@app/lib/cn"; import { Binary, Bot, Key, Plus } from "lucide-react"; import { useState } from "react"; -import { type UseFormReturn, useForm } from "react-hook-form"; +import { type UseFormReturn, useForm, useWatch } from "react-hook-form"; // ─── CreatePolicyAuthMethodsSectionForm ─────────────────────────────────────── @@ -72,14 +73,23 @@ export function CreatePolicyAuthMethodsSectionForm({ form }: CreatePolicyAuthMethodsSectionFormProps) { const t = useTranslations(); - const [isOpen, setIsOpen] = useState(false); + const [isExpanded, setIsExpanded] = useState(false); const [isSetPasswordOpen, setIsSetPasswordOpen] = useState(false); const [isSetPincodeOpen, setIsSetPincodeOpen] = useState(false); const [isSetHeaderAuthOpen, setIsSetHeaderAuthOpen] = useState(false); - const password = form.watch("password"); - const pincode = form.watch("pincode"); - const headerAuth = form.watch("headerAuth"); + const password = useWatch({ + control: form.control, + name: "password" + }); + const pincode = useWatch({ + control: form.control, + name: "pincode" + }); + const headerAuth = useWatch({ + control: form.control, + name: "headerAuth" + }); const passwordForm = useForm({ resolver: zodResolver(setPasswordSchema), @@ -96,7 +106,7 @@ export function CreatePolicyAuthMethodsSectionForm({ defaultValues: { user: "", password: "", extendedCompatibility: true } }); - if (!isOpen) { + if (!isExpanded) { return ( @@ -111,7 +121,7 @@ export function CreatePolicyAuthMethodsSectionForm({