parent
4326a46dd0
commit
a2bdfab9c5
1 changed files with 5 additions and 7 deletions
|
@ -1,7 +1,4 @@
|
||||||
import type {
|
import type { UserProfileAttribute } from "@keycloak/keycloak-admin-client/lib/defs/userProfileConfig";
|
||||||
UserProfileAttribute,
|
|
||||||
UserProfileAttributeRequired,
|
|
||||||
} from "@keycloak/keycloak-admin-client/lib/defs/userProfileConfig";
|
|
||||||
import {
|
import {
|
||||||
Form,
|
Form,
|
||||||
FormGroup,
|
FormGroup,
|
||||||
|
@ -92,8 +89,9 @@ const FormField = ({ attribute, roles }: FormFieldProps) => {
|
||||||
const isRootAttribute = (attr?: string) =>
|
const isRootAttribute = (attr?: string) =>
|
||||||
attr && ROOT_ATTRIBUTES.includes(attr);
|
attr && ROOT_ATTRIBUTES.includes(attr);
|
||||||
|
|
||||||
const isRequired = (required: UserProfileAttributeRequired | undefined) =>
|
const isRequired = (attribute: UserProfileAttribute) =>
|
||||||
Object.keys(required || {}).length !== 0;
|
Object.keys(attribute.required || {}).length !== 0 ||
|
||||||
|
((attribute.validations?.length?.min as number) || 0) > 0;
|
||||||
|
|
||||||
const fieldName = (attribute: UserProfileAttribute) =>
|
const fieldName = (attribute: UserProfileAttribute) =>
|
||||||
`${isRootAttribute(attribute.name) ? "" : "attributes."}${attribute.name}`;
|
`${isRootAttribute(attribute.name) ? "" : "attributes."}${attribute.name}`;
|
||||||
|
@ -107,7 +105,7 @@ const FormField = ({ attribute, roles }: FormFieldProps) => {
|
||||||
: attribute.displayName) || attribute.name
|
: attribute.displayName) || attribute.name
|
||||||
}
|
}
|
||||||
fieldId={attribute.name}
|
fieldId={attribute.name}
|
||||||
isRequired={isRequired(attribute.required)}
|
isRequired={isRequired(attribute)}
|
||||||
validated={errors.username ? "error" : "default"}
|
validated={errors.username ? "error" : "default"}
|
||||||
helperTextInvalid={t("common:required")}
|
helperTextInvalid={t("common:required")}
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in a new issue