mirror of
https://github.com/fosrl/pangolin.git
synced 2026-05-17 06:24:32 +00:00
♻️ usewatch
This commit is contained in:
@@ -99,7 +99,7 @@ import {
|
|||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
|
|
||||||
import { useCallback, useMemo, useState } from "react";
|
import { useCallback, useMemo, useState } from "react";
|
||||||
import { UseFormReturn, useForm } from "react-hook-form";
|
import { UseFormReturn, useForm, useWatch } from "react-hook-form";
|
||||||
import z from "zod";
|
import z from "zod";
|
||||||
import type { PolicyFormValues } from ".";
|
import type { PolicyFormValues } from ".";
|
||||||
|
|
||||||
@@ -137,8 +137,11 @@ export function PolicyUsersRolesSection({
|
|||||||
allIdps
|
allIdps
|
||||||
}: PolicyUsersRolesSectionProps) {
|
}: PolicyUsersRolesSectionProps) {
|
||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
const ssoEnabled = form.watch("sso");
|
const ssoEnabled = useWatch({ control: form.control, name: "sso" });
|
||||||
const selectedIdpId = form.watch("skipToIdpId");
|
const selectedIdpId = useWatch({
|
||||||
|
control: form.control,
|
||||||
|
name: "skipToIdpId"
|
||||||
|
});
|
||||||
const [activeRolesTagIndex, setActiveRolesTagIndex] = useState<
|
const [activeRolesTagIndex, setActiveRolesTagIndex] = useState<
|
||||||
number | null
|
number | null
|
||||||
>(null);
|
>(null);
|
||||||
@@ -163,6 +166,7 @@ export function PolicyUsersRolesSection({
|
|||||||
label={t("ssoUse")}
|
label={t("ssoUse")}
|
||||||
defaultChecked={ssoEnabled}
|
defaultChecked={ssoEnabled}
|
||||||
onCheckedChange={(val) => {
|
onCheckedChange={(val) => {
|
||||||
|
console.log(`form.setValue("sso", ${val})`);
|
||||||
form.setValue("sso", val);
|
form.setValue("sso", val);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@@ -555,11 +559,13 @@ export function PolicyAuthMethodsSection({
|
|||||||
<CredenzaBody>
|
<CredenzaBody>
|
||||||
<Form {...headerAuthForm}>
|
<Form {...headerAuthForm}>
|
||||||
<form
|
<form
|
||||||
onSubmit={headerAuthForm.handleSubmit((data) => {
|
onSubmit={headerAuthForm.handleSubmit(
|
||||||
form.setValue("headerAuth", data);
|
(data) => {
|
||||||
setIsSetHeaderAuthOpen(false);
|
form.setValue("headerAuth", data);
|
||||||
headerAuthForm.reset();
|
setIsSetHeaderAuthOpen(false);
|
||||||
})}
|
headerAuthForm.reset();
|
||||||
|
}
|
||||||
|
)}
|
||||||
className="space-y-4"
|
className="space-y-4"
|
||||||
id="set-header-auth-form"
|
id="set-header-auth-form"
|
||||||
>
|
>
|
||||||
@@ -672,7 +678,9 @@ export function PolicyAuthMethodsSection({
|
|||||||
: () => setIsSetPasswordOpen(true)
|
: () => setIsSetPasswordOpen(true)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{password ? t("passwordRemove") : t("passwordAdd")}
|
{password
|
||||||
|
? t("passwordRemove")
|
||||||
|
: t("passwordAdd")}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -712,8 +720,12 @@ export function PolicyAuthMethodsSection({
|
|||||||
<Bot size="14" />
|
<Bot size="14" />
|
||||||
<span>
|
<span>
|
||||||
{headerAuth
|
{headerAuth
|
||||||
? t("resourceHeaderAuthProtectionEnabled")
|
? t(
|
||||||
: t("resourceHeaderAuthProtectionDisabled")}
|
"resourceHeaderAuthProtectionEnabled"
|
||||||
|
)
|
||||||
|
: t(
|
||||||
|
"resourceHeaderAuthProtectionDisabled"
|
||||||
|
)}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
Reference in New Issue
Block a user