Load server info before rendering rest of application (#27783)
Signed-off-by: Jon Koops <jonkoops@gmail.com>
This commit is contained in:
parent
f168b8cce9
commit
7b755e02d3
1 changed files with 6 additions and 1 deletions
|
@ -3,6 +3,7 @@ import { PropsWithChildren, useState } from "react";
|
|||
import { createNamedContext, useRequiredContext } from "ui-shared";
|
||||
|
||||
import { adminClient } from "../../admin-client";
|
||||
import { KeycloakSpinner } from "../../components/keycloak-spinner/KeycloakSpinner";
|
||||
import { sortProviders } from "../../util";
|
||||
import { useFetch } from "../../utils/useFetch";
|
||||
|
||||
|
@ -16,10 +17,14 @@ export const useLoginProviders = () =>
|
|||
sortProviders(useServerInfo().providers!["login-protocol"].providers);
|
||||
|
||||
export const ServerInfoProvider = ({ children }: PropsWithChildren) => {
|
||||
const [serverInfo, setServerInfo] = useState<ServerInfoRepresentation>({});
|
||||
const [serverInfo, setServerInfo] = useState<ServerInfoRepresentation>();
|
||||
|
||||
useFetch(adminClient.serverInfo.find, setServerInfo, []);
|
||||
|
||||
if (!serverInfo) {
|
||||
return <KeycloakSpinner />;
|
||||
}
|
||||
|
||||
return (
|
||||
<ServerInfoContext.Provider value={serverInfo}>
|
||||
{children}
|
||||
|
|
Loading…
Reference in a new issue