diff --git a/apps/infoalloggi/emails/pagamento-conferma.tsx b/apps/infoalloggi/emails/pagamento-conferma.tsx index fadb7e1..4631a52 100644 --- a/apps/infoalloggi/emails/pagamento-conferma.tsx +++ b/apps/infoalloggi/emails/pagamento-conferma.tsx @@ -14,7 +14,6 @@ const PagamentoConferma = () => {
- {/**TODO correggere */} Gentile Cliente, la informiamo che il pagamento è stato confermato con successo. @@ -22,8 +21,8 @@ const PagamentoConferma = () => { Puoi controllare lo stato del tuo account nella sezione dedicata. - In allegato troverai una ricevuta di cortesia, la fattura - eletnica arriverà separatamente. + In allegato troverai una ricevuta di cortesia, la fattura eletnica + arriverà separatamente.
diff --git a/apps/infoalloggi/src/forms/FormEditAnnuncio.tsx b/apps/infoalloggi/src/forms/FormEditAnnuncio.tsx index 5e7c4f8..152cad3 100644 --- a/apps/infoalloggi/src/forms/FormEditAnnuncio.tsx +++ b/apps/infoalloggi/src/forms/FormEditAnnuncio.tsx @@ -1133,10 +1133,7 @@ export const AnnuncioEditForm = ({ data }: { data: AnnunciWithMedia }) => { - + { - + - + - + - + - + - + - + { const check = zAnnuncioId.safeParse(annuncioId); if (!check.success) { - return { - redirect: { - destination: "/500", - permanent: false, - }, - }; + return redirectTo500; } const ssg = generateSSGHelper(); diff --git a/apps/infoalloggi/src/pages/area-riservata/admin/user-view/onboard/[servizioId].tsx b/apps/infoalloggi/src/pages/area-riservata/admin/user-view/onboard/[servizioId].tsx index 4538e56..b13fd7f 100644 --- a/apps/infoalloggi/src/pages/area-riservata/admin/user-view/onboard/[servizioId].tsx +++ b/apps/infoalloggi/src/pages/area-riservata/admin/user-view/onboard/[servizioId].tsx @@ -3,6 +3,7 @@ import { AreaRiservataLayoutUserView } from "~/components/Layout"; import { LoadingPage } from "~/components/loading"; import { Status500 } from "~/components/status-page"; import { FormServizioAcquisto } from "~/forms/FormServizioAcquisto"; +import { redirectTo500 } from "~/lib/utils"; import type { NextPageWithLayout } from "~/pages/_app"; import { CatastoProvider } from "~/providers/CatastoProvider"; import type { ServizioServizioId } from "~/schemas/public/Servizio"; @@ -56,23 +57,13 @@ export const getServerSideProps = (async (context) => { if (typeof id !== "string") { console.error("Error: servizioId is not a string"); - return { - redirect: { - destination: "/500", - permanent: false, - }, - }; + return redirectTo500; } const parsed = zServizioId.safeParse(id); if (!parsed.success) { console.error("Error parsing servizioId", parsed.error); - return { - redirect: { - destination: "/500", - permanent: false, - }, - }; + return redirectTo500; } const access_token = context.req.cookies.access_token; @@ -104,12 +95,7 @@ export const getServerSideProps = (async (context) => { }; } - return { - redirect: { - destination: `/area-riservata/admin/utenti`, - permanent: false, - }, - }; + return redirectTo500; }) satisfies GetServerSideProps; OnboardUser.getLayout = function getLayout(page) { diff --git a/apps/infoalloggi/src/pages/area-riservata/admin/user-view/servizio/[...slug].tsx b/apps/infoalloggi/src/pages/area-riservata/admin/user-view/servizio/[...slug].tsx index e436187..69271ec 100644 --- a/apps/infoalloggi/src/pages/area-riservata/admin/user-view/servizio/[...slug].tsx +++ b/apps/infoalloggi/src/pages/area-riservata/admin/user-view/servizio/[...slug].tsx @@ -4,6 +4,7 @@ import { LoadingPage } from "~/components/loading"; import { Servizio } from "~/components/servizio/servizio"; import { AnnunciRichiesti } from "~/components/servizio/servizio_annunci_accordions"; import { Status500 } from "~/components/status-page"; +import { redirectTo500 } from "~/lib/utils"; import type { NextPageWithLayout } from "~/pages/_app"; import type { ServizioServizioId } from "~/schemas/public/Servizio"; import type { UsersId } from "~/schemas/public/Users"; @@ -52,33 +53,18 @@ export const getServerSideProps = (async (context) => { if (typeof servizio_id !== "string" || typeof user_id !== "string") { console.error("Error: servizioId or userId is not a string"); - return { - redirect: { - destination: "/500", - permanent: false, - }, - }; + return redirectTo500; } const parsedUserId = zUserId.safeParse(user_id); if (!parsedUserId.success) { console.error("Error parsing userId", parsedUserId.error); - return { - redirect: { - destination: "/500", - permanent: false, - }, - }; + return redirectTo500; } const parsedServizioId = zServizioId.safeParse(servizio_id); if (!parsedServizioId.success) { console.error("Error parsing servizioId", parsedServizioId.error); - return { - redirect: { - destination: "/500", - permanent: false, - }, - }; + return redirectTo500; } const servizioId = parsedServizioId.data; const userId = parsedUserId.data; @@ -100,12 +86,7 @@ export const getServerSideProps = (async (context) => { }; } - return { - redirect: { - destination: `/area-riservata/admin/utenti`, - permanent: false, - }, - }; + return redirectTo500; }) satisfies GetServerSideProps; ServizioUser.getLayout = function getLayout(page) { diff --git a/apps/infoalloggi/src/pages/area-riservata/allegato-view/[allegatoId].tsx b/apps/infoalloggi/src/pages/area-riservata/allegato-view/[allegatoId].tsx index f189e9c..3a0c462 100644 --- a/apps/infoalloggi/src/pages/area-riservata/allegato-view/[allegatoId].tsx +++ b/apps/infoalloggi/src/pages/area-riservata/allegato-view/[allegatoId].tsx @@ -22,6 +22,7 @@ import { } from "~/components/ui/dialog"; import { Input } from "~/components/ui/input"; import { getStorageUrl } from "~/lib/storage_utils"; +import { redirectTo500 } from "~/lib/utils"; import type { NextPageWithLayout } from "~/pages/_app"; import { useTranslation } from "~/providers/I18nProvider"; import { useEnforcedSession } from "~/providers/SessionProvider"; @@ -151,12 +152,7 @@ export const getServerSideProps = (async (context) => { }, }; } - return { - redirect: { - destination: "/500", - permanent: false, - }, - }; + return redirectTo500; }) satisfies GetServerSideProps; export default AllegatoView; diff --git a/apps/infoalloggi/src/pages/area-riservata/scheda-annuncio-stampa/[id].tsx b/apps/infoalloggi/src/pages/area-riservata/scheda-annuncio-stampa/[id].tsx index 110329f..bc61b97 100644 --- a/apps/infoalloggi/src/pages/area-riservata/scheda-annuncio-stampa/[id].tsx +++ b/apps/infoalloggi/src/pages/area-riservata/scheda-annuncio-stampa/[id].tsx @@ -5,6 +5,7 @@ import { SchedaAnnuncio, SchedaAnnuncioStampabile, } from "~/components/schedaAnnuncioStampabile"; +import { redirectTo500 } from "~/lib/utils"; import type { NextPageWithLayout } from "~/pages/_app"; import type { AnnunciWithMedia } from "~/server/controllers/annunci.controller"; import { generateSSGHelper } from "~/server/utils/ssgHelper"; @@ -53,23 +54,13 @@ export const getServerSideProps = (async (context) => { if (typeof id !== "string") { console.error("Error: id is not a string"); - return { - redirect: { - destination: "/500", - permanent: false, - }, - }; + return redirectTo500; } const parsed = zAnnuncioId.safeParse(parseInt(id)); if (!parsed.success) { console.error("Error parsing ordineId", parsed.error); - return { - redirect: { - destination: "/500", - permanent: false, - }, - }; + return redirectTo500; } const helper = generateSSGHelper(); @@ -87,7 +78,7 @@ export const getServerSideProps = (async (context) => { props: { raw: raw === "true", trpcState: helper.dehydrate(), - data : AnnuncioToStringified(data), + data: AnnuncioToStringified(data), }, }; }) satisfies GetServerSideProps; diff --git a/apps/infoalloggi/src/pages/area-riservata/servizio/[servizioId].tsx b/apps/infoalloggi/src/pages/area-riservata/servizio/[servizioId].tsx index 9cd5c1d..00c538c 100644 --- a/apps/infoalloggi/src/pages/area-riservata/servizio/[servizioId].tsx +++ b/apps/infoalloggi/src/pages/area-riservata/servizio/[servizioId].tsx @@ -4,6 +4,7 @@ import { AreaRiservataLayout } from "~/components/Layout"; import { LoadingPage } from "~/components/loading"; import { Servizio } from "~/components/servizio/servizio"; import { Status500 } from "~/components/status-page"; +import { redirectTo500 } from "~/lib/utils"; import type { NextPageWithLayout } from "~/pages/_app"; import { useEnforcedSession } from "~/providers/SessionProvider"; import type { ServizioServizioId } from "~/schemas/public/Servizio"; @@ -34,21 +35,6 @@ const ServizioPage: NextPageWithLayout = ({ } return (
- {/*
-
-

- {t.servizio.dettaglio_servizio} -

- - - - -
- -
*/}
{ if (typeof servizio_id !== "string") { console.error("Error: servizioId is not a string"); - return { - redirect: { - destination: "/500", - permanent: false, - }, - }; + return redirectTo500; } const parsedServizioId = zServizioId.safeParse(servizio_id); if (!parsedServizioId.success) { console.error("Error parsing servizioId", parsedServizioId.error); - return { - redirect: { - destination: "/500", - permanent: false, - }, - }; + return redirectTo500; } const servizioId = parsedServizioId.data; @@ -106,12 +82,7 @@ export const getServerSideProps = (async (context) => { }; } - return { - redirect: { - destination: `/area-riservata/admin/utenti`, - permanent: false, - }, - }; + return redirectTo500; }) satisfies GetServerSideProps; ServizioPage.getLayout = function getLayout(page) { diff --git a/apps/infoalloggi/src/pages/servizio/bonifico-checkout/[ordineId].tsx b/apps/infoalloggi/src/pages/servizio/bonifico-checkout/[ordineId].tsx index c0c49fe..9bc5a07 100644 --- a/apps/infoalloggi/src/pages/servizio/bonifico-checkout/[ordineId].tsx +++ b/apps/infoalloggi/src/pages/servizio/bonifico-checkout/[ordineId].tsx @@ -3,7 +3,7 @@ import type { GetServerSideProps } from "next"; import Link from "next/link"; import { AreaRiservataLayout } from "~/components/Layout"; import { Button } from "~/components/ui/button"; -import { formatCurrency } from "~/lib/utils"; +import { formatCurrency, redirectTo500 } from "~/lib/utils"; import type { NextPageWithLayout } from "~/pages/_app"; import { TrpcAuthedFetchingIstance } from "~/server/utils/ssgHelper"; import { zOrdineId } from "~/server/utils/zod_types"; @@ -78,23 +78,13 @@ export const getServerSideProps = (async (context) => { const id = context.params?.ordineId; if (typeof id !== "string") { console.error("Error: ordineId is not a string"); - return { - redirect: { - destination: "/500", - permanent: false, - }, - }; + return redirectTo500; } const parsed = zOrdineId.safeParse(id); if (!parsed.success) { console.error("Error parsing ordineId", parsed.error); - return { - redirect: { - destination: "/500", - permanent: false, - }, - }; + return redirectTo500; } const access_token = context.req.cookies.access_token; @@ -115,10 +105,5 @@ export const getServerSideProps = (async (context) => { }, }; } - return { - redirect: { - destination: "/500", - permanent: false, - }, - }; + return redirectTo500; }) satisfies GetServerSideProps; diff --git a/apps/infoalloggi/src/pages/servizio/condizioni/[stringaId].tsx b/apps/infoalloggi/src/pages/servizio/condizioni/[stringaId].tsx index 3fbf9f3..d11391b 100644 --- a/apps/infoalloggi/src/pages/servizio/condizioni/[stringaId].tsx +++ b/apps/infoalloggi/src/pages/servizio/condizioni/[stringaId].tsx @@ -2,6 +2,7 @@ import type { GetServerSideProps } from "next"; import { AreaRiservataLayout } from "~/components/Layout"; import { LoadingPage } from "~/components/loading"; import { Status500 } from "~/components/status-page"; +import { redirectTo500 } from "~/lib/utils"; import type { NextPageWithLayout } from "~/pages/_app"; import type { TestiEStringheStingaId } from "~/schemas/public/TestiEStringhe"; import { generateSSGHelper } from "~/server/utils/ssgHelper"; @@ -53,23 +54,13 @@ export const getServerSideProps = (async (context) => { const raw = context.query?.raw; if (typeof id !== "string") { console.error("Error: stringaId is not a string"); - return { - redirect: { - destination: "/500", - permanent: false, - }, - }; + return redirectTo500; } const parsed = zTestiEStringheStingaId.safeParse(id); if (!parsed.success) { console.error("Error parsing paymentId", parsed.error); - return { - redirect: { - destination: "/500", - permanent: false, - }, - }; + return redirectTo500; } const helper = generateSSGHelper(); @@ -86,10 +77,5 @@ export const getServerSideProps = (async (context) => { }, }; } - return { - redirect: { - destination: "/500", - permanent: false, - }, - }; + return redirectTo500; }) satisfies GetServerSideProps; diff --git a/apps/infoalloggi/src/pages/servizio/conferma-immobile/[...slug].tsx b/apps/infoalloggi/src/pages/servizio/conferma-immobile/[...slug].tsx index cc5bfe2..493536d 100644 --- a/apps/infoalloggi/src/pages/servizio/conferma-immobile/[...slug].tsx +++ b/apps/infoalloggi/src/pages/servizio/conferma-immobile/[...slug].tsx @@ -9,6 +9,7 @@ import { FileSection } from "~/components/servizio/conferma"; import { Status500 } from "~/components/status-page"; import { Button } from "~/components/ui/button"; import { Checkbox } from "~/components/ui/checkbox"; +import { redirectTo500 } from "~/lib/utils"; import type { NextPageWithLayout } from "~/pages/_app"; import { useTranslation } from "~/providers/I18nProvider"; import { useEnforcedSession } from "~/providers/SessionProvider"; @@ -214,10 +215,5 @@ export const getServerSideProps = (async (context) => { }, }; } - return { - redirect: { - destination: "/500", - permanent: false, - }, - }; + return redirectTo500; }) satisfies GetServerSideProps; diff --git a/apps/infoalloggi/src/pages/servizio/contratto-registrazione/[...slug].tsx b/apps/infoalloggi/src/pages/servizio/contratto-registrazione/[...slug].tsx index acb9627..e87da94 100644 --- a/apps/infoalloggi/src/pages/servizio/contratto-registrazione/[...slug].tsx +++ b/apps/infoalloggi/src/pages/servizio/contratto-registrazione/[...slug].tsx @@ -6,6 +6,7 @@ import { AreaRiservataLayout } from "~/components/Layout"; import { LoadingPage } from "~/components/loading"; import { Status500 } from "~/components/status-page"; import { getStorageUrl } from "~/lib/storage_utils"; +import { redirectTo500 } from "~/lib/utils"; import type { NextPageWithLayout } from "~/pages/_app"; import { useTranslation } from "~/providers/I18nProvider"; import type { AnnunciId } from "~/schemas/public/Annunci"; @@ -120,10 +121,5 @@ export const getServerSideProps = (async (context) => { }, }; } - return { - redirect: { - destination: "/500", - permanent: false, - }, - }; + return redirectTo500; }) satisfies GetServerSideProps; diff --git a/apps/infoalloggi/src/pages/servizio/contratto/[...slug].tsx b/apps/infoalloggi/src/pages/servizio/contratto/[...slug].tsx index 4e1429b..b077606 100644 --- a/apps/infoalloggi/src/pages/servizio/contratto/[...slug].tsx +++ b/apps/infoalloggi/src/pages/servizio/contratto/[...slug].tsx @@ -6,6 +6,7 @@ import { AreaRiservataLayout } from "~/components/Layout"; import { LoadingPage } from "~/components/loading"; import { Status500 } from "~/components/status-page"; import { getStorageUrl } from "~/lib/storage_utils"; +import { redirectTo500 } from "~/lib/utils"; import type { NextPageWithLayout } from "~/pages/_app"; import { useTranslation } from "~/providers/I18nProvider"; import type { AnnunciId } from "~/schemas/public/Annunci"; @@ -116,10 +117,5 @@ export const getServerSideProps = (async (context) => { }, }; } - return { - redirect: { - destination: "/500", - permanent: false, - }, - }; + return redirectTo500; }) satisfies GetServerSideProps; diff --git a/apps/infoalloggi/src/pages/servizio/onboard/[servizioId].tsx b/apps/infoalloggi/src/pages/servizio/onboard/[servizioId].tsx index 4750924..4010237 100644 --- a/apps/infoalloggi/src/pages/servizio/onboard/[servizioId].tsx +++ b/apps/infoalloggi/src/pages/servizio/onboard/[servizioId].tsx @@ -4,6 +4,7 @@ import { LoadingPage } from "~/components/loading"; import { OnboardTutorial } from "~/components/onboard_tutorial"; import { Status500 } from "~/components/status-page"; import { FormServizioAcquisto } from "~/forms/FormServizioAcquisto"; +import { redirectTo500 } from "~/lib/utils"; import type { NextPageWithLayout } from "~/pages/_app"; import { CatastoProvider } from "~/providers/CatastoProvider"; import { useTranslation } from "~/providers/I18nProvider"; @@ -65,23 +66,13 @@ export const getServerSideProps = (async (context) => { if (typeof id !== "string") { console.error("Error: servizioId is not a string"); - return { - redirect: { - destination: "/500", - permanent: false, - }, - }; + return redirectTo500; } const parsed = zServizioId.safeParse(id); if (!parsed.success) { console.error("Error parsing servizioId", parsed.error); - return { - redirect: { - destination: "/500", - permanent: false, - }, - }; + return redirectTo500; } const access_token = context.req.cookies.access_token; diff --git a/apps/infoalloggi/src/pages/servizio/pagamento-status.tsx b/apps/infoalloggi/src/pages/servizio/pagamento-status.tsx index 4ade2ac..5b358fc 100644 --- a/apps/infoalloggi/src/pages/servizio/pagamento-status.tsx +++ b/apps/infoalloggi/src/pages/servizio/pagamento-status.tsx @@ -6,10 +6,10 @@ import PaymentStatus from "~/components/payment_status"; import { ProgressRedirect } from "~/components/progress_redirect"; import { Button, buttonVariants } from "~/components/ui/button"; import stripe from "~/lib/stripe"; -import { cn } from "~/lib/utils"; +import { cn, redirectTo500 } from "~/lib/utils"; import { useTranslation } from "~/providers/I18nProvider"; +import OrderTypeEnum from "~/schemas/public/OrderTypeEnum"; import PaymentStatusEnum from "~/schemas/public/PaymentStatusEnum"; -import type { ServizioServizioId } from "~/schemas/public/Servizio"; import { TrpcAuthedFetchingIstance } from "~/server/utils/ssgHelper"; enum AcquistoStatusEnum { @@ -21,26 +21,21 @@ enum AcquistoStatusEnum { } type AcquistoProcessingProps = { - servizioId: ServizioServizioId | null; + redirectUrl: string; status: AcquistoStatusEnum; }; export const getServerSideProps = (async (context) => { const paymentIntentId = context.query?.payment_intent; if (!paymentIntentId || typeof paymentIntentId !== "string") { - return { - redirect: { - destination: "/500", - permanent: false, - }, - }; + return redirectTo500; } const paymentIntent = await stripe.paymentIntents.retrieve(paymentIntentId); if (!paymentIntent) { return { props: { - servizioId: null, + redirectUrl: "", status: AcquistoStatusEnum.internal_error, }, }; @@ -57,7 +52,7 @@ export const getServerSideProps = (async (context) => { if (!payment) { return { props: { - servizioId: null, + redirectUrl: "", status: AcquistoStatusEnum.not_found, }, }; @@ -79,25 +74,23 @@ export const getServerSideProps = (async (context) => { } return { props: { - servizioId: payment.servizio_id, + redirectUrl: + payment.type === OrderTypeEnum.Rinnovo + ? `/area-riservata/rinnovo/${payment.rinnovo_id}` + : `/area-riservata/servizio/${payment.servizio_id}`, status: resultStatus, }, }; } - return { - redirect: { - destination: "/500", - permanent: false, - }, - }; + return redirectTo500; }) satisfies GetServerSideProps; /** * Pagina di stato del pagamento dopo un acquisto: /servizio/pagamento-status?payment_intent=paymentIntentId */ export default function AcquistoProcessing({ - servizioId, + redirectUrl, status, }: AcquistoProcessingProps) { const { t } = useTranslation(); @@ -117,7 +110,7 @@ export default function AcquistoProcessing({ title={t.acquisto_elaborazione.success_title} /> - + )} {status === AcquistoStatusEnum.processing && ( diff --git a/apps/infoalloggi/src/pages/servizio/riapri-conferma/[...slug].tsx b/apps/infoalloggi/src/pages/servizio/riapri-conferma/[...slug].tsx index 941b4ab..a6ba60e 100644 --- a/apps/infoalloggi/src/pages/servizio/riapri-conferma/[...slug].tsx +++ b/apps/infoalloggi/src/pages/servizio/riapri-conferma/[...slug].tsx @@ -7,6 +7,7 @@ import { LoadingPage } from "~/components/loading"; import { FileSection } from "~/components/servizio/conferma"; import { Status500 } from "~/components/status-page"; import { Button } from "~/components/ui/button"; +import { redirectTo500 } from "~/lib/utils"; import type { NextPageWithLayout } from "~/pages/_app"; import { useTranslation } from "~/providers/I18nProvider"; import type { AnnunciId } from "~/schemas/public/Annunci"; @@ -126,10 +127,5 @@ export const getServerSideProps = (async (context) => { }, }; } - return { - redirect: { - destination: "/500", - permanent: false, - }, - }; + return redirectTo500; }) satisfies GetServerSideProps; diff --git a/apps/infoalloggi/src/pages/servizio/ricevuta-cortesia/[ordineId].tsx b/apps/infoalloggi/src/pages/servizio/ricevuta-cortesia/[ordineId].tsx index 2d209d7..7584291 100644 --- a/apps/infoalloggi/src/pages/servizio/ricevuta-cortesia/[ordineId].tsx +++ b/apps/infoalloggi/src/pages/servizio/ricevuta-cortesia/[ordineId].tsx @@ -3,6 +3,7 @@ import { ReceiptGenerator } from "~/components/acquisto_receipt"; import { AreaRiservataLayout } from "~/components/Layout"; import { LoadingPage } from "~/components/loading"; import { Status500 } from "~/components/status-page"; +import { redirectTo500 } from "~/lib/utils"; import type { NextPageWithLayout } from "~/pages/_app"; import type { OrdiniOrdineId } from "~/schemas/public/Ordini"; import { generateSSGHelper } from "~/server/utils/ssgHelper"; @@ -52,23 +53,13 @@ export const getServerSideProps = (async (context) => { const raw = context.query?.raw; if (typeof id !== "string") { console.error("Error: ordineId is not a string"); - return { - redirect: { - destination: "/500", - permanent: false, - }, - }; + return redirectTo500; } const parsed = zOrdineId.safeParse(id); if (!parsed.success) { console.error("Error parsing ordineId", parsed.error); - return { - redirect: { - destination: "/500", - permanent: false, - }, - }; + return redirectTo500 } const helper = generateSSGHelper(); @@ -85,10 +76,5 @@ export const getServerSideProps = (async (context) => { }, }; } - return { - redirect: { - destination: "/500", - permanent: false, - }, - }; + return redirectTo500; }) satisfies GetServerSideProps;