From eba4e31d38515214228e6648b16b1c7eba514110 Mon Sep 17 00:00:00 2001 From: Marco Pedone Date: Wed, 27 Aug 2025 10:56:13 +0200 Subject: [PATCH] fix: update meta handling in AnnuncioDettaglio and improve error messages in getAnnunciByCod and getAnnunciMetaByCod --- apps/infoalloggi/src/pages/annuncio/[cod].tsx | 14 +++++++------- .../src/server/controllers/annunci.controller.ts | 12 +++++------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/apps/infoalloggi/src/pages/annuncio/[cod].tsx b/apps/infoalloggi/src/pages/annuncio/[cod].tsx index 4cfbead..fc87b90 100644 --- a/apps/infoalloggi/src/pages/annuncio/[cod].tsx +++ b/apps/infoalloggi/src/pages/annuncio/[cod].tsx @@ -68,7 +68,7 @@ type AnnuncioProps = { title: string; description: string; ogUrl: string; - }; + } | null; }; const AnnuncioDettaglio: NextPage = ({ cod, @@ -78,13 +78,13 @@ const AnnuncioDettaglio: NextPage = ({ return (
- {`${cod} | ${meta.title}`} - - + {`${cod} | ${meta?.title}`} + + - - - + + + { .where("codice", "=", cod) .executeTakeFirst(); if (!annuncio) { - throw new TRPCError({ - code: "NOT_FOUND", - message: "Annuncio non trovato", - }); + return null; } return { @@ -111,7 +109,7 @@ export const getAnnunciMetaByCod = async ({ cod }: { cod: string }) => { } catch (e) { throw new TRPCError({ code: "INTERNAL_SERVER_ERROR", - message: "Errore query getAnnuncio: " + (e as Error).message, + message: "Errore query getAnnunciMetaByCod: " + (e as Error).message, }); } };