diff --git a/app/property/[id]/page.js b/app/property/[id]/page.js index ccaa36f..5dfdeee 100644 --- a/app/property/[id]/page.js +++ b/app/property/[id]/page.js @@ -41,9 +41,11 @@ import { FileText, Printer, Download, - ArrowLeft + ArrowLeft, + LogIn } from 'lucide-react'; import { getRentProperty, getSaleProperty, bookReservation, checkAvailability, getAvailableDateRanges } from '../../utils/api'; +import AuthService from '../../services/AuthService'; import { BuildingTypeKeys, PropertyStatusKeys, extractCity } from '../../enums'; // Map API response to the UI format @@ -138,6 +140,7 @@ export default function PropertyDetailsPage() { const [availableRanges, setAvailableRanges] = useState([]); const [calendarMonth, setCalendarMonth] = useState(new Date()); const [selectingEnd, setSelectingEnd] = useState(false); + const [showLoginDialog, setShowLoginDialog] = useState(false); useEffect(() => { const id = params.id; @@ -235,6 +238,10 @@ export default function PropertyDetailsPage() { }; const handleCalendarClick = (dateStr) => { + if (!AuthService.isAuthenticated()) { + setShowLoginDialog(true); + return; + } if (!isDateAvailable(dateStr)) return; if (!bookingDates.start || selectingEnd) { @@ -269,6 +276,11 @@ export default function PropertyDetailsPage() { const dayNames = ['أح', 'إث', 'ثل', 'أر', 'خم', 'جم', 'سب']; const handleBooking = async () => { + if (!AuthService.isAuthenticated()) { + setShowLoginDialog(true); + return; + } + setBookingError(null); setBookingSuccess(false); @@ -785,6 +797,44 @@ export default function PropertyDetailsPage() { + + {/* Login/Register Dialog */} + {showLoginDialog && ( +
يجب عليك إنشاء حساب أو تسجيل الدخول لحجز هذا العقار
+