mirror of
https://github.com/inventree/InvenTree.git
synced 2026-02-05 21:05:51 +00:00
refactor(frontend): load server and auth info in paralell (#11245)
This commit is contained in:
@@ -37,27 +37,29 @@ export const useServerApiState = create<ServerApiStateProps>()(
|
||||
server: emptyServerAPI,
|
||||
setServer: (newServer: ServerAPIProps) => set({ server: newServer }),
|
||||
fetchServerApiState: async () => {
|
||||
// Fetch server data
|
||||
await api
|
||||
.get(apiUrl(ApiEndpoints.api_server_info))
|
||||
.then((response) => {
|
||||
set({ server: response.data });
|
||||
})
|
||||
.catch(() => {
|
||||
console.error('ERR: Error fetching server info');
|
||||
});
|
||||
await Promise.all([
|
||||
// Fetch server data
|
||||
api
|
||||
.get(apiUrl(ApiEndpoints.api_server_info))
|
||||
.then((response) => {
|
||||
set({ server: response.data });
|
||||
})
|
||||
.catch(() => {
|
||||
console.error('ERR: Error fetching server info');
|
||||
}),
|
||||
|
||||
// Fetch login/SSO behaviour
|
||||
await api
|
||||
.get(apiUrl(ApiEndpoints.auth_config), {
|
||||
headers: { Authorization: '' }
|
||||
})
|
||||
.then((response) => {
|
||||
set({ auth_config: response.data.data });
|
||||
})
|
||||
.catch(() => {
|
||||
console.error('ERR: Error fetching SSO information');
|
||||
});
|
||||
// Fetch login/SSO behaviour
|
||||
api
|
||||
.get(apiUrl(ApiEndpoints.auth_config), {
|
||||
headers: { Authorization: '' }
|
||||
})
|
||||
.then((response) => {
|
||||
set({ auth_config: response.data.data });
|
||||
})
|
||||
.catch(() => {
|
||||
console.error('ERR: Error fetching SSO information');
|
||||
})
|
||||
]);
|
||||
},
|
||||
auth_config: undefined,
|
||||
auth_context: undefined,
|
||||
|
||||
Reference in New Issue
Block a user