From fa46fd2925143a2655597a7e50956ba1baf1938a Mon Sep 17 00:00:00 2001 From: Marco Pedone Date: Sun, 10 Aug 2025 17:54:00 +0200 Subject: [PATCH] Refactor AnnuncioActions and Interactions components for improved layout and structure --- .../components/servizio/annuncio_actions.tsx | 117 ++++++++++-------- .../src/components/servizio/interactions.tsx | 4 +- 2 files changed, 68 insertions(+), 53 deletions(-) diff --git a/apps/infoalloggi/src/components/servizio/annuncio_actions.tsx b/apps/infoalloggi/src/components/servizio/annuncio_actions.tsx index 0caa573..83844d5 100644 --- a/apps/infoalloggi/src/components/servizio/annuncio_actions.tsx +++ b/apps/infoalloggi/src/components/servizio/annuncio_actions.tsx @@ -5,7 +5,6 @@ import { ChevronsUpDown, CircleCheck, ClipboardPaste, - Cog, ExternalLink, FolderKanban, Pen, @@ -90,7 +89,7 @@ export const AnnuncioActions = () => { if ((!isAdmin && data.open_contatti_at == null) || isAdmin) { return ( -
+
{isAdmin && data.user_confirmed_at != null && } {isAdmin && data.accettato_conferma_at != null && ( <> @@ -102,48 +101,49 @@ export const AnnuncioActions = () => { target="_blank" > )} )} {isAdmin && ( - - - - )} + + - { - mutate({ - servizioId, - annuncioId, - }); - }} - > - - + { + mutate({ + servizioId, + annuncioId, + }); + }} + > + + + + )}
); } @@ -152,8 +152,8 @@ export const AnnuncioActions = () => { const ContrattoImportSchema = z.object({ gestionale_id: z.number().nullable(), - contratto_decorrenza: z.date().nullable(), - contratto_scadenza: z.date().nullable(), + contratto_decorrenza: z.string().nullable(), + contratto_scadenza: z.string().nullable(), contratto_tipo: z .enum([ "Transitorio", @@ -167,7 +167,14 @@ const ContrattoImportSchema = z.object({ .nullable(), }); -type ContrattoImportObj = z.infer; +interface ContrattoImportObj + extends Omit< + z.infer, + "contratto_decorrenza" | "contratto_scadenza" + > { + contratto_decorrenza: Date | null; + contratto_scadenza: Date | null; +} const parseContrattoImport = (ingest: string) => { let parsedJson: unknown; @@ -181,7 +188,15 @@ const parseContrattoImport = (ingest: string) => { } const parsed = ContrattoImportSchema.safeParse(parsedJson); if (parsed.success) { - return parsed.data; + return { + ...parsed.data, + contratto_decorrenza: parsed.data.contratto_decorrenza + ? new Date(parsed.data.contratto_decorrenza) + : null, + contratto_scadenza: parsed.data.contratto_scadenza + ? new Date(parsed.data.contratto_scadenza) + : null, + }; } else { console.error("Invalid format:", parsed.error); return undefined; @@ -431,19 +446,19 @@ const AdminContratto = () => { - + Sezione Contratto @@ -535,7 +550,7 @@ const ContrattoSection = ({ setSelectedDoc(null); }} > - Reset + Reset
)} @@ -626,7 +641,7 @@ const RicevutaSection = ({ setSelectedDoc(null); }} > - Reset + Reset )} @@ -691,16 +706,16 @@ const AdminLavoraConferma = () => { diff --git a/apps/infoalloggi/src/components/servizio/interactions.tsx b/apps/infoalloggi/src/components/servizio/interactions.tsx index 21e678a..079f6e8 100644 --- a/apps/infoalloggi/src/components/servizio/interactions.tsx +++ b/apps/infoalloggi/src/components/servizio/interactions.tsx @@ -45,7 +45,7 @@ export const Interactions = () => { const { data, annuncioId } = useServizioAnnuncio(); return ( - <> +
{data.open_contatti_at !== null && data.user_confirmed_at == null && ( @@ -195,7 +195,7 @@ export const Interactions = () => {
)} - + ); };