Move React Hook Form errors to formState (#2412)
This commit is contained in:
parent
818b8cdbb9
commit
4a7c0436cc
42 changed files with 208 additions and 59 deletions
|
@ -43,8 +43,12 @@ export const ExecutionConfigModal = ({
|
||||||
const [configDescription, setConfigDescription] =
|
const [configDescription, setConfigDescription] =
|
||||||
useState<AuthenticatorConfigInfoRepresentation>();
|
useState<AuthenticatorConfigInfoRepresentation>();
|
||||||
|
|
||||||
const { register, errors, setValue, handleSubmit } =
|
const {
|
||||||
useForm<ExecutionConfigModalForm>();
|
register,
|
||||||
|
setValue,
|
||||||
|
handleSubmit,
|
||||||
|
formState: { errors },
|
||||||
|
} = useForm<ExecutionConfigModalForm>();
|
||||||
|
|
||||||
const setupForm = (
|
const setupForm = (
|
||||||
configDescription: AuthenticatorConfigInfoRepresentation,
|
configDescription: AuthenticatorConfigInfoRepresentation,
|
||||||
|
|
|
@ -40,7 +40,12 @@ export const AddSubFlowModal = ({
|
||||||
onCancel,
|
onCancel,
|
||||||
}: AddSubFlowProps) => {
|
}: AddSubFlowProps) => {
|
||||||
const { t } = useTranslation("authentication");
|
const { t } = useTranslation("authentication");
|
||||||
const { register, control, errors, handleSubmit } = useForm<Flow>();
|
const {
|
||||||
|
register,
|
||||||
|
control,
|
||||||
|
handleSubmit,
|
||||||
|
formState: { errors },
|
||||||
|
} = useForm<Flow>();
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const [openProvider, setOpenProvider] = useState(false);
|
const [openProvider, setOpenProvider] = useState(false);
|
||||||
const [formProviders, setFormProviders] =
|
const [formProviders, setFormProviders] =
|
||||||
|
|
|
@ -12,7 +12,10 @@ import { HelpItem } from "../../components/help-enabler/HelpItem";
|
||||||
|
|
||||||
export const NameDescription = () => {
|
export const NameDescription = () => {
|
||||||
const { t } = useTranslation("authentication");
|
const { t } = useTranslation("authentication");
|
||||||
const { register, errors } = useFormContext();
|
const {
|
||||||
|
register,
|
||||||
|
formState: { errors },
|
||||||
|
} = useFormContext();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
|
@ -41,10 +41,9 @@ export const OtpPolicy = ({ realm, realmUpdated }: OtpPolicyProps) => {
|
||||||
const {
|
const {
|
||||||
control,
|
control,
|
||||||
register,
|
register,
|
||||||
errors,
|
|
||||||
reset,
|
reset,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
formState: { isDirty },
|
formState: { isDirty, errors },
|
||||||
} = useForm({ mode: "onChange" });
|
} = useForm({ mode: "onChange" });
|
||||||
const adminClient = useAdminClient();
|
const adminClient = useAdminClient();
|
||||||
const { realm: realmName } = useRealm();
|
const { realm: realmName } = useRealm();
|
||||||
|
|
|
@ -27,7 +27,11 @@ export const PolicyRow = ({
|
||||||
onRemove,
|
onRemove,
|
||||||
}: PolicyRowProps) => {
|
}: PolicyRowProps) => {
|
||||||
const { t } = useTranslation("authentication");
|
const { t } = useTranslation("authentication");
|
||||||
const { control, register, errors } = useFormContext();
|
const {
|
||||||
|
control,
|
||||||
|
register,
|
||||||
|
formState: { errors },
|
||||||
|
} = useFormContext();
|
||||||
return (
|
return (
|
||||||
<FormGroup
|
<FormGroup
|
||||||
label={displayName}
|
label={displayName}
|
||||||
|
|
|
@ -37,8 +37,13 @@ type ScopeFormProps = {
|
||||||
export const ScopeForm = ({ clientScope, save }: ScopeFormProps) => {
|
export const ScopeForm = ({ clientScope, save }: ScopeFormProps) => {
|
||||||
const { t } = useTranslation("client-scopes");
|
const { t } = useTranslation("client-scopes");
|
||||||
const { t: tc } = useTranslation("clients");
|
const { t: tc } = useTranslation("clients");
|
||||||
const { register, control, handleSubmit, errors, setValue } =
|
const {
|
||||||
useForm<ClientScopeRepresentation>({
|
register,
|
||||||
|
control,
|
||||||
|
handleSubmit,
|
||||||
|
setValue,
|
||||||
|
formState: { errors },
|
||||||
|
} = useForm<ClientScopeRepresentation>({
|
||||||
defaultValues: { attributes: { "display.on.consent.screen": "true" } },
|
defaultValues: { attributes: { "display.on.consent.screen": "true" } },
|
||||||
});
|
});
|
||||||
const { realm } = useRealm();
|
const { realm } = useRealm();
|
||||||
|
|
|
@ -19,7 +19,11 @@ type ClientDescriptionProps = {
|
||||||
|
|
||||||
export const ClientDescription = ({ protocol }: ClientDescriptionProps) => {
|
export const ClientDescription = ({ protocol }: ClientDescriptionProps) => {
|
||||||
const { t } = useTranslation("clients");
|
const { t } = useTranslation("clients");
|
||||||
const { register, errors, control } = useFormContext<ClientRepresentation>();
|
const {
|
||||||
|
register,
|
||||||
|
control,
|
||||||
|
formState: { errors },
|
||||||
|
} = useFormContext<ClientRepresentation>();
|
||||||
return (
|
return (
|
||||||
<FormAccess role="manage-clients" unWrap>
|
<FormAccess role="manage-clients" unWrap>
|
||||||
<FormGroup
|
<FormGroup
|
||||||
|
|
|
@ -38,8 +38,12 @@ export const ClientSettings = ({
|
||||||
save,
|
save,
|
||||||
reset,
|
reset,
|
||||||
}: ClientSettingsProps) => {
|
}: ClientSettingsProps) => {
|
||||||
const { register, control, watch, errors } =
|
const {
|
||||||
useFormContext<ClientRepresentation>();
|
register,
|
||||||
|
control,
|
||||||
|
watch,
|
||||||
|
formState: { errors },
|
||||||
|
} = useFormContext<ClientRepresentation>();
|
||||||
const { t } = useTranslation("clients");
|
const { t } = useTranslation("clients");
|
||||||
const { realm } = useRealm();
|
const { realm } = useRealm();
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,10 @@ import { getProtocolName } from "../utils";
|
||||||
|
|
||||||
export const GeneralSettings = () => {
|
export const GeneralSettings = () => {
|
||||||
const { t } = useTranslation("clients");
|
const { t } = useTranslation("clients");
|
||||||
const { errors, control } = useFormContext();
|
const {
|
||||||
|
control,
|
||||||
|
formState: { errors },
|
||||||
|
} = useFormContext();
|
||||||
|
|
||||||
const providers = useLoginProviders();
|
const providers = useLoginProviders();
|
||||||
const [open, isOpen] = useState(false);
|
const [open, isOpen] = useState(false);
|
||||||
|
|
|
@ -32,7 +32,10 @@ export const ResourcesPolicySelect = ({
|
||||||
const { t } = useTranslation("clients");
|
const { t } = useTranslation("clients");
|
||||||
const adminClient = useAdminClient();
|
const adminClient = useAdminClient();
|
||||||
|
|
||||||
const { control, errors } = useFormContext<PolicyRepresentation>();
|
const {
|
||||||
|
control,
|
||||||
|
formState: { errors },
|
||||||
|
} = useFormContext<PolicyRepresentation>();
|
||||||
const [items, setItems] = useState<Policies[]>([]);
|
const [items, setItems] = useState<Policies[]>([]);
|
||||||
const [search, setSearch] = useState("");
|
const [search, setSearch] = useState("");
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
|
@ -35,8 +35,12 @@ export default function ScopeDetails() {
|
||||||
|
|
||||||
const [deleteDialog, toggleDeleteDialog] = useToggle();
|
const [deleteDialog, toggleDeleteDialog] = useToggle();
|
||||||
const [scope, setScope] = useState<ScopeRepresentation>();
|
const [scope, setScope] = useState<ScopeRepresentation>();
|
||||||
const { register, errors, reset, handleSubmit } =
|
const {
|
||||||
useForm<ScopeRepresentation>({
|
register,
|
||||||
|
reset,
|
||||||
|
handleSubmit,
|
||||||
|
formState: { errors },
|
||||||
|
} = useForm<ScopeRepresentation>({
|
||||||
mode: "onChange",
|
mode: "onChange",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,11 @@ export const ScopeSelect = ({
|
||||||
const { t } = useTranslation("clients");
|
const { t } = useTranslation("clients");
|
||||||
const adminClient = useAdminClient();
|
const adminClient = useAdminClient();
|
||||||
|
|
||||||
const { control, errors, setValue } = useFormContext();
|
const {
|
||||||
|
control,
|
||||||
|
setValue,
|
||||||
|
formState: { errors },
|
||||||
|
} = useFormContext();
|
||||||
|
|
||||||
const [scopes, setScopes] = useState<ScopeRepresentation[]>([]);
|
const [scopes, setScopes] = useState<ScopeRepresentation[]>([]);
|
||||||
const [search, setSearch] = useState("");
|
const [search, setSearch] = useState("");
|
||||||
|
|
|
@ -15,7 +15,11 @@ import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
export const Client = () => {
|
export const Client = () => {
|
||||||
const { t } = useTranslation("clients");
|
const { t } = useTranslation("clients");
|
||||||
const { control, getValues, errors } = useFormContext();
|
const {
|
||||||
|
control,
|
||||||
|
getValues,
|
||||||
|
formState: { errors },
|
||||||
|
} = useFormContext();
|
||||||
const values: string[] | undefined = getValues("clients");
|
const values: string[] | undefined = getValues("clients");
|
||||||
|
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
|
@ -25,7 +25,12 @@ export type RequiredIdValue = {
|
||||||
|
|
||||||
export const ClientScope = () => {
|
export const ClientScope = () => {
|
||||||
const { t } = useTranslation("clients");
|
const { t } = useTranslation("clients");
|
||||||
const { control, getValues, setValue, errors } = useFormContext<{
|
const {
|
||||||
|
control,
|
||||||
|
getValues,
|
||||||
|
setValue,
|
||||||
|
formState: { errors },
|
||||||
|
} = useFormContext<{
|
||||||
clientScopes: RequiredIdValue[];
|
clientScopes: RequiredIdValue[];
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,13 @@ export type GroupValue = {
|
||||||
|
|
||||||
export const Group = () => {
|
export const Group = () => {
|
||||||
const { t } = useTranslation("clients");
|
const { t } = useTranslation("clients");
|
||||||
const { control, register, getValues, setValue, errors } = useFormContext<{
|
const {
|
||||||
|
control,
|
||||||
|
register,
|
||||||
|
getValues,
|
||||||
|
setValue,
|
||||||
|
formState: { errors },
|
||||||
|
} = useFormContext<{
|
||||||
groups?: GroupValue[];
|
groups?: GroupValue[];
|
||||||
}>();
|
}>();
|
||||||
const values = getValues("groups");
|
const values = getValues("groups");
|
||||||
|
|
|
@ -16,7 +16,10 @@ type NameDescriptionProps = {
|
||||||
|
|
||||||
export const NameDescription = ({ prefix }: NameDescriptionProps) => {
|
export const NameDescription = ({ prefix }: NameDescriptionProps) => {
|
||||||
const { t } = useTranslation("clients");
|
const { t } = useTranslation("clients");
|
||||||
const { register, errors } = useFormContext();
|
const {
|
||||||
|
register,
|
||||||
|
formState: { errors },
|
||||||
|
} = useFormContext();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
|
@ -7,7 +7,10 @@ import { HelpItem } from "../../../components/help-enabler/HelpItem";
|
||||||
|
|
||||||
export const Regex = () => {
|
export const Regex = () => {
|
||||||
const { t } = useTranslation("clients");
|
const { t } = useTranslation("clients");
|
||||||
const { register, errors } = useFormContext();
|
const {
|
||||||
|
register,
|
||||||
|
formState: { errors },
|
||||||
|
} = useFormContext();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
|
@ -20,7 +20,12 @@ import { AddRoleMappingModal } from "../../../components/role-mapping/AddRoleMap
|
||||||
|
|
||||||
export const Role = () => {
|
export const Role = () => {
|
||||||
const { t } = useTranslation("clients");
|
const { t } = useTranslation("clients");
|
||||||
const { control, getValues, setValue, errors } = useFormContext<{
|
const {
|
||||||
|
control,
|
||||||
|
getValues,
|
||||||
|
setValue,
|
||||||
|
formState: { errors },
|
||||||
|
} = useFormContext<{
|
||||||
roles?: RequiredIdValue[];
|
roles?: RequiredIdValue[];
|
||||||
}>();
|
}>();
|
||||||
const values = getValues("roles");
|
const values = getValues("roles");
|
||||||
|
|
|
@ -15,7 +15,11 @@ import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
export const User = () => {
|
export const User = () => {
|
||||||
const { t } = useTranslation("clients");
|
const { t } = useTranslation("clients");
|
||||||
const { control, getValues, errors } = useFormContext();
|
const {
|
||||||
|
control,
|
||||||
|
getValues,
|
||||||
|
formState: { errors },
|
||||||
|
} = useFormContext();
|
||||||
const values: string[] | undefined = getValues("users");
|
const values: string[] | undefined = getValues("users");
|
||||||
|
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
|
@ -11,7 +11,11 @@ import { HelpItem } from "../../components/help-enabler/HelpItem";
|
||||||
|
|
||||||
export const X509 = () => {
|
export const X509 = () => {
|
||||||
const { t } = useTranslation("clients");
|
const { t } = useTranslation("clients");
|
||||||
const { register, control, errors } = useFormContext();
|
const {
|
||||||
|
register,
|
||||||
|
control,
|
||||||
|
formState: { errors },
|
||||||
|
} = useFormContext();
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<FormGroup
|
<FormGroup
|
||||||
|
|
|
@ -27,8 +27,7 @@ export default function CreateInitialAccessToken() {
|
||||||
const {
|
const {
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
control,
|
control,
|
||||||
errors,
|
formState: { isValid, errors },
|
||||||
formState: { isValid },
|
|
||||||
} = useForm({ mode: "onChange" });
|
} = useForm({ mode: "onChange" });
|
||||||
|
|
||||||
const adminClient = useAdminClient();
|
const adminClient = useAdminClient();
|
||||||
|
|
|
@ -34,7 +34,11 @@ export const RoleComponent = ({
|
||||||
|
|
||||||
const adminClient = useAdminClient();
|
const adminClient = useAdminClient();
|
||||||
const { realm } = useRealm();
|
const { realm } = useRealm();
|
||||||
const { control, errors, getValues } = useFormContext();
|
const {
|
||||||
|
control,
|
||||||
|
getValues,
|
||||||
|
formState: { errors },
|
||||||
|
} = useFormContext();
|
||||||
|
|
||||||
const [roleOpen, setRoleOpen] = useState(false);
|
const [roleOpen, setRoleOpen] = useState(false);
|
||||||
const [clientsOpen, setClientsOpen] = useState(false);
|
const [clientsOpen, setClientsOpen] = useState(false);
|
||||||
|
|
|
@ -33,7 +33,11 @@ export const GroupsModal = ({
|
||||||
const { t } = useTranslation("groups");
|
const { t } = useTranslation("groups");
|
||||||
const adminClient = useAdminClient();
|
const adminClient = useAdminClient();
|
||||||
const { addAlert, addError } = useAlerts();
|
const { addAlert, addError } = useAlerts();
|
||||||
const { register, errors, handleSubmit } = useForm({
|
const {
|
||||||
|
register,
|
||||||
|
handleSubmit,
|
||||||
|
formState: { errors },
|
||||||
|
} = useForm({
|
||||||
defaultValues: { name: rename },
|
defaultValues: { name: rename },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,11 @@ const Fields = ({ readOnly }: DescriptorSettingsProps) => {
|
||||||
const { t } = useTranslation("identity-providers");
|
const { t } = useTranslation("identity-providers");
|
||||||
const { t: th } = useTranslation("identity-providers-help");
|
const { t: th } = useTranslation("identity-providers-help");
|
||||||
|
|
||||||
const { register, control, errors } = useFormContext();
|
const {
|
||||||
|
register,
|
||||||
|
control,
|
||||||
|
formState: { errors },
|
||||||
|
} = useFormContext();
|
||||||
const [namedPolicyDropdownOpen, setNamedPolicyDropdownOpen] = useState(false);
|
const [namedPolicyDropdownOpen, setNamedPolicyDropdownOpen] = useState(false);
|
||||||
const [principalTypeDropdownOpen, setPrincipalTypeDropdownOpen] =
|
const [principalTypeDropdownOpen, setPrincipalTypeDropdownOpen] =
|
||||||
useState(false);
|
useState(false);
|
||||||
|
|
|
@ -19,7 +19,11 @@ type DiscoverySettingsProps = {
|
||||||
|
|
||||||
const Fields = ({ readOnly }: DiscoverySettingsProps) => {
|
const Fields = ({ readOnly }: DiscoverySettingsProps) => {
|
||||||
const { t } = useTranslation("identity-providers");
|
const { t } = useTranslation("identity-providers");
|
||||||
const { register, control, errors } = useFormContext();
|
const {
|
||||||
|
register,
|
||||||
|
control,
|
||||||
|
formState: { errors },
|
||||||
|
} = useFormContext();
|
||||||
|
|
||||||
const validateSignature = useWatch({
|
const validateSignature = useWatch({
|
||||||
control: control,
|
control: control,
|
||||||
|
|
|
@ -14,7 +14,10 @@ export const OIDCGeneralSettings = ({ id }: { id: string }) => {
|
||||||
const { t } = useTranslation("identity-providers");
|
const { t } = useTranslation("identity-providers");
|
||||||
const { tab } = useParams<IdentityProviderParams>();
|
const { tab } = useParams<IdentityProviderParams>();
|
||||||
|
|
||||||
const { register, errors } = useFormContext();
|
const {
|
||||||
|
register,
|
||||||
|
formState: { errors },
|
||||||
|
} = useFormContext();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
|
@ -17,7 +17,12 @@ export const OpenIdConnectSettings = () => {
|
||||||
|
|
||||||
const adminClient = useAdminClient();
|
const adminClient = useAdminClient();
|
||||||
const { realm } = useRealm();
|
const { realm } = useRealm();
|
||||||
const { setValue, errors, setError, clearErrors } = useFormContext();
|
const {
|
||||||
|
setValue,
|
||||||
|
setError,
|
||||||
|
clearErrors,
|
||||||
|
formState: { errors },
|
||||||
|
} = useFormContext();
|
||||||
|
|
||||||
const setupForm = (result: any) => {
|
const setupForm = (result: any) => {
|
||||||
Object.keys(result).map((k) => setValue(`config.${k}`, result[k]));
|
Object.keys(result).map((k) => setValue(`config.${k}`, result[k]));
|
||||||
|
|
|
@ -20,8 +20,13 @@ export const SamlConnectSettings = () => {
|
||||||
|
|
||||||
const adminClient = useAdminClient();
|
const adminClient = useAdminClient();
|
||||||
const { realm } = useRealm();
|
const { realm } = useRealm();
|
||||||
const { setValue, register, errors, setError, clearErrors } =
|
const {
|
||||||
useFormContext();
|
setValue,
|
||||||
|
register,
|
||||||
|
setError,
|
||||||
|
clearErrors,
|
||||||
|
formState: { errors },
|
||||||
|
} = useFormContext();
|
||||||
|
|
||||||
const setupForm = (result: IdentityProviderRepresentation) => {
|
const setupForm = (result: IdentityProviderRepresentation) => {
|
||||||
Object.entries(result).map(([key, value]) =>
|
Object.entries(result).map(([key, value]) =>
|
||||||
|
|
|
@ -20,7 +20,11 @@ export const SamlGeneralSettings = ({ id }: { id: string }) => {
|
||||||
const { realm } = useRealm();
|
const { realm } = useRealm();
|
||||||
const { tab } = useParams<IdentityProviderParams>();
|
const { tab } = useParams<IdentityProviderParams>();
|
||||||
|
|
||||||
const { register, errors, watch } = useFormContext();
|
const {
|
||||||
|
register,
|
||||||
|
watch,
|
||||||
|
formState: { errors },
|
||||||
|
} = useFormContext();
|
||||||
|
|
||||||
const alias = watch("alias");
|
const alias = watch("alias");
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,10 @@ export const ClientIdSecret = ({
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation("identity-providers");
|
const { t } = useTranslation("identity-providers");
|
||||||
|
|
||||||
const { register, errors } = useFormContext();
|
const {
|
||||||
|
register,
|
||||||
|
formState: { errors },
|
||||||
|
} = useFormContext();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
|
@ -22,8 +22,14 @@ export const DiscoveryEndpointField = ({
|
||||||
|
|
||||||
const adminClient = useAdminClient();
|
const adminClient = useAdminClient();
|
||||||
|
|
||||||
const { setValue, register, errors, setError, watch, clearErrors } =
|
const {
|
||||||
useFormContext();
|
setValue,
|
||||||
|
register,
|
||||||
|
setError,
|
||||||
|
watch,
|
||||||
|
clearErrors,
|
||||||
|
formState: { errors },
|
||||||
|
} = useFormContext();
|
||||||
const discoveryUrl = watch("discoveryEndpoint");
|
const discoveryUrl = watch("discoveryEndpoint");
|
||||||
|
|
||||||
const [discovery, setDiscovery] = useState(true);
|
const [discovery, setDiscovery] = useState(true);
|
||||||
|
|
|
@ -30,7 +30,11 @@ export const AddMessageBundleModal = ({
|
||||||
save,
|
save,
|
||||||
}: AddMessageBundleModalProps) => {
|
}: AddMessageBundleModalProps) => {
|
||||||
const { t } = useTranslation("realm-settings");
|
const { t } = useTranslation("realm-settings");
|
||||||
const { register, errors, handleSubmit } = useForm();
|
const {
|
||||||
|
register,
|
||||||
|
handleSubmit,
|
||||||
|
formState: { errors },
|
||||||
|
} = useForm();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
|
|
|
@ -30,7 +30,12 @@ export const AddUserEmailModal = ({ callback }: AddUserEmailModalProps) => {
|
||||||
const { t } = useTranslation("groups");
|
const { t } = useTranslation("groups");
|
||||||
const adminClient = useAdminClient();
|
const adminClient = useAdminClient();
|
||||||
const { whoAmI } = useWhoAmI();
|
const { whoAmI } = useWhoAmI();
|
||||||
const { register, errors, handleSubmit, watch } = useForm<AddUserEmailForm>({
|
const {
|
||||||
|
register,
|
||||||
|
handleSubmit,
|
||||||
|
watch,
|
||||||
|
formState: { errors },
|
||||||
|
} = useForm<AddUserEmailForm>({
|
||||||
defaultValues: { email: "" },
|
defaultValues: { email: "" },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -54,8 +54,7 @@ export default function ClientProfileForm() {
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
setValue,
|
setValue,
|
||||||
register,
|
register,
|
||||||
errors,
|
formState: { isDirty, errors },
|
||||||
formState: { isDirty },
|
|
||||||
} = useForm<ClientProfileForm>({
|
} = useForm<ClientProfileForm>({
|
||||||
defaultValues,
|
defaultValues,
|
||||||
mode: "onChange",
|
mode: "onChange",
|
||||||
|
|
|
@ -44,10 +44,10 @@ export const RealmSettingsEmailTab = ({
|
||||||
register,
|
register,
|
||||||
control,
|
control,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
errors,
|
|
||||||
watch,
|
watch,
|
||||||
reset: resetForm,
|
reset: resetForm,
|
||||||
getValues,
|
getValues,
|
||||||
|
formState: { errors },
|
||||||
} = useForm<RealmRepresentation>({ defaultValues: realm });
|
} = useForm<RealmRepresentation>({ defaultValues: realm });
|
||||||
|
|
||||||
const reset = () => resetForm(realm);
|
const reset = () => resetForm(realm);
|
||||||
|
|
|
@ -65,7 +65,10 @@ type PolicyDetailAttributes = {
|
||||||
|
|
||||||
export default function NewClientPolicyForm() {
|
export default function NewClientPolicyForm() {
|
||||||
const { t } = useTranslation("realm-settings");
|
const { t } = useTranslation("realm-settings");
|
||||||
const { errors, reset: resetForm } = useForm<NewClientPolicyForm>({
|
const {
|
||||||
|
reset: resetForm,
|
||||||
|
formState: { errors },
|
||||||
|
} = useForm<NewClientPolicyForm>({
|
||||||
defaultValues,
|
defaultValues,
|
||||||
});
|
});
|
||||||
const { realm } = useRealm();
|
const { realm } = useRealm();
|
||||||
|
|
|
@ -14,7 +14,10 @@ export const Time = ({
|
||||||
style?: CSSProperties;
|
style?: CSSProperties;
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useTranslation("realm-settings");
|
const { t } = useTranslation("realm-settings");
|
||||||
const { control, errors } = useFormContext();
|
const {
|
||||||
|
control,
|
||||||
|
formState: { errors },
|
||||||
|
} = useFormContext();
|
||||||
return (
|
return (
|
||||||
<FormGroup
|
<FormGroup
|
||||||
style={style}
|
style={style}
|
||||||
|
|
|
@ -29,8 +29,13 @@ export default function NewRealmForm() {
|
||||||
const adminClient = useAdminClient();
|
const adminClient = useAdminClient();
|
||||||
const { addAlert, addError } = useAlerts();
|
const { addAlert, addError } = useAlerts();
|
||||||
|
|
||||||
const { register, handleSubmit, control, errors, setValue } =
|
const {
|
||||||
useForm<RealmRepresentation>({ mode: "onChange" });
|
register,
|
||||||
|
handleSubmit,
|
||||||
|
control,
|
||||||
|
setValue,
|
||||||
|
formState: { errors },
|
||||||
|
} = useForm<RealmRepresentation>({ mode: "onChange" });
|
||||||
|
|
||||||
const handleFileChange = (obj: object) => {
|
const handleFileChange = (obj: object) => {
|
||||||
const defaultRealm = { id: "", realm: "", enabled: true };
|
const defaultRealm = { id: "", realm: "", enabled: true };
|
||||||
|
|
|
@ -37,7 +37,11 @@ export const RevocationModal = ({
|
||||||
|
|
||||||
const { realm: realmName } = useRealm();
|
const { realm: realmName } = useRealm();
|
||||||
const adminClient = useAdminClient();
|
const adminClient = useAdminClient();
|
||||||
const { register, errors, handleSubmit } = useForm();
|
const {
|
||||||
|
register,
|
||||||
|
handleSubmit,
|
||||||
|
formState: { errors },
|
||||||
|
} = useForm();
|
||||||
const [realm, setRealm] = useState<RealmRepresentation>();
|
const [realm, setRealm] = useState<RealmRepresentation>();
|
||||||
|
|
||||||
const [key, setKey] = useState(0);
|
const [key, setKey] = useState(0);
|
||||||
|
|
|
@ -60,8 +60,14 @@ export const UserForm = ({
|
||||||
const adminClient = useAdminClient();
|
const adminClient = useAdminClient();
|
||||||
const { addAlert, addError } = useAlerts();
|
const { addAlert, addError } = useAlerts();
|
||||||
|
|
||||||
const { handleSubmit, register, errors, watch, control, reset } =
|
const {
|
||||||
useFormContext();
|
handleSubmit,
|
||||||
|
register,
|
||||||
|
watch,
|
||||||
|
control,
|
||||||
|
reset,
|
||||||
|
formState: { errors },
|
||||||
|
} = useFormContext();
|
||||||
const watchUsernameInput = watch("username");
|
const watchUsernameInput = watch("username");
|
||||||
const [selectedGroups, setSelectedGroups] = useState<GroupRepresentation[]>(
|
const [selectedGroups, setSelectedGroups] = useState<GroupRepresentation[]>(
|
||||||
[]
|
[]
|
||||||
|
|
|
@ -35,7 +35,11 @@ export const UserIdpModal = ({
|
||||||
const { t } = useTranslation("users");
|
const { t } = useTranslation("users");
|
||||||
const adminClient = useAdminClient();
|
const adminClient = useAdminClient();
|
||||||
const { addAlert, addError } = useAlerts();
|
const { addAlert, addError } = useAlerts();
|
||||||
const { register, errors, handleSubmit, formState } = useForm({
|
const {
|
||||||
|
register,
|
||||||
|
handleSubmit,
|
||||||
|
formState: { isValid, errors },
|
||||||
|
} = useForm({
|
||||||
mode: "onChange",
|
mode: "onChange",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -71,7 +75,7 @@ export const UserIdpModal = ({
|
||||||
variant="primary"
|
variant="primary"
|
||||||
type="submit"
|
type="submit"
|
||||||
form="group-form"
|
form="group-form"
|
||||||
isDisabled={!formState.isValid}
|
isDisabled={!isValid}
|
||||||
>
|
>
|
||||||
{t("link")}
|
{t("link")}
|
||||||
</Button>,
|
</Button>,
|
||||||
|
|
|
@ -50,8 +50,7 @@ export const ResetPasswordDialog = ({
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
control,
|
control,
|
||||||
errors,
|
formState: { isValid, errors },
|
||||||
formState: { isValid },
|
|
||||||
watch,
|
watch,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
} = useForm<CredentialsForm>({
|
} = useForm<CredentialsForm>({
|
||||||
|
|
Loading…
Reference in a new issue