diff --git a/apps/infoalloggi/src/components/servizio/annuncio_actions.tsx b/apps/infoalloggi/src/components/servizio/annuncio_actions.tsx index 83844d5..fd7b741 100644 --- a/apps/infoalloggi/src/components/servizio/annuncio_actions.tsx +++ b/apps/infoalloggi/src/components/servizio/annuncio_actions.tsx @@ -47,7 +47,7 @@ import { } from "~/components/custom_ui/credenza"; import { LoadingPage } from "~/components/loading"; import Link from "next/link"; -import { cn } from "~/lib/utils"; +import { cn, formatCurrency } from "~/lib/utils"; import { useRef, useState } from "react"; import { z } from "zod/v4"; import { Separator } from "~/components/ui/separator"; @@ -67,6 +67,8 @@ import { type AnimatedButtonRef, } from "~/components/custom_ui/animated-button"; import type { AnnunciId } from "~/schemas/public/Annunci"; +import { useTranslation } from "~/providers/I18nProvider"; +import TipologiaPosizioneEnum from "~/schemas/public/TipologiaPosizioneEnum"; export const AnnuncioActions = () => { const { servizioId, userId, isAdmin } = useServizio(); @@ -537,21 +539,22 @@ const ContrattoSection = ({ {selectedDoc && (
- - + + +
)} {selectedDoc && (
- - + + +
)} { const { userId } = useServizio(); const { data } = useServizioAnnuncio(); - const [selectedDoc, setSelectedDoc] = useState( - data.doc_conferma_ref, - ); const utils = api.useUtils(); @@ -771,19 +772,6 @@ const DocSection = ({ }, }); - const handleSave = () => { - handleUpdate({ - doc_conferma_ref: selectedDoc, - doc_conferma_added: selectedDoc != null, - }); - if (selectedDoc) { - setUserStorage({ - userId, - fileId: selectedDoc, - }); - } - }; - if (isLoading) return ; if (files == undefined) { return

Errore nel caricamento dei documenti

; @@ -797,73 +785,85 @@ const DocSection = ({ - {selectedDoc && ( -
- - - + {data.doc_conferma_ref && ( +
+ + +
)} - { - setSelectedDoc(f.id); - }} - current={selectedDoc} - /> - +
+ { + handleUpdate({ + doc_conferma_ref: f.id, + doc_conferma_added: true, + }); + + setUserStorage({ + userId, + fileId: f.id, + }); + }} + current={data.doc_conferma_ref} + /> + +
- - - ); }; -const DocInfo = ({ storageId }: { storageId: StorageindexId }) => { +const DocInfo = ({ + storageId, + children, +}: { + storageId: StorageindexId; + children: React.ReactNode; +}) => { const { data: file_info } = api.storage.getStorageFromId.useQuery({ storageId, }); if (!file_info) return null; return ( -
+
- - {file_info.ext && } - {file_info.filename} - - +
+
+ + {file_info.ext && } + + {file_info.filename} + + + +
+ {children} +
); }; @@ -981,7 +981,7 @@ const Caparra = ({ -
+
{caparra ? ( @@ -1129,7 +1128,9 @@ const SendConferma = ({ }: { handleUpdate: (upd: ServizioAnnunciUpdate) => void; }) => { + const { servizio } = useServizio(); const { data } = useServizioAnnuncio(); + const { t } = useTranslation(); const [check, setCheck] = useState(data.hasConfermaAdmin); return ( @@ -1137,10 +1138,47 @@ const SendConferma = ({ Lavorazione Conferma - Se accettare la conferma, controlla i parametri di ricerca prima! + controlla i parametri di ricerca prima! - + +
+

Tipologia servizio: {servizio.tipologia}

+ {(() => { + if (servizio.tipologia === TipologiaPosizioneEnum.Transitorio) { + return ( + <> +

+ Permanenza (da preferenze):{" "} + {servizio.permanenza + ? t.preferenze.permanenza[servizio.permanenza] + : "non inserita"} +

+

+ Permanenza (da descrizione): " + {(() => { + const match = data.desc_it?.match(/Permanenza:.*$/m); + return match ? match[0] : ""; + })()} + " +

+ + ); + } else { + return ( + <> +

+ Budget (da preferenze): {formatCurrency(servizio.budget)} +

+

+ Canone Mensile (da descrizione):{" "} + {formatCurrency(data.prezzo / 100)} +

+ + ); + } + })()} +
{ } content={
-
+
{ "servizio.created_at", "servizio.decorrenza", "servizio.tipologia", + "servizio.budget", + "servizio.permanenza", "servizio.isInterrotto", "servizio.isOkAcconto", "servizio.isOkSaldo",