import type { GetServerSideProps } from "next"; import type { NextPageWithLayout } from "~/pages/_app"; import { zAnnuncioId, zServizioId } from "~/server/utils/zod_types"; import { AreaRiservataLayout } from "~/components/Layout"; import { TrpcAuthedFetchingIstance } from "~/server/utils/ssgHelper"; import { Button } from "~/components/ui/button"; import { api } from "~/utils/api"; import { LoadingPage } from "~/components/loading"; import type { StorageindexId } from "~/schemas/public/Storageindex"; import { AllegatoIframe } from "~/components/allegato-iframe"; import { handleDownload } from "~/hooks/filesHooks"; import type { ServizioServizioId } from "~/schemas/public/Servizio"; import type { AnnunciId } from "~/schemas/public/Annunci"; import { Status500 } from "~/components/status-page"; import { DocNotFoundPage } from "~/components/doc_not_found"; type ContrattoViewerProps = { servizioId: ServizioServizioId; annuncioId: AnnunciId; }; const ContrattoViewer: NextPageWithLayout = ({ servizioId, annuncioId, }: ContrattoViewerProps) => { const { data, isLoading } = api.servizio.getServizioAnnuncio.useQuery({ servizioId, annuncioId, }); if (isLoading) return ; if (!data) return ; if (!data.doc_contratto_ref) return ; return (

Contratto di locazione

Hai modo di visualizzare e scaricare il contratto di locazione. Per qualunque dubbio, contattaci via chat o email.

); }; const FileSection = ({ storageId }: { storageId: StorageindexId }) => { const { data: fileInfos, isLoading } = api.storage.getStorageFromId.useQuery({ storageId, }); const { mutateAsync: getToken } = api.storage.getStorageToken.useMutation(); if (isLoading) return ; if (!fileInfos) return

Errore nel caricamento del documento

; return ( <> ); }; ContrattoViewer.getLayout = function getLayout(page) { return ( {page} ); }; export default ContrattoViewer; export const getServerSideProps = (async (context) => { const slug = context.params?.slug; if (!slug || slug.length != 2) { return { notFound: true, }; } const [servizioId, annuncioId] = slug; if (!servizioId || !annuncioId) { return { notFound: true, }; } const parsedServizioId = zServizioId.safeParse(servizioId); const parsedAnnuncioId = zAnnuncioId.safeParse(parseInt(annuncioId)); if (!parsedServizioId.success || !parsedAnnuncioId.success) { return { notFound: true, }; } const access_token = context.req.cookies.access_token; const helper = await TrpcAuthedFetchingIstance({ access_token }); if (helper) { await helper.trpc.servizio.getServizioAnnuncio.prefetch({ servizioId: parsedServizioId.data, annuncioId: parsedAnnuncioId.data, }); return { props: { servizioId: parsedServizioId.data, annuncioId: parsedAnnuncioId.data, trpcState: helper.trpc.dehydrate(), }, }; } return { redirect: { destination: "/500", permanent: false, }, }; }) satisfies GetServerSideProps;