diff --git a/apps/edr-passenger-api/src/modules/auth/auth.controller.ts b/apps/edr-passenger-api/src/modules/auth/auth.controller.ts index 4d091656f..33976f22f 100644 --- a/apps/edr-passenger-api/src/modules/auth/auth.controller.ts +++ b/apps/edr-passenger-api/src/modules/auth/auth.controller.ts @@ -137,6 +137,9 @@ export class AuthController { - **Loyalty Account**: Tier, points balance, lifetime points - **Wallet Account**: Balance (minor units), currency +#### Devices +- List of registered devices with platform, name, push token, and last seen time + #### User Preferences - Language, notification settings, etc. @@ -154,6 +157,8 @@ export class AuthController { 5. **Wallet Balance**: Display available balance +6. **Device Management**: Get list of user's registered devices + --- ### Authentication @@ -196,7 +201,25 @@ export class AuthController { emailNotifications: true, smsNotifications: true, language: 'am' - } + }, + devices: [ + { + id: 'device-uuid-1', + platform: 'WEB', + name: 'Chrome on Windows', + pushToken: 'token-abc123', + trusted: true, + lastSeenAt: '2024-01-20T14:22:00.000Z' + }, + { + id: 'device-uuid-2', + platform: 'IOS', + name: 'iPhone 14', + pushToken: 'token-xyz789', + trusted: false, + lastSeenAt: '2024-01-19T10:15:00.000Z' + } + ] } } }) diff --git a/apps/edr-passenger-api/src/modules/auth/auth.service.ts b/apps/edr-passenger-api/src/modules/auth/auth.service.ts index 74bd3f79b..931db07b5 100644 --- a/apps/edr-passenger-api/src/modules/auth/auth.service.ts +++ b/apps/edr-passenger-api/src/modules/auth/auth.service.ts @@ -180,6 +180,7 @@ export class AuthService { }, }, preferences: true, + devices: true, }, }); @@ -213,6 +214,14 @@ export class AuthService { } : null, } : null, preferences: user.preferences, + devices: user.devices.map(device => ({ + id: device.id, + platform: device.platform, + name: device.name, + pushToken: device.pushToken, + trusted: device.trusted, + lastSeenAt: device.lastSeenAt, + })), }; } diff --git a/apps/edr-passenger-api/src/modules/seats/seats.service.ts b/apps/edr-passenger-api/src/modules/seats/seats.service.ts index c625fada6..b1b1a3af3 100644 --- a/apps/edr-passenger-api/src/modules/seats/seats.service.ts +++ b/apps/edr-passenger-api/src/modules/seats/seats.service.ts @@ -485,8 +485,15 @@ export class SeatsService { async expireHolds() { const expired = await this.prisma.seatHold.findMany({ where: { expiresAt: { lt: new Date() } } }); for (const hold of expired) { - await this.releaseSeats(hold.seatIds); - await this.prisma.seatHold.delete({ where: { id: hold.id } }); + await this.releaseSeats(hold.seatIds); + try { + await this.prisma.seatHold.delete({ where: { id: hold.id } }); + } catch (err) { + // Ignore if already deleted (e.g., by another process) + if (err instanceof Error && !err.message.includes('P2025')) { + throw err; + } + } } } } diff --git a/apps/edr-passenger-web/portal/src/app/booking/confirmation/page.tsx b/apps/edr-passenger-web/portal/src/app/booking/confirmation/page.tsx index cbaac5fb3..1a36ac04b 100644 --- a/apps/edr-passenger-web/portal/src/app/booking/confirmation/page.tsx +++ b/apps/edr-passenger-web/portal/src/app/booking/confirmation/page.tsx @@ -11,6 +11,17 @@ import { CheckCircle, Download, Share2, Copy, Printer, Mail, Train } from 'lucid import { QRCodeSVG } from 'qrcode.react'; import { format } from 'date-fns'; +type BookingWithTicket = { + id: string; + pnr?: string | null; + status?: string; + totalMinor?: number; + ticket?: { + barcodePayload?: string; + qrPayload?: string; + }; +}; + export default function ConfirmationPage() { const router = useRouter(); const { bookingId, pnr, selectedSchedule, passengers, clearBooking } = useBookingStore(); @@ -21,16 +32,16 @@ export default function ConfirmationPage() { mutationFn: () => apiClient.patch(`/bookings/${bookingId}/confirm`, { status: 'SUCCEEDED' }), }); - const { data: _booking } = useQuery({ + const { data: _booking } = useQuery({ queryKey: ['booking', bookingId], - queryFn: async () => { + queryFn: async (): Promise => { try { return await apiClient.get(`/bookings/${bookingId}`); } catch (error) { console.log('Booking API not available, using local data'); return { - id: bookingId, - pnr, + id: bookingId || '', + pnr: pnr || undefined, status: 'CONFIRMED', totalMinor: passengers.reduce((sum) => sum + (selectedSchedule?.baseFareAdult || 0), 0), };