infoalloggi-monorepo/apps/infoalloggi/src/pages/servizio/condizioni/[stringaId].tsx
Marco Pedone 280e0ab5c2 feat: update payment recap links and add new receipt page
- Changed payment recap link in OrdiniModal to point to the new receipt page.
- Added new PaymentRecapPage for displaying receipt details.
- Updated PaymentsTable to set paid_at date based on payment status.
- Introduced manual payment type in PaymentType and updated related strings.
- Refactored getOrdineRicevutaData to use overridableProcedure for access control.
- Enhanced mail sending functionality to include PDF attachments for receipts and conditions.
- Updated PDF generation service to handle new receipt PDF generation.
- Cleaned up context checking utilities by removing unnecessary session checks.
2026-03-04 19:12:01 +01:00

93 lines
2.2 KiB
TypeScript

import type { GetServerSideProps } from "next";
import { AreaRiservataLayout } from "~/components/Layout";
import { LoadingPage } from "~/components/loading";
import { Status500 } from "~/components/status-page";
import type { NextPageWithLayout } from "~/pages/_app";
import type { TestiEStringheStingaId } from "~/schemas/public/TestiEStringhe";
import { generateSSGHelper } from "~/server/utils/ssgHelper";
import { zTestiEStringheStingaId } from "~/server/utils/zod_types";
import { api } from "~/utils/api";
type CondizioniProps = {
stringaId: TestiEStringheStingaId;
};
const CondizioniPage: NextPageWithLayout<CondizioniProps> = ({
stringaId,
}: CondizioniProps) => {
const { data, isLoading } = api.strings.getStringa.useQuery({
stringaId,
});
if (isLoading) {
return <LoadingPage />;
}
if (!data) {
return <Status500 />;
}
return (
<div className="w-full grow space-y-4 p-4 text-foreground sm:p-6">
{data && (
<div
className="prose dark:prose-invert mx-auto max-w-5xl"
dangerouslySetInnerHTML={{ __html: data.stringa_value || "" }}
/>
)}
</div>
);
};
CondizioniPage.getLayout = function getLayout(page) {
if (page.props.raw) {
return <>{page}</>;
}
return <AreaRiservataLayout noSidebar>{page}</AreaRiservataLayout>;
};
export default CondizioniPage;
export const getServerSideProps = (async (context) => {
const id = context.params?.stringaId;
const raw = context.query?.raw;
if (typeof id !== "string") {
console.error("Error: stringaId is not a string");
return {
redirect: {
destination: "/500",
permanent: false,
},
};
}
const parsed = zTestiEStringheStingaId.safeParse(id);
if (!parsed.success) {
console.error("Error parsing paymentId", parsed.error);
return {
redirect: {
destination: "/500",
permanent: false,
},
};
}
const helper = generateSSGHelper();
if (helper) {
await helper.strings.getStringa.prefetch({
stringaId: parsed.data,
});
return {
props: {
raw: raw === "true",
stringaId: parsed.data,
trpcState: helper.dehydrate(),
},
};
}
return {
redirect: {
destination: "/500",
permanent: false,
},
};
}) satisfies GetServerSideProps<CondizioniProps>;