From 6c75ddf5c6915c3eedef34c5b434bea749198748 Mon Sep 17 00:00:00 2001 From: Matteo Grifantini Date: Fri, 20 Sep 2024 18:00:57 +0200 Subject: [PATCH] feat(fe-piattaforma): update tabella caricamento massivo --- .../ActivityReportTable.tsx | 35 ++++++++++++------- .../components/FileHandling/SubmitFileCsv.tsx | 3 ++ .../src/components/StatusChip/statusChip.tsx | 9 +++++ .../src/models/RegistroAttivita.model.ts | 1 + 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/fe-piattaforma/src/components/ActivityReportTable/ActivityReportTable.tsx b/fe-piattaforma/src/components/ActivityReportTable/ActivityReportTable.tsx index 21c7dc25d..8d798b737 100644 --- a/fe-piattaforma/src/components/ActivityReportTable/ActivityReportTable.tsx +++ b/fe-piattaforma/src/components/ActivityReportTable/ActivityReportTable.tsx @@ -19,6 +19,7 @@ import { ProjectContext } from '../../contexts/ProjectContext'; import { CRUDActionsI, CRUDActionTypes } from '../../utils/common'; import { useParams } from 'react-router-dom'; import { downloadResume } from '../../utils/csvUtils'; +import StatusChip from '../StatusChip/statusChip'; const tableHeading: TableHeadingI[] = [ { @@ -33,8 +34,8 @@ const tableHeading: TableHeadingI[] = [ size: 'medium', }, { - label: 'Data e ora', - field: 'dataFineInserimento', + label: 'Data e ora avvio', + field: 'dataInizioInserimento', size: 'medium', }, { @@ -59,7 +60,7 @@ const tableHeading: TableHeadingI[] = [ }, { label: 'Stato', - field: 'stato', + field: 'statoChip', size: 'medium', }, ]; @@ -90,19 +91,29 @@ const ActivityReportTable = forwardRef(function ActivityReportTable( enteId ? parseInt(enteId) : projectContext!.idEnte ) .then((res) => { - // mappo gli stati per inserirli in tabella in modo semplificato ('IN CORSO', 'COMPLETATO', 'NON COMPLETATO') + // mappo gli stati per inserirli in tabella in modo semplificato ('IN CORSO', 'COMPLETATO', 'FALLITO') const statusMap: { [key: string]: string } = { IN_PROGRESS: 'IN CORSO', SUCCESS: 'COMPLETATO', - FAIL_MONGO: 'NON COMPLETATO', - FAIL_S3_API: 'NON COMPLETATO', - 'FAIL-S3_UPLOAD': 'NON COMPLETATO', - GENERIC_FAIL: 'NON COMPLETATO' + FAIL_MONGO: 'FALLITO', + FAIL_S3_API: 'FALLITO', + 'FAIL-S3_UPLOAD': 'FALLITO', + GENERIC_FAIL: 'FALLITO' }; - const updatedContent = res.data.content.map((item: RegistroAttivita) => ({ - ...item, - stato: statusMap[item.jobStatus] || item.stato - })); + const updatedContent = res.data.content.map((item: RegistroAttivita) => { + const updatedItem = { + ...item, + stato: statusMap[item.jobStatus] || item.stato, + statoChip: , + }; + if (statusMap[item.jobStatus] === 'FALLITO') { + updatedItem.cittadiniAggiunti = 0; + updatedItem.serviziAcquisiti = 0; + updatedItem.totaleRigheFile = 0; + updatedItem.righeScartate = 0; + } + return updatedItem; + }); setPagination({ ...res.data, content: updatedContent }); }) .catch(() => { diff --git a/fe-piattaforma/src/components/FileHandling/SubmitFileCsv.tsx b/fe-piattaforma/src/components/FileHandling/SubmitFileCsv.tsx index fbdbc2070..df9e0d3b8 100644 --- a/fe-piattaforma/src/components/FileHandling/SubmitFileCsv.tsx +++ b/fe-piattaforma/src/components/FileHandling/SubmitFileCsv.tsx @@ -94,6 +94,9 @@ export default function SubmitFileCsv(props: { clearFile: () => void }) { const res = results[1]; setActivityReportUUID(res.data); props.clearFile(); + setTimeout(() => { + triggerSearch(); + }, 2000); }) .catch(() => { //showErrorUpload() diff --git a/fe-piattaforma/src/components/StatusChip/statusChip.tsx b/fe-piattaforma/src/components/StatusChip/statusChip.tsx index fc22949a3..92a195598 100644 --- a/fe-piattaforma/src/components/StatusChip/statusChip.tsx +++ b/fe-piattaforma/src/components/StatusChip/statusChip.tsx @@ -24,6 +24,8 @@ const statusTypes = { NOT_FILLED_OUT: 'NON COMPILATA', TERMINATED: 'TERMINATO', ACTIVABLE: 'ATTIVABILE', + IN_PROGRESS: 'IN CORSO', + FAILED: 'FALLITO', }; export const statusBgColor = (status: string) => { @@ -47,6 +49,10 @@ export const statusBgColor = (status: string) => { return 'neutral-2-bg-b5'; case statusTypes.ACTIVABLE: return 'activable'; + case statusTypes.IN_PROGRESS: + return 'activable'; + case statusTypes.FAILED: + return 'neutral-1-bg-a1'; default: return 'neutral-1-bg-a1'; } @@ -73,6 +79,9 @@ export const statusColor = (status: string) => { return 'text-white'; case statusTypes.ACTIVABLE: return 'text-white'; + case statusTypes.IN_PROGRESS: + return 'text-white'; + case statusTypes.FAILED: default: return 'neutral-1-bg-a1'; } diff --git a/fe-piattaforma/src/models/RegistroAttivita.model.ts b/fe-piattaforma/src/models/RegistroAttivita.model.ts index 8d04e1948..d451515df 100644 --- a/fe-piattaforma/src/models/RegistroAttivita.model.ts +++ b/fe-piattaforma/src/models/RegistroAttivita.model.ts @@ -16,6 +16,7 @@ export interface RegistroAttivita extends TableRowI { isFileUpdated?: boolean; jobStatus: string; stato: string; + statoChip?: JSX.Element; } export type RegistroAttivitaWithoutID = Omit;