keycloak-scim/src/App.tsx

45 lines
1.3 KiB
TypeScript
Raw Normal View History

import React, { useContext } from 'react';
2020-08-07 13:44:34 +00:00
import {
Page,
PageSection,
Button,
AlertVariant,
} from '@patternfly/react-core';
import { ClientList } from './clients/ClientList';
import { DataLoader } from './components/data-loader/DataLoader';
import { HttpClientContext } from './http-service/HttpClientContext';
import { Client } from './clients/client-model';
import { Header } from './PageHeader';
import { PageNav } from './PageNav';
2020-08-07 13:44:34 +00:00
import { AlertPanel } from './components/alert/AlertPanel';
import { useAlerts, withAlerts } from './components/alert/Alerts';
2020-08-07 13:44:34 +00:00
const AppComponent = () => {
const [alerts, add, hide] = useAlerts();
const httpClient = useContext(HttpClientContext);
const loader = async () => {
return await httpClient
?.doGet('/realms/master/clients?first=0&max=20&search=true')
.then((r) => r.data as Client[]);
};
return (
<Page header={<Header />} sidebar={<PageNav />}>
2020-08-06 09:43:33 +00:00
<PageSection>
2020-08-07 13:44:34 +00:00
<AlertPanel alerts={alerts} onCloseAlert={hide} />
2020-08-06 09:43:33 +00:00
<DataLoader loader={loader}>
{(clients) => <ClientList clients={clients} />}
</DataLoader>
2020-08-07 13:44:34 +00:00
<Button
onClick={() => add('Crazy stuff happened', AlertVariant.danger)}
>
Click
</Button>
2020-08-06 09:43:33 +00:00
</PageSection>
</Page>
);
};
2020-08-07 13:44:34 +00:00
export const App = withAlerts(AppComponent);