2020-08-04 12:59:41 +00:00
|
|
|
import React, { useContext } from 'react';
|
|
|
|
|
|
|
|
import { ClientList } from './clients/ClientList';
|
|
|
|
import { DataLoader } from './components/data-loader/DataLoader';
|
|
|
|
import { HttpClientContext } from './http-service/HttpClientContext';
|
|
|
|
import { Client } from './clients/client-model';
|
2020-08-08 13:52:23 +00:00
|
|
|
import { Page, PageSection } from '@patternfly/react-core';
|
2020-08-04 12:59:41 +00:00
|
|
|
import { Header } from './PageHeader';
|
|
|
|
import { PageNav } from './PageNav';
|
|
|
|
|
2020-08-08 13:52:23 +00:00
|
|
|
export const App = () => {
|
2020-08-04 12:59:41 +00:00
|
|
|
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>
|
|
|
|
<DataLoader loader={loader}>
|
|
|
|
{(clients) => <ClientList clients={clients} />}
|
|
|
|
</DataLoader>
|
|
|
|
</PageSection>
|
2020-08-04 12:59:41 +00:00
|
|
|
</Page>
|
|
|
|
);
|
|
|
|
};
|