From 752cd2f6c6beb12f64bb1c28a338c4888738e94d Mon Sep 17 00:00:00 2001 From: Rebecca Dumazert <44778533+rebeccadumazert@users.noreply.github.com> Date: Wed, 10 Jan 2024 14:54:47 +0100 Subject: [PATCH] create dashboard component (#48) --- .../src/oidc-client/oidc-client.controller.ts | 4 +- back/src/oidc-client/oidc-client.dto.ts | 3 ++ .../providers/connectedSpaces/Dashboard.tsx | 41 +++++++++++++++++++ .../src/providers/details/ProviderDetails.tsx | 1 + front/src/routes/Router.tsx | 12 +++--- front/src/types.ts | 3 ++ 6 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 front/src/providers/connectedSpaces/Dashboard.tsx diff --git a/back/src/oidc-client/oidc-client.controller.ts b/back/src/oidc-client/oidc-client.controller.ts index 9d4b3b8..dee1e70 100644 --- a/back/src/oidc-client/oidc-client.controller.ts +++ b/back/src/oidc-client/oidc-client.controller.ts @@ -20,6 +20,7 @@ export class OidcClientController { async findAll() { return [ { + id: 123, clientDescription: 'Description', clientId: 'clientId', clientSecret: 'ClientSecret', @@ -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', @@ -57,7 +59,7 @@ export class OidcClientController { HttpStatus.BAD_REQUEST, { cause: error, - } + }, ); } } diff --git a/back/src/oidc-client/oidc-client.dto.ts b/back/src/oidc-client/oidc-client.dto.ts index 2912918..cf353dd 100644 --- a/back/src/oidc-client/oidc-client.dto.ts +++ b/back/src/oidc-client/oidc-client.dto.ts @@ -3,6 +3,9 @@ import { IsNotEmpty } from 'class-validator'; export class CreateOidcClientDto { clientDescription: string | null; + @IsNotEmpty() + id: number; + @IsNotEmpty() clientName: string; diff --git a/front/src/providers/connectedSpaces/Dashboard.tsx b/front/src/providers/connectedSpaces/Dashboard.tsx new file mode 100644 index 0000000..c39798f --- /dev/null +++ b/front/src/providers/connectedSpaces/Dashboard.tsx @@ -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 ( +
+ Tableau de bord +
+ {oidcClients.map((oidcClient) => ( +
+ +
  • + Clés de test + DINUM +
  • + + } + title={oidcClient.clientName} + titleAs="h2" + /> +
    + ))} +
    +
    + ); +}; diff --git a/front/src/providers/details/ProviderDetails.tsx b/front/src/providers/details/ProviderDetails.tsx index aa99e0f..3378a2d 100644 --- a/front/src/providers/details/ProviderDetails.tsx +++ b/front/src/providers/details/ProviderDetails.tsx @@ -16,6 +16,7 @@ import { OidcClientFormContext } from './oidc-client-form.context'; export function ProviderDetails() { const [oidcClientForm, setOidcClientForm] = useState({ + id: 0, clientName: '', clientDescription: '', clientId: '', diff --git a/front/src/routes/Router.tsx b/front/src/routes/Router.tsx index a3d5c5b..4360c10 100644 --- a/front/src/routes/Router.tsx +++ b/front/src/routes/Router.tsx @@ -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([ { @@ -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: ( - <> - NEW -
    - Rebecca Project 123 - +
    ), }, diff --git a/front/src/types.ts b/front/src/types.ts index 3bb496f..dea509d 100644 --- a/front/src/types.ts +++ b/front/src/types.ts @@ -1,4 +1,5 @@ export type OidcClient = { + id: number; clientName: string; clientDescription: string; clientId: string; @@ -7,3 +8,5 @@ export type OidcClient = { postLogoutRedirectUris: string[]; scope: string[]; }; + +export type OidcClients = OidcClient[];