mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 11:08:12 +00:00
Add device management to user profile and enhance seat hold expiration handling
This commit is contained in:
@@ -137,6 +137,9 @@ export class AuthController {
|
|||||||
- **Loyalty Account**: Tier, points balance, lifetime points
|
- **Loyalty Account**: Tier, points balance, lifetime points
|
||||||
- **Wallet Account**: Balance (minor units), currency
|
- **Wallet Account**: Balance (minor units), currency
|
||||||
|
|
||||||
|
#### Devices
|
||||||
|
- List of registered devices with platform, name, push token, and last seen time
|
||||||
|
|
||||||
#### User Preferences
|
#### User Preferences
|
||||||
- Language, notification settings, etc.
|
- Language, notification settings, etc.
|
||||||
|
|
||||||
@@ -154,6 +157,8 @@ export class AuthController {
|
|||||||
|
|
||||||
5. **Wallet Balance**: Display available balance
|
5. **Wallet Balance**: Display available balance
|
||||||
|
|
||||||
|
6. **Device Management**: Get list of user's registered devices
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Authentication
|
### Authentication
|
||||||
@@ -196,7 +201,25 @@ export class AuthController {
|
|||||||
emailNotifications: true,
|
emailNotifications: true,
|
||||||
smsNotifications: true,
|
smsNotifications: true,
|
||||||
language: 'am'
|
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'
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -180,6 +180,7 @@ export class AuthService {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
preferences: true,
|
preferences: true,
|
||||||
|
devices: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -213,6 +214,14 @@ export class AuthService {
|
|||||||
} : null,
|
} : null,
|
||||||
} : null,
|
} : null,
|
||||||
preferences: user.preferences,
|
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,
|
||||||
|
})),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -485,8 +485,15 @@ export class SeatsService {
|
|||||||
async expireHolds() {
|
async expireHolds() {
|
||||||
const expired = await this.prisma.seatHold.findMany({ where: { expiresAt: { lt: new Date() } } });
|
const expired = await this.prisma.seatHold.findMany({ where: { expiresAt: { lt: new Date() } } });
|
||||||
for (const hold of expired) {
|
for (const hold of expired) {
|
||||||
await this.releaseSeats(hold.seatIds);
|
await this.releaseSeats(hold.seatIds);
|
||||||
await this.prisma.seatHold.delete({ where: { id: hold.id } });
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,17 @@ import { CheckCircle, Download, Share2, Copy, Printer, Mail, Train } from 'lucid
|
|||||||
import { QRCodeSVG } from 'qrcode.react';
|
import { QRCodeSVG } from 'qrcode.react';
|
||||||
import { format } from 'date-fns';
|
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() {
|
export default function ConfirmationPage() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { bookingId, pnr, selectedSchedule, passengers, clearBooking } = useBookingStore();
|
const { bookingId, pnr, selectedSchedule, passengers, clearBooking } = useBookingStore();
|
||||||
@@ -21,16 +32,16 @@ export default function ConfirmationPage() {
|
|||||||
mutationFn: () => apiClient.patch(`/bookings/${bookingId}/confirm`, { status: 'SUCCEEDED' }),
|
mutationFn: () => apiClient.patch(`/bookings/${bookingId}/confirm`, { status: 'SUCCEEDED' }),
|
||||||
});
|
});
|
||||||
|
|
||||||
const { data: _booking } = useQuery({
|
const { data: _booking } = useQuery<BookingWithTicket>({
|
||||||
queryKey: ['booking', bookingId],
|
queryKey: ['booking', bookingId],
|
||||||
queryFn: async () => {
|
queryFn: async (): Promise<BookingWithTicket> => {
|
||||||
try {
|
try {
|
||||||
return await apiClient.get(`/bookings/${bookingId}`);
|
return await apiClient.get(`/bookings/${bookingId}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('Booking API not available, using local data');
|
console.log('Booking API not available, using local data');
|
||||||
return {
|
return {
|
||||||
id: bookingId,
|
id: bookingId || '',
|
||||||
pnr,
|
pnr: pnr || undefined,
|
||||||
status: 'CONFIRMED',
|
status: 'CONFIRMED',
|
||||||
totalMinor: passengers.reduce((sum) => sum + (selectedSchedule?.baseFareAdult || 0), 0),
|
totalMinor: passengers.reduce((sum) => sum + (selectedSchedule?.baseFareAdult || 0), 0),
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user