Skip to content

Commit

Permalink
get db datas
Browse files Browse the repository at this point in the history
add id in dto
  • Loading branch information
rebeccadumazert committed Jan 8, 2024
1 parent 3829dd0 commit b5433c7
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 52 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
77 changes: 28 additions & 49 deletions front/src/providers/connectedSpaces/Dashboard.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<div className="fr-container fr-mb-10v">
<Title1>Tableau de bord</Title1>
<div className="fr-grid-row fr-grid-row--gutters">
<div className="container fr-col-6">
<Card
background
border
desc="Description text MD"
horizontal
enlargeLink
linkProps={{
to: '#',
}}
size="small"
start={
<ul className="fr-badges-group">
<li>
<Badge>Clés de test</Badge>
<Badge severity="info">DINUM</Badge>
</li>
</ul>
}
title="Test"
titleAs="h2"
/>
</div>

{/* CARTE 2 !! */}

<div className="container fr-col-6">
<Card
background
border
desc="Description text MD"
horizontal
enlargeLink
linkProps={{
to: '#',
}}
size="small"
start={
<ul className="fr-badges-group">
<li>
<Badge>Clés de test</Badge>
<Badge severity="info">ANCT</Badge>
</li>
</ul>
}
title="Test"
titleAs="h2"
/>
</div>
{/* ERREUR DE TYPAGE A CORRIGER */}
{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>
);
Expand Down
7 changes: 5 additions & 2 deletions front/src/routes/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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([
{
Expand Down Expand Up @@ -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: (
<PageLayout>
<Dashboard></Dashboard>
<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 b5433c7

Please sign in to comment.