mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 00:52:50 +00:00
update booking request object
This commit is contained in:
@@ -144,9 +144,14 @@ export default function ReviewPage() {
|
||||
const createBookingMutation = useMutation({
|
||||
mutationFn: (data: any) => {
|
||||
const endpoint = isAuthenticated ? '/bookings' : '/bookings/guest';
|
||||
console.log('=== API REQUEST ===');
|
||||
console.log('Endpoint:', endpoint);
|
||||
console.log('Request Data:', JSON.stringify(data, null, 2));
|
||||
return apiClient.post(endpoint, data);
|
||||
},
|
||||
onSuccess: (data: any) => {
|
||||
console.log('=== API RESPONSE SUCCESS ===');
|
||||
console.log('Response Data:', JSON.stringify(data, null, 2));
|
||||
console.log('Booking created successfully:', data);
|
||||
const bookingIdValue = data.bookingId || data.id;
|
||||
const pnrValue = data.pnr || data.bookingReference || data.bookingRef;
|
||||
@@ -178,7 +183,12 @@ export default function ReviewPage() {
|
||||
}, 100);
|
||||
},
|
||||
onError: (error: any) => {
|
||||
console.error('Booking creation failed:', error);
|
||||
console.log('=== API RESPONSE ERROR ===');
|
||||
console.error('Error Object:', error);
|
||||
console.error('Error Response:', error?.response);
|
||||
console.error('Error Response Data:', JSON.stringify(error?.response?.data, null, 2));
|
||||
console.error('Error Status:', error?.response?.status);
|
||||
console.error('Error Message:', error?.message);
|
||||
const errorMessage = error?.response?.data?.message || error?.message || 'Failed to create booking. Please try again.';
|
||||
alert(errorMessage);
|
||||
},
|
||||
@@ -196,7 +206,7 @@ export default function ReviewPage() {
|
||||
console.log('Inbound schedule:', inboundSchedule);
|
||||
console.log('Passengers:', passengers);
|
||||
|
||||
if (!seatHold?.holdId) {
|
||||
if (!seatHold?.holdId && (passengers.some(p => p.seatId) || passengers.some(p => (p as any).outboundSeatId || (p as any).inboundSeatId))) {
|
||||
console.error('No seat hold found');
|
||||
alert('Please select seats before continuing.');
|
||||
router.push('/booking/seats');
|
||||
@@ -285,6 +295,7 @@ export default function ReviewPage() {
|
||||
const isEthiopian = p.nationality === 'ETHIOPIAN' || p.nationality === 'Ethiopian';
|
||||
return {
|
||||
seatId: isRoundTrip ? (p as any).outboundSeatId : (p.seatId || ''),
|
||||
...(isRoundTrip && { returnSeatId: (p as any).inboundSeatId || '' }),
|
||||
passengerName: p.name,
|
||||
dateOfBirth: p.dateOfBirth,
|
||||
idDocumentType: isEthiopian ? 'NATIONAL_ID' : 'PASSPORT',
|
||||
@@ -323,6 +334,7 @@ export default function ReviewPage() {
|
||||
const isEthiopian = p.nationality === 'ETHIOPIAN' || p.nationality === 'Ethiopian';
|
||||
return {
|
||||
seatId: isRoundTrip ? (p as any).outboundSeatId : (p.seatId || ''),
|
||||
...(isRoundTrip && { returnSeatId: (p as any).inboundSeatId || '' }),
|
||||
passengerName: p.name,
|
||||
dateOfBirth: p.dateOfBirth,
|
||||
idDocumentType: isEthiopian ? 'NATIONAL_ID' : 'PASSPORT',
|
||||
@@ -358,7 +370,8 @@ export default function ReviewPage() {
|
||||
localStorage.setItem('deviceId', bookingData.deviceId);
|
||||
}
|
||||
|
||||
console.log('Creating booking with payload:', bookingData);
|
||||
console.log('Creating booking with payload:', JSON.stringify(bookingData, null, 2));
|
||||
console.log('API endpoint:', isAuthenticated ? '/bookings' : '/bookings/guest');
|
||||
await createBookingMutation.mutateAsync(bookingData);
|
||||
} catch (error) {
|
||||
console.error('Error in handleConfirm:', error);
|
||||
|
||||
Reference in New Issue
Block a user