From d3869a446e7bcfd11e103b09b09c9880e93c6784 Mon Sep 17 00:00:00 2001 From: federico-tocci-dxc Date: Mon, 21 Oct 2024 11:05:33 +0200 Subject: [PATCH] fix(monitoraggio-caricamenti): spostata sezione chips fuori sezione ricerca 20241021 --- .../MonitoraggioCaricamenti/monitoring.tsx | 55 ++++++++++++++++--- .../monitoringSearchFilters.tsx | 46 +--------------- 2 files changed, 51 insertions(+), 50 deletions(-) diff --git a/fe-piattaforma/src/pages/administrator/MonitoraggioCaricamenti/monitoring.tsx b/fe-piattaforma/src/pages/administrator/MonitoraggioCaricamenti/monitoring.tsx index 7ec3760ac..88c7ed8c8 100644 --- a/fe-piattaforma/src/pages/administrator/MonitoraggioCaricamenti/monitoring.tsx +++ b/fe-piattaforma/src/pages/administrator/MonitoraggioCaricamenti/monitoring.tsx @@ -23,6 +23,7 @@ import { withFormHandlerProps } from '../../../hoc/withFormHandler'; import { setHeadquarterDetails,resetProjectDetails } from '../../../redux/features/administrativeArea/administrativeAreaSlice'; +import { Button, Chip, ChipLabel, Icon } from 'design-react-kit'; interface MonitoringFormI { formDisabled?: boolean; creation?: boolean; @@ -50,6 +51,7 @@ const Monitoring: React.FC = ({ // const { filtroCriterioRicerca, filtroPolicies, filtroStati } = filtersList; const [statisticheElaborate, setStatisticheElaborate] = useState([]); const [formValues, setFormValues] = useState(initialFormValues); + const [chips, setChips] = useState([]); useEffect(() => { dispatch(setEntityPagination({ pageSize: 10})); @@ -59,11 +61,30 @@ const Monitoring: React.FC = ({ fetchData(); }, [dispatch]); - // const handleTableValuesChange = (newTableValues: CaricamentiResponse) => { - // setCaricamentiList(newTableValues.monitoraggioCaricamentiEntity); - // setNumeroRisultati(newTableValues.numeroTotaleElementi); - // setStatistiche([newTableValues.numeroEnti, newTableValues.numeroCaricamenti, newTableValues.serviziCaricati, newTableValues.cittadiniCaricati]); - // }; + const removeChip = (chip: string) => { + console.log("Sono in removeChip"); + // Identifica quale valore deve essere cancellato in base al chip selezionato + const newFormValues = { ...formValues }; + + if (chip.includes('Programma')) { + newFormValues.programma = initialFormValues.programma; + } else if (chip.includes('Intervento')) { + newFormValues.intervento = initialFormValues.intervento; + } else if (chip.includes('Progetto')) { + newFormValues.progetto = initialFormValues.progetto; + } else if (chip.includes('Periodo')) { + newFormValues.dataInizio = initialFormValues.dataInizio; + newFormValues.dataFine = initialFormValues.dataFine; + } else if (chip.includes('Ente')) { + newFormValues.ente = initialFormValues.ente; + } + + // Aggiorna i valori del form + setFormValues(newFormValues); + + // Rimuove la chip e aggiorna lo stato + setChips((prevChips) => prevChips.filter((c) => c !== chip)); + }; const fetchData = async (currPage: number = 1, orderBy: string = "data_caricamenti", direction: string = "desc" ) => { @@ -170,6 +191,10 @@ const Monitoring: React.FC = ({ setFormValues(formValues); } + const setChipsFunction = (chips: string[]) => { + setChips(chips); + } + return (
Monitora l'avanzamento dei caricamenti massivi dei dati degli enti. La visualizzazione di base รจ preimpostata in
@@ -177,9 +202,25 @@ const Monitoring: React.FC = ({
- + -
+
+ {chips.map((chip, index) => ( + + ))} +
+ Risultati ({numeroRisultati}) diff --git a/fe-piattaforma/src/pages/administrator/MonitoraggioCaricamenti/monitoringSearchFilters.tsx b/fe-piattaforma/src/pages/administrator/MonitoraggioCaricamenti/monitoringSearchFilters.tsx index f7f2f3c7f..8a1c3586f 100644 --- a/fe-piattaforma/src/pages/administrator/MonitoraggioCaricamenti/monitoringSearchFilters.tsx +++ b/fe-piattaforma/src/pages/administrator/MonitoraggioCaricamenti/monitoringSearchFilters.tsx @@ -19,6 +19,8 @@ interface MonitoringSearchFilterI { onSearch: () => void; formValues: { ente: OptionType; programma: OptionType; intervento: OptionType; progetto: OptionType; dataInizio: DateField; dataFine: DateField; }; setFormValues: (formValues: any) => void; + chips: string[]; + setChips: (chips: string[]) => void; } type DateField = { @@ -56,8 +58,7 @@ export const initialFormValues = { } as DateField, }; -const MonitoringSearchFilters: React.FC = ({ formValues, setFormValues, onSearch }) => { - const [chips, setChips] = useState([]); +const MonitoringSearchFilters: React.FC = ({ formValues, setFormValues, onSearch, chips, setChips }) => { const [isDateValid, setIsDateValid] = useState<{ dataInizio?: boolean; dataFine?: boolean }>({ dataInizio: true, dataFine: true }); const dispatch = useDispatch(); const dropdownFilterOptions = useSelector(selectEntityFiltersOptions); @@ -74,31 +75,6 @@ const MonitoringSearchFilters: React.FC = ({ formValues dispatch(GetEntitySearchValues({ entity: 'ente', criterioRicerca: "%" })); }, [dispatch]); - const removeChip = (chip: string) => { - console.log("Sono in removeChip"); - // Identifica quale valore deve essere cancellato in base al chip selezionato - const newFormValues = { ...formValues }; - - if (chip.includes('Programma')) { - newFormValues.programma = initialFormValues.programma; - } else if (chip.includes('Intervento')) { - newFormValues.intervento = initialFormValues.intervento; - } else if (chip.includes('Progetto')) { - newFormValues.progetto = initialFormValues.progetto; - } else if (chip.includes('Periodo')) { - newFormValues.dataInizio = initialFormValues.dataInizio; - newFormValues.dataFine = initialFormValues.dataFine; - } else if (chip.includes('Ente')) { - newFormValues.ente = initialFormValues.ente; - } - - // Aggiorna i valori del form - setFormValues(newFormValues); - - // Rimuove la chip e aggiorna lo stato - setChips((prevChips) => prevChips.filter((c) => c !== chip)); - }; - useEffect(() => { if (dropdownFilterOptions['programmi']) { @@ -393,22 +369,6 @@ const MonitoringSearchFilters: React.FC = ({ formValues - - {chips.map((chip, index) => ( - - ))} - );