diff --git a/client/src/components/layout/Header.js b/client/src/components/layout/Header.js index badb317..d5a86d8 100644 --- a/client/src/components/layout/Header.js +++ b/client/src/components/layout/Header.js @@ -58,7 +58,7 @@ const Header = () => { return () => window.removeEventListener('scroll', handleScroll); }, []); - const lightHeaderRoutes = ['/facilities', '/contact']; + const lightHeaderRoutes = ['/facilities', '/contact', '/booking']; const forceLightHeader = lightHeaderRoutes.some( (r) => location.pathname === r || location.pathname.startsWith(r + '/') ); @@ -119,7 +119,6 @@ const Header = () => { ))} - {/* ✅ بدل واتساب: يروح على صفحة /booking */} { - {/* ✅ بدل واتساب: يروح على صفحة /booking */} { ); }; -export default Header; +export default Header; \ No newline at end of file diff --git a/client/src/pages/Booking.js b/client/src/pages/Booking.js index 7a240a8..be896ba 100644 --- a/client/src/pages/Booking.js +++ b/client/src/pages/Booking.js @@ -39,7 +39,18 @@ const Booking = () => { const loadRooms = async () => { try { const res = await api.get('/api/rooms?limit=100'); - const fetched = res?.data?.data?.rooms || []; + + const rawRooms = + res?.data?.data?.rooms || + res?.data?.data || + res?.data?.rooms || + []; + + const fetched = (Array.isArray(rawRooms) ? rawRooms : []).filter((r) => { + const status = String(r?.status || '').toLowerCase(); + return !status || status === 'active'; + }); + if (mounted) setRooms(fetched); } catch (e) { if (mounted) setMessage({ type: 'error', text: 'Failed to load rooms' }); @@ -108,15 +119,13 @@ const Booking = () => { specialRequests: form.specialRequests }; - // ✅ هذا لازم يكون موجود بالـ CMS: POST /api/bookings/request const res = await api.post('/api/bookings/request', payload); const booking = res?.data?.data?.booking || null; const bookingNumber = booking?.bookingNumber || res?.data?.data?.bookingNumber || null; - const selectedRoom = rooms.find(r => r._id === form.roomId); + const selectedRoom = rooms.find(r => String(r._id || r.id) === String(form.roomId)); - // ✅ معلومات نبعثها لصفحة BookingConfirmation const requestForConfirmation = { fullName: `${form.firstName} ${form.lastName}`.trim(), phone: form.phone, @@ -125,13 +134,12 @@ const Booking = () => { checkOutDate: form.checkOutDate, adults: Number(form.adults), children: Number(form.children || 0), - roomCategory: selectedRoom?.name || '', + roomCategory: selectedRoom?.name || selectedRoom?.title || '', message: form.specialRequests || '', bookingNumber: bookingNumber || '', - autoOpenWhatsApp: true // إذا صفحة الـ Confirmation عندك بتفتح واتساب تلقائيًا + autoOpenWhatsApp: true }; - // ✅ روح على صفحة التأكيد (بدون ما نظل هون) navigate('/booking/confirmation', { state: { request: requestForConfirmation } }); } catch (error) { @@ -182,11 +190,19 @@ const Booking = () => { onChange={handleChange('roomId')} required > - {rooms.map(r => ( - - {r.name} (#{r.roomNumber}) - ${r.basePrice}/night + {rooms.length === 0 ? ( + + No rooms available - ))} + ) : ( + rooms.map((r) => ( + + {(r.name || r.title || 'Room')} + {r.roomNumber ? ` (#${r.roomNumber})` : ''} + {(r.basePrice ?? r.price) != null ? ` - $${r.basePrice ?? r.price}/night` : ''} + + )) + )} { ); }; -export default Booking; +export default Booking; \ No newline at end of file