-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Ajout du lien vers la liste des dépôts en cours des GF (#1692)
* ♻️ Better split in permissions gf * 🎨 Add menu link for depot in progress in SSR * 🎨 Conditionnal display link to legacy pages or new page based on feature flag * 🎨 Conditionnal link on legacy app * 🚩 Update name of gf feature flag * Change permission legacy * Update packages/libraries/routes/src/garanties-financières/garantiesFinancières.routes.ts Co-authored-by: HanaeY <[email protected]> * 🔥 Remove feature flags from .envs * 🎨 Add @potentiel-applications/feature-flags and use it in legacy / ssr * 📦️ Update lock * 🐛 Fix bad package name --------- Co-authored-by: HanaeY <[email protected]>
- Loading branch information
Showing
23 changed files
with
436 additions
and
546 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "@potentiel-applications/feature-flags", | ||
"version": "0.0.0", | ||
"description": "Feature flag system", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"private": true, | ||
"scripts": { | ||
"build": "tsc" | ||
}, | ||
"devDependencies": { | ||
"@potentiel-config/tsconfig": "*" | ||
}, | ||
"dependencies": { | ||
"@aws-sdk/client-s3": "^3.405.0", | ||
"@aws-sdk/lib-storage": "^3.405.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
type FeatureFlags = { | ||
SHOW_GARANTIES_FINANCIERES?: true; | ||
}; | ||
|
||
export const featureFlags: FeatureFlags = { | ||
SHOW_GARANTIES_FINANCIERES: true, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "@potentiel-config/tsconfig/tsconfig.base.json", | ||
"compilerOptions": { | ||
"outDir": "dist", | ||
"rootDir": "src" | ||
}, | ||
"references": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
packages/applications/ssr/src/app/garanties-financieres/depots-en-cours/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import { mediator } from 'mediateur'; | ||
import type { Metadata } from 'next'; | ||
import { notFound } from 'next/navigation'; | ||
|
||
import { ListerAppelOffreQuery } from '@potentiel-domain/appel-offre'; | ||
import { GarantiesFinancières } from '@potentiel-domain/laureat'; | ||
import { featureFlags } from '@potentiel-applications/feature-flags'; | ||
|
||
import { PageWithErrorHandling } from '@/utils/PageWithErrorHandling'; | ||
import { | ||
GarantiesFinancièresDépôtsEnCoursListPage, | ||
GarantiesFinancièresDépôtsEnCoursListProps, | ||
} from '@/components/pages/garanties-financières/dépôt/lister/GarantiesFinancièresDépôtsEnCoursList.page'; | ||
import { getGarantiesFinancièresTypeLabel } from '@/components/pages/garanties-financières/getGarantiesFinancièresTypeLabel'; | ||
import { withUtilisateur } from '@/utils/withUtilisateur'; | ||
|
||
type PageProps = { | ||
searchParams?: Record<string, string>; | ||
}; | ||
|
||
export const metadata: Metadata = { | ||
title: 'Garanties financières en cours - Potentiel', | ||
description: 'Liste des garanties financières en cours', | ||
}; | ||
|
||
export default async function Page({ searchParams }: PageProps) { | ||
if (!featureFlags.SHOW_GARANTIES_FINANCIERES) { | ||
return notFound(); | ||
} | ||
|
||
return PageWithErrorHandling(async () => | ||
withUtilisateur(async (utilisateur) => { | ||
const page = searchParams?.page ? parseInt(searchParams.page) : 1; | ||
const appelOffre = searchParams?.appelOffre; | ||
|
||
const dépôtsEnCoursGarantiesFinancières = | ||
await mediator.send<GarantiesFinancières.ListerDépôtsEnCoursGarantiesFinancièresQuery>({ | ||
type: 'Lauréat.GarantiesFinancières.Query.ListerDépôtsEnCoursGarantiesFinancières', | ||
data: { | ||
utilisateur: { | ||
email: utilisateur.identifiantUtilisateur.email, | ||
rôle: utilisateur.role.nom, | ||
}, | ||
...(appelOffre && { appelOffre }), | ||
pagination: { page, itemsPerPage: 10 }, | ||
}, | ||
}); | ||
|
||
const appelOffres = await mediator.send<ListerAppelOffreQuery>({ | ||
type: 'AppelOffre.Query.ListerAppelOffre', | ||
data: {}, | ||
}); | ||
|
||
const filters = [ | ||
{ | ||
label: `Appel d'offres`, | ||
searchParamKey: 'appelOffre', | ||
defaultValue: appelOffre, | ||
options: appelOffres.items.map((appelOffre) => ({ | ||
label: appelOffre.id, | ||
value: appelOffre.id, | ||
})), | ||
}, | ||
]; | ||
|
||
return ( | ||
<GarantiesFinancièresDépôtsEnCoursListPage | ||
list={mapToListProps(dépôtsEnCoursGarantiesFinancières)} | ||
filters={filters} | ||
/> | ||
); | ||
}), | ||
); | ||
} | ||
|
||
const mapToListProps = ( | ||
readModel: GarantiesFinancières.ListerDépôtsEnCoursGarantiesFinancièresReadModel, | ||
): GarantiesFinancièresDépôtsEnCoursListProps['list'] => { | ||
const items = readModel.items.map( | ||
({ | ||
identifiantProjet, | ||
appelOffre, | ||
période, | ||
famille, | ||
nomProjet, | ||
régionProjet, | ||
dépôt: { type, dateÉchéance, dernièreMiseÀJour, statut }, | ||
}) => ({ | ||
identifiantProjet: identifiantProjet.formatter(), | ||
nomProjet, | ||
appelOffre, | ||
période, | ||
famille, | ||
statut: statut.statut, | ||
misÀJourLe: dernièreMiseÀJour.date.formatter(), | ||
type: getGarantiesFinancièresTypeLabel(type.type), | ||
dateÉchéance: dateÉchéance?.formatter(), | ||
régionProjet, | ||
}), | ||
); | ||
|
||
return { | ||
items, | ||
currentPage: readModel.currentPage, | ||
itemsPerPage: readModel.itemsPerPage, | ||
totalItems: readModel.totalItems, | ||
}; | ||
}; |
109 changes: 7 additions & 102 deletions
109
packages/applications/ssr/src/app/garanties-financieres/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,107 +1,12 @@ | ||
import { mediator } from 'mediateur'; | ||
import type { Metadata } from 'next'; | ||
import { notFound } from 'next/navigation'; | ||
import { notFound, redirect } from 'next/navigation'; | ||
|
||
import { ListerAppelOffreQuery } from '@potentiel-domain/appel-offre'; | ||
import { GarantiesFinancières } from '@potentiel-domain/laureat'; | ||
import { featureFlags } from '@potentiel-applications/feature-flags'; | ||
import { Routes } from '@potentiel-applications/routes'; | ||
|
||
import { PageWithErrorHandling } from '@/utils/PageWithErrorHandling'; | ||
import { | ||
GarantiesFinancièresDépôtsEnCoursListPage, | ||
GarantiesFinancièresDépôtsEnCoursListProps, | ||
} from '@/components/pages/garanties-financières/dépôt/lister/GarantiesFinancièresDépôtsEnCoursList.page'; | ||
import { getGarantiesFinancièresTypeLabel } from '@/components/pages/garanties-financières/getGarantiesFinancièresTypeLabel'; | ||
import { withUtilisateur } from '@/utils/withUtilisateur'; | ||
|
||
type PageProps = { | ||
searchParams?: Record<string, string>; | ||
}; | ||
|
||
export const metadata: Metadata = { | ||
title: 'Garanties financières à traiter - Potentiel', | ||
description: 'Liste des garanties financières à traiter', | ||
}; | ||
|
||
export default async function Page({ searchParams }: PageProps) { | ||
if (!process.env.FEATURE_FLAG_GARANTIES_FINANCIERES) { | ||
return notFound(); | ||
export default async function Page() { | ||
if (featureFlags.SHOW_GARANTIES_FINANCIERES) { | ||
return redirect(Routes.GarantiesFinancières.dépôt.lister); | ||
} | ||
|
||
return PageWithErrorHandling(async () => | ||
withUtilisateur(async (utilisateur) => { | ||
const page = searchParams?.page ? parseInt(searchParams.page) : 1; | ||
const appelOffre = searchParams?.appelOffre; | ||
|
||
const dépôtsEnCoursGarantiesFinancières = | ||
await mediator.send<GarantiesFinancières.ListerDépôtsEnCoursGarantiesFinancièresQuery>({ | ||
type: 'Lauréat.GarantiesFinancières.Query.ListerDépôtsEnCoursGarantiesFinancières', | ||
data: { | ||
utilisateur: { | ||
email: utilisateur.identifiantUtilisateur.email, | ||
rôle: utilisateur.role.nom, | ||
}, | ||
...(appelOffre && { appelOffre }), | ||
pagination: { page, itemsPerPage: 10 }, | ||
}, | ||
}); | ||
|
||
const appelOffres = await mediator.send<ListerAppelOffreQuery>({ | ||
type: 'AppelOffre.Query.ListerAppelOffre', | ||
data: {}, | ||
}); | ||
|
||
const filters = [ | ||
{ | ||
label: `Appel d'offres`, | ||
searchParamKey: 'appelOffre', | ||
defaultValue: appelOffre, | ||
options: appelOffres.items.map((appelOffre) => ({ | ||
label: appelOffre.id, | ||
value: appelOffre.id, | ||
})), | ||
}, | ||
]; | ||
|
||
return ( | ||
<GarantiesFinancièresDépôtsEnCoursListPage | ||
list={mapToListProps(dépôtsEnCoursGarantiesFinancières)} | ||
filters={filters} | ||
/> | ||
); | ||
}), | ||
); | ||
return notFound(); | ||
} | ||
|
||
const mapToListProps = ( | ||
readModel: GarantiesFinancières.ListerDépôtsEnCoursGarantiesFinancièresReadModel, | ||
): GarantiesFinancièresDépôtsEnCoursListProps['list'] => { | ||
const items = readModel.items.map( | ||
({ | ||
identifiantProjet, | ||
appelOffre, | ||
période, | ||
famille, | ||
nomProjet, | ||
régionProjet, | ||
dépôt: { type, dateÉchéance, dernièreMiseÀJour, statut }, | ||
}) => ({ | ||
identifiantProjet: identifiantProjet.formatter(), | ||
nomProjet, | ||
appelOffre, | ||
période, | ||
famille, | ||
statut: statut.statut, | ||
misÀJourLe: dernièreMiseÀJour.date.formatter(), | ||
type: getGarantiesFinancièresTypeLabel(type.type), | ||
dateÉchéance: dateÉchéance?.formatter(), | ||
régionProjet, | ||
}), | ||
); | ||
|
||
return { | ||
items, | ||
currentPage: readModel.currentPage, | ||
itemsPerPage: readModel.itemsPerPage, | ||
totalItems: readModel.totalItems, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.