From 7988372ceb17fe23caca131f5547608d21e04eb0 Mon Sep 17 00:00:00 2001 From: shinework Date: Tue, 21 Jan 2025 15:53:10 +0100 Subject: [PATCH] feat: improvements --- .../Place/ApplicationPlaceList.tsx | 8 +++ .../Place/ApplicationPlaceListItem.tsx | 2 +- .../ValidatedSelections.tsx | 2 +- .../DetailDrawer/ApplicationDetailDrawer.tsx | 3 + .../ApplicationPreselectButton.tsx | 62 ++++++++++++------- .../DetailDrawer/ApplicationRightPanel.tsx | 3 + web/pages/api/pdfs/campaign/[id].tsx | 16 ++++- web/public/locales/fr/application.json | 1 + 8 files changed, 68 insertions(+), 29 deletions(-) diff --git a/web/components/Account/Application/Place/ApplicationPlaceList.tsx b/web/components/Account/Application/Place/ApplicationPlaceList.tsx index a4ee980c..a547e73b 100644 --- a/web/components/Account/Application/Place/ApplicationPlaceList.tsx +++ b/web/components/Account/Application/Place/ApplicationPlaceList.tsx @@ -50,6 +50,13 @@ const ApplicationPlaceList = ({ applications = [] }: Props) => { (application) => application?.status === 'preselected', ) + const validatedApplications = applications?.filter( + (application) => application?.status === 'confirmed', + ).length + + const hasValidatedApplications = + selectedCampaign?.mode === 'preselections' && validatedApplications > 0 + const filteredList = useMemo( () => list.filter((application) => { @@ -139,6 +146,7 @@ const ApplicationPlaceList = ({ applications = [] }: Props) => { isOpen={isOpen} onClose={onClose} application={selectedApplication} + hasValidatedApplications={hasValidatedApplications} canPreselect={ preselectedApplications?.length < selectedCampaign?.preselections_max && diff --git a/web/components/Account/Application/Place/ApplicationPlaceListItem.tsx b/web/components/Account/Application/Place/ApplicationPlaceListItem.tsx index 3649811e..0065d270 100644 --- a/web/components/Account/Application/Place/ApplicationPlaceListItem.tsx +++ b/web/components/Account/Application/Place/ApplicationPlaceListItem.tsx @@ -48,7 +48,7 @@ const ApplicationPlaceListItem = ({ application, onSelect }: Props) => { {['preselections', 'closed']?.includes(selectedCampaign?.mode) && ( - + + <> + + + {!canPreselect && ( + + {t('place.preselected_limit_reached')} + + )} + )} - {application?.status === 'confirmed' && ( + {(application?.status === 'confirmed' || hasValidatedApplications) && ( {t('place.detail.confirmed_helper_start')} void isDownloading?: boolean + hasValidatedApplications: boolean }) => { const { t } = useTranslation('application') @@ -48,6 +50,7 @@ const ApplicationRightPanel = ({ diff --git a/web/pages/api/pdfs/campaign/[id].tsx b/web/pages/api/pdfs/campaign/[id].tsx index 7ac8b6b4..913ed38b 100644 --- a/web/pages/api/pdfs/campaign/[id].tsx +++ b/web/pages/api/pdfs/campaign/[id].tsx @@ -67,6 +67,7 @@ const buildApplicationsSpreadsheet = async (applications: Application[]) => { 'Site web', 'Espace - Candidature', 'Créneau - Candidature', + 'Statut - Candidature', ] const headerRow = worksheet.addRow(headers) @@ -114,6 +115,7 @@ const buildApplicationsSpreadsheet = async (applications: Application[]) => { ? `${application.disponibility.espace.users_permissions_user.structureName} - ${application.espace.name}` : '-', range, + application.status, ]) row.eachCell((cell) => { @@ -257,6 +259,7 @@ const buildSummarySpreadsheet = async ( `Nom de l'espace`, `Créneaux proposés`, withAllApplications ? `Candidatures` : `Sélection finale`, + `Référence candidature`, `Communication`, `Contact`, ] @@ -287,11 +290,16 @@ const buildSummarySpreadsheet = async ( espaceCount++ disponibilityCount++ + const counterApplications = applicationsCounter[application.title] + const row = worksheet.addRow([ place.structureName, espace.name, disponibility.range, - application.name, + `${application.name}${ + counterApplications > 1 ? ` - ${counterApplications}` : '' + }`, + `Ref. ${application.id}`, '', application.email, ]) @@ -305,7 +313,9 @@ const buildSummarySpreadsheet = async ( } applicationCell.value = { - text: application.name, + text: `${application.name}${ + counterApplications > 1 ? ` - ${counterApplications}` : '' + }`, hyperlink: getApplicationLink(application.id), } @@ -314,7 +324,7 @@ const buildSummarySpreadsheet = async ( italic: true, } - if (applicationsCounter[application.title] > 1) { + if (counterApplications > 1) { applicationCell.fill = { type: 'pattern', pattern: 'solid', diff --git a/web/public/locales/fr/application.json b/web/public/locales/fr/application.json index 770a5c9b..55dd7cfd 100644 --- a/web/public/locales/fr/application.json +++ b/web/public/locales/fr/application.json @@ -73,6 +73,7 @@ "no_places": "Aucun de vos espaces ne propose de créneau pour ce dispositif", "no_applications": "Aucune candidature déposée pour ce créneau pour le moment.", "no_applications_past": "Aucune candidature n'a été déposée pour ce créneau.", + "preselected_limit_reached": "Vous avez atteint la limite de candidatures à pré-sélectionner, annuler la sélection de l'une de ces candidatures afin de pouvoir sélectionner celle-ci.", "detail": { "title": "Candidature n°{{id}}", "header": {