parent
0bae359058
commit
d8ff73e34f
2 changed files with 18 additions and 4 deletions
|
@ -19,6 +19,8 @@ import { UserFormFields, toUserRepresentation } from "./form-state";
|
|||
import { toUser } from "./routes/User";
|
||||
|
||||
import "./user-section.css";
|
||||
import RealmRepresentation from "@keycloak/keycloak-admin-client/lib/defs/realmRepresentation";
|
||||
import { useFetch } from "../utils/useFetch";
|
||||
|
||||
export default function CreateUser() {
|
||||
const { t } = useTranslation();
|
||||
|
@ -28,6 +30,15 @@ export default function CreateUser() {
|
|||
const userForm = useForm<UserFormFields>({ mode: "onChange" });
|
||||
const [addedGroups, setAddedGroups] = useState<GroupRepresentation[]>([]);
|
||||
|
||||
const [realmRepresentation, setRealmRepresentation] =
|
||||
useState<RealmRepresentation>();
|
||||
|
||||
useFetch(
|
||||
() => adminClient.realms.findOne({ realm }),
|
||||
(result) => setRealmRepresentation(result),
|
||||
[],
|
||||
);
|
||||
|
||||
const save = async (data: UserFormFields) => {
|
||||
try {
|
||||
const createdUser = await adminClient.users.create({
|
||||
|
@ -57,7 +68,11 @@ export default function CreateUser() {
|
|||
<UserProfileProvider>
|
||||
<FormProvider {...userForm}>
|
||||
<PageSection variant="light">
|
||||
<UserForm onGroupsUpdate={setAddedGroups} save={save} />
|
||||
<UserForm
|
||||
realm={realmRepresentation}
|
||||
onGroupsUpdate={setAddedGroups}
|
||||
save={save}
|
||||
/>
|
||||
</PageSection>
|
||||
</FormProvider>
|
||||
</UserProfileProvider>
|
||||
|
|
|
@ -182,7 +182,6 @@ export const UserForm = ({
|
|||
filterGroups={selectedGroups}
|
||||
/>
|
||||
)}
|
||||
{isUserProfileEnabled && <EmailVerified />}
|
||||
{user?.id && (
|
||||
<>
|
||||
<FormGroup label={t("id")} fieldId="kc-id" isRequired>
|
||||
|
@ -224,8 +223,8 @@ export const UserForm = ({
|
|||
<FederatedUserLink user={user} />
|
||||
</FormGroup>
|
||||
)}
|
||||
{isUserProfileEnabled ? (
|
||||
<UserProfileFields config={user?.userProfileMetadata!} />
|
||||
{isUserProfileEnabled && user?.userProfileMetadata ? (
|
||||
<UserProfileFields config={user.userProfileMetadata} />
|
||||
) : (
|
||||
<>
|
||||
{!realm?.registrationEmailAsUsername && (
|
||||
|
|
Loading…
Reference in a new issue