From 3829dd0093c198342d650fa773a27320077107c1 Mon Sep 17 00:00:00 2001 From: rebeccadumazert Date: Mon, 8 Jan 2024 16:17:57 +0100 Subject: [PATCH 1/4] create dashboard component --- .../providers/connectedSpaces/Dashboard.tsx | 62 +++++++++++++++++++ front/src/routes/Router.tsx | 7 +-- 2 files changed, 64 insertions(+), 5 deletions(-) create mode 100644 front/src/providers/connectedSpaces/Dashboard.tsx diff --git a/front/src/providers/connectedSpaces/Dashboard.tsx b/front/src/providers/connectedSpaces/Dashboard.tsx new file mode 100644 index 0000000..b4bfb18 --- /dev/null +++ b/front/src/providers/connectedSpaces/Dashboard.tsx @@ -0,0 +1,62 @@ +import { Badge } from '@codegouvfr/react-dsfr/Badge'; +import Title1 from '../../titles/Title1'; +import { Card } from '@codegouvfr/react-dsfr/Card'; + +export const Dashboard = () => { + return ( +
+ Tableau de bord +
+
+ +
  • + Clés de test + DINUM +
  • + + } + title="Test" + titleAs="h2" + /> +
    + + {/* CARTE 2 !! */} + +
    + +
  • + Clés de test + ANCT +
  • + + } + title="Test" + titleAs="h2" + /> +
    +
    +
    + ); +}; diff --git a/front/src/routes/Router.tsx b/front/src/routes/Router.tsx index a3d5c5b..f0c156f 100644 --- a/front/src/routes/Router.tsx +++ b/front/src/routes/Router.tsx @@ -10,6 +10,7 @@ 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'; const router = createBrowserRouter([ { @@ -43,11 +44,7 @@ const router = createBrowserRouter([ }, element: ( - <> - NEW -
    - Rebecca Project 123 - +
    ), }, From b5433c7bacbf410b1116a8c077854fd6958bb7eb Mon Sep 17 00:00:00 2001 From: rebeccadumazert Date: Mon, 8 Jan 2024 18:00:58 +0100 Subject: [PATCH 2/4] get db datas add id in dto --- .../src/oidc-client/oidc-client.controller.ts | 4 +- back/src/oidc-client/oidc-client.dto.ts | 3 + .../providers/connectedSpaces/Dashboard.tsx | 77 +++++++------------ front/src/routes/Router.tsx | 7 +- front/src/types.ts | 3 + 5 files changed, 42 insertions(+), 52 deletions(-) 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 index b4bfb18..ac3abac 100644 --- a/front/src/providers/connectedSpaces/Dashboard.tsx +++ b/front/src/providers/connectedSpaces/Dashboard.tsx @@ -1,61 +1,40 @@ 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'; export const Dashboard = () => { + const oidcClients = useRouteLoaderData('dashboard'); return (
    Tableau de bord
    -
    - -
  • - Clés de test - DINUM -
  • - - } - title="Test" - titleAs="h2" - /> -
    - - {/* CARTE 2 !! */} - -
    - -
  • - Clés de test - ANCT -
  • - - } - title="Test" - titleAs="h2" - /> -
    + {/* ERREUR DE TYPAGE A CORRIGER */} + {oidcClients.map((oidcClient) => ( +
    + +
  • + Clés de test + DINUM +
  • + + } + title={oidcClient.clientName} + titleAs="h2" + /> +
    + ))}
    ); diff --git a/front/src/routes/Router.tsx b/front/src/routes/Router.tsx index f0c156f..acc9c61 100644 --- a/front/src/routes/Router.tsx +++ b/front/src/routes/Router.tsx @@ -11,6 +11,7 @@ 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 { OidcClient } from '../types'; const router = createBrowserRouter([ { @@ -40,11 +41,13 @@ const router = createBrowserRouter([ { path: '/dashboard', loader: async () => { - return backendClient.getDashboard(); + const datas: OidcClient = await backendClient.getDashboard(); + return datas; }, + id: 'dashboard', element: ( - + ), }, 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[]; From b66b662b232f31129233abd229ffd9d37c868325 Mon Sep 17 00:00:00 2001 From: rebeccadumazert Date: Mon, 8 Jan 2024 18:51:16 +0100 Subject: [PATCH 3/4] correct CI --- front/src/providers/details/ProviderDetails.tsx | 1 + 1 file changed, 1 insertion(+) 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: '', From 27eb8c5d89573ec9a8e8d3e99929bd9a7c544817 Mon Sep 17 00:00:00 2001 From: rebeccadumazert Date: Wed, 10 Jan 2024 14:32:59 +0100 Subject: [PATCH 4/4] fix TS error --- front/src/providers/connectedSpaces/Dashboard.tsx | 4 ++-- front/src/routes/Router.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/front/src/providers/connectedSpaces/Dashboard.tsx b/front/src/providers/connectedSpaces/Dashboard.tsx index ac3abac..c39798f 100644 --- a/front/src/providers/connectedSpaces/Dashboard.tsx +++ b/front/src/providers/connectedSpaces/Dashboard.tsx @@ -2,14 +2,14 @@ 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'); + const oidcClients = useRouteLoaderData('dashboard') as OidcClients; return (
    Tableau de bord
    - {/* ERREUR DE TYPAGE A CORRIGER */} {oidcClients.map((oidcClient) => (
    { - const datas: OidcClient = await backendClient.getDashboard(); + const datas: OidcClients = await backendClient.getDashboard(); return datas; }, id: 'dashboard',