Skip to content

Commit

Permalink
create dashboard component (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
rebeccadumazert authored Jan 10, 2024
1 parent 6b11ebf commit 752cd2f
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 7 deletions.
4 changes: 3 additions & 1 deletion back/src/oidc-client/oidc-client.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class OidcClientController {
async findAll() {
return [
{
id: 123,
clientDescription: 'Description',
clientId: 'clientId',
clientSecret: 'ClientSecret',
Expand All @@ -34,6 +35,7 @@ export class OidcClientController {
@Get('/:id')
async find_by_id(@Param('id') id: string) {
return {
id: 123,
clientDescription: 'Description',
clientId: 'clientId',
clientSecret: 'ClientSecret',
Expand All @@ -57,7 +59,7 @@ export class OidcClientController {
HttpStatus.BAD_REQUEST,
{
cause: error,
}
},
);
}
}
Expand Down
3 changes: 3 additions & 0 deletions back/src/oidc-client/oidc-client.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { IsNotEmpty } from 'class-validator';
export class CreateOidcClientDto {
clientDescription: string | null;

@IsNotEmpty()
id: number;

@IsNotEmpty()
clientName: string;

Expand Down
41 changes: 41 additions & 0 deletions front/src/providers/connectedSpaces/Dashboard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Badge } from '@codegouvfr/react-dsfr/Badge';
import Title1 from '../../titles/Title1';
import { Card } from '@codegouvfr/react-dsfr/Card';
import { useRouteLoaderData } from 'react-router-dom';
import { OidcClients } from '../../types';

export const Dashboard = () => {
const oidcClients = useRouteLoaderData('dashboard') as OidcClients;
return (
<div className="fr-container fr-mb-10v">
<Title1>Tableau de bord</Title1>
<div className="fr-grid-row fr-grid-row--gutters">
{oidcClients.map((oidcClient) => (
<div className="container fr-col-6">
<Card
background
border
desc={oidcClient.clientDescription}
horizontal
enlargeLink
linkProps={{
to: `/dashboard/${oidcClient.id}`,
}}
size="small"
start={
<ul className="fr-badges-group">
<li>
<Badge>Clés de test</Badge>
<Badge severity="info">DINUM</Badge>
</li>
</ul>
}
title={oidcClient.clientName}
titleAs="h2"
/>
</div>
))}
</div>
</div>
);
};
1 change: 1 addition & 0 deletions front/src/providers/details/ProviderDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { OidcClientFormContext } from './oidc-client-form.context';

export function ProviderDetails() {
const [oidcClientForm, setOidcClientForm] = useState<OidcClient>({
id: 0,
clientName: '',
clientDescription: '',
clientId: '',
Expand Down
12 changes: 6 additions & 6 deletions front/src/routes/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { EspaceConnected } from '../providers/connectedSpaces/EspaceConnected';
import { ProviderDetails } from '../providers/details/ProviderDetails';
import { OidcClientFormProvider } from '../providers/details/oidc-client-form.context';
import { EspaceDocumentation } from '../providers/documentation/EspaceDocumentation';
import { Dashboard } from '../providers/connectedSpaces/Dashboard';
import { OidcClients } from '../types';

const router = createBrowserRouter([
{
Expand Down Expand Up @@ -39,15 +41,13 @@ const router = createBrowserRouter([
{
path: '/dashboard',
loader: async () => {
return backendClient.getDashboard();
const datas: OidcClients = await backendClient.getDashboard();
return datas;
},
id: 'dashboard',
element: (
<PageLayout>
<>
<a href="/dashboard/new">NEW</a>
<br />
<a href="/dashboard/123">Rebecca Project 123</a>
</>
<Dashboard />
</PageLayout>
),
},
Expand Down
3 changes: 3 additions & 0 deletions front/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export type OidcClient = {
id: number;
clientName: string;
clientDescription: string;
clientId: string;
Expand All @@ -7,3 +8,5 @@ export type OidcClient = {
postLogoutRedirectUris: string[];
scope: string[];
};

export type OidcClients = OidcClient[];

0 comments on commit 752cd2f

Please sign in to comment.