Use admin timezone for emails and ticket PDFs
- Email: formatDate/formatTime use site timezone from settings - PDF tickets: date/time formatted in site timezone - Tickets routes: fetch timezone and pass to PDF generation
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Hono } from 'hono';
|
||||
import { zValidator } from '@hono/zod-validator';
|
||||
import { z } from 'zod';
|
||||
import { db, dbGet, dbAll, tickets, events, users, payments, paymentOptions } from '../db/index.js';
|
||||
import { db, dbGet, dbAll, tickets, events, users, payments, paymentOptions, siteSettings } from '../db/index.js';
|
||||
import { eq, and, sql } from 'drizzle-orm';
|
||||
import { requireAuth, getAuthUser } from '../lib/auth.js';
|
||||
import { generateId, generateTicketCode, getNow } from '../lib/utils.js';
|
||||
@@ -378,6 +378,12 @@ ticketsRouter.get('/booking/:bookingId/pdf', async (c) => {
|
||||
|
||||
console.log(`[PDF] Generating PDF with ${confirmedTickets.length} confirmed tickets`);
|
||||
|
||||
// Get site timezone for proper date/time formatting
|
||||
const settings = await dbGet<any>(
|
||||
(db as any).select().from(siteSettings).limit(1)
|
||||
);
|
||||
const timezone = settings?.timezone || 'America/Asuncion';
|
||||
|
||||
const ticketsData = confirmedTickets.map((ticket: any) => ({
|
||||
id: ticket.id,
|
||||
qrCode: ticket.qrCode,
|
||||
@@ -390,6 +396,7 @@ ticketsRouter.get('/booking/:bookingId/pdf', async (c) => {
|
||||
location: event.location,
|
||||
locationUrl: event.locationUrl,
|
||||
},
|
||||
timezone,
|
||||
}));
|
||||
|
||||
const pdfBuffer = await generateCombinedTicketsPDF(ticketsData);
|
||||
@@ -448,6 +455,12 @@ ticketsRouter.get('/:id/pdf', async (c) => {
|
||||
}
|
||||
|
||||
try {
|
||||
// Get site timezone for proper date/time formatting
|
||||
const settings = await dbGet<any>(
|
||||
(db as any).select().from(siteSettings).limit(1)
|
||||
);
|
||||
const timezone = settings?.timezone || 'America/Asuncion';
|
||||
|
||||
const pdfBuffer = await generateTicketPDF({
|
||||
id: ticket.id,
|
||||
qrCode: ticket.qrCode,
|
||||
@@ -460,6 +473,7 @@ ticketsRouter.get('/:id/pdf', async (c) => {
|
||||
location: event.location,
|
||||
locationUrl: event.locationUrl,
|
||||
},
|
||||
timezone,
|
||||
});
|
||||
|
||||
// Set response headers for PDF download
|
||||
|
||||
Reference in New Issue
Block a user