2022-12-07 14:23:12 +00:00
|
|
|
import type RealmRepresentation from "@keycloak/keycloak-admin-client/lib/defs/realmRepresentation";
|
2022-08-03 12:12:07 +00:00
|
|
|
import { useState } from "react";
|
2021-11-16 11:10:10 +00:00
|
|
|
|
2023-05-03 13:51:02 +00:00
|
|
|
import { adminClient } from "../admin-client";
|
2021-11-16 11:10:10 +00:00
|
|
|
import { KeycloakSpinner } from "../components/keycloak-spinner/KeycloakSpinner";
|
2023-05-03 13:51:02 +00:00
|
|
|
import { useFetch } from "../context/auth/AdminClient";
|
2022-12-07 14:23:12 +00:00
|
|
|
import { useParams } from "../utils/useParams";
|
2021-09-02 20:14:43 +00:00
|
|
|
import { RealmSettingsTabs } from "./RealmSettingsTabs";
|
2022-12-07 14:23:12 +00:00
|
|
|
import type { RealmSettingsParams } from "./routes/RealmSettings";
|
2021-10-21 18:40:02 +00:00
|
|
|
|
2021-10-29 16:11:06 +00:00
|
|
|
export default function RealmSettingsSection() {
|
2022-06-15 12:57:39 +00:00
|
|
|
const { realm: realmName } = useParams<RealmSettingsParams>();
|
2021-04-30 19:08:12 +00:00
|
|
|
const [realm, setRealm] = useState<RealmRepresentation>();
|
2021-09-27 17:15:36 +00:00
|
|
|
const [key, setKey] = useState(0);
|
|
|
|
|
|
|
|
const refresh = () => {
|
|
|
|
setKey(key + 1);
|
2022-06-15 12:57:39 +00:00
|
|
|
setRealm(undefined);
|
2021-09-27 17:15:36 +00:00
|
|
|
};
|
|
|
|
|
2022-02-28 15:22:00 +00:00
|
|
|
useFetch(() => adminClient.realms.findOne({ realm: realmName }), setRealm, [
|
|
|
|
key,
|
|
|
|
]);
|
2021-01-13 19:59:45 +00:00
|
|
|
|
2022-02-28 15:22:00 +00:00
|
|
|
if (!realm) {
|
2021-11-16 11:10:10 +00:00
|
|
|
return <KeycloakSpinner />;
|
2021-08-23 19:00:42 +00:00
|
|
|
}
|
2022-02-28 15:22:00 +00:00
|
|
|
return <RealmSettingsTabs realm={realm} refresh={refresh} />;
|
2021-10-29 16:11:06 +00:00
|
|
|
}
|