'use client'; import { useState, useEffect } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { useRouter } from 'next/navigation'; import Link from 'next/link'; import { PlusCircle, Building, Home, DollarSign, MapPin, Bed, Bath, Square, Edit, Trash2, Eye, Calendar, TrendingUp, Users, FileText, Image as ImageIcon, CheckCircle, XCircle, AlertCircle, ChevronRight, ChevronLeft, Loader2, Clock, Wifi, Zap, Flame, Droplets, Cigarette, Dog, Music, Sofa, DoorOpen, Warehouse, Layers, Wind, Pencil, Save, X } from 'lucide-react'; import toast, { Toaster } from 'react-hot-toast'; const DeleteConfirmationModal = ({ isOpen, onClose, onConfirm, propertyTitle }) => { if (!isOpen) return null; return ( e.stopPropagation()} >

تأكيد الحذف

هل أنت متأكد من حذف العقار: "{propertyTitle}"؟

هذا الإجراء لا يمكن التراجع عنه

); }; const PropertyViewModal = ({ isOpen, onClose, property }) => { if (!isOpen || !property) return null; const getServiceIcon = (serviceId) => { const icons = { electricity: Zap, internet: Wifi, heating: Flame, water: Droplets, airConditioning: Wind, parking: Warehouse, elevator: Layers }; const Icon = icons[serviceId]; return Icon ? : null; }; return ( e.stopPropagation()} >

{property.title}

تم الإضافة: {new Date(property.createdAt).toLocaleDateString('ar-SA')}

{property.images && property.images.length > 0 && (

صور العقار

{property.images.map((image, index) => (
{`${property.title}
))}
)}

معلومات أساسية

نوع العقار: {property.propertyType === 'apartment' ? 'شقة' : property.propertyType === 'villa' ? 'فيلا' : property.propertyType === 'suite' ? 'سويت' : 'غرفة ضمن شقة'}

الحالة: {property.furnished ? 'مفروش' : 'غير مفروش'}

حالة العقار: {property.status === 'available' ? 'متاح' : 'مؤجر'}

{property.description && (

الوصف: {property.description}

)}

التفاصيل

{property.bedrooms} غرف
{property.bathrooms} حمامات
{property.area} م²
{property.livingRooms && (
{property.livingRooms} صالونات
)}

الموقع

{property.address || 'لم يتم تحديد العنوان'} {property.city && `، ${property.city}`} {property.district && `، ${property.district}`}

{property.services && Object.values(property.services).some(v => v) && (

الخدمات المتوفرة

{Object.entries(property.services).map(([key, value]) => { if (!value) return null; const Icon = getServiceIcon(key); return ( {Icon} {key === 'electricity' && 'كهرباء'} {key === 'internet' && 'انترنت'} {key === 'heating' && 'تدفئة'} {key === 'water' && 'ماء'} {key === 'airConditioning' && 'تكييف'} {key === 'parking' && 'موقف سيارات'} {key === 'elevator' && 'مصعد'} ); })}
)} {property.terms && Object.values(property.terms).some(v => v) && (

شروط الاستخدام

{Object.entries(property.terms).map(([key, value]) => { if (!value) return null; return ( {key === 'noSmoking' && ' ممنوع التدخين'} {key === 'noPets' && ' ممنوع الحيوانات'} {key === 'noParties' && ' ممنوع الحفلات'} {key === 'noAlcohol' && ' ممنوع الكحول'} {key === 'suitableForChildren' && ' مناسب للأطفال'} {key === 'suitableForElderly' && ' مناسب لكبار السن'} ); })}
)}

معلومات السعر

{property.purpose === 'rent' ? (
{property.dailyPrice && (

السعر اليومي: {Number(property.dailyPrice).toLocaleString()} ل.س

)} {property.monthlyPrice && (

السعر الشهري: {Number(property.monthlyPrice).toLocaleString()} ل.س

)}

نوع الإيجار: { property.rentType === 'daily' ? 'يومي' : property.rentType === 'monthly' ? 'شهري' : 'يومي وشهري' }

) : (

سعر البيع: {Number(property.salePrice).toLocaleString()} ل.س

)}
); }; const PropertyEditModal = ({ isOpen, onClose, property, onSave }) => { const [formData, setFormData] = useState({ ...property }); const [isSaving, setIsSaving] = useState(false); const [editingField, setEditingField] = useState(null); const [tempValues, setTempValues] = useState({}); const sections = [ { title: 'معلومات أساسية', fields: [ { id: 'title', label: 'عنوان العقار', type: 'text' }, { id: 'description', label: 'الوصف', type: 'textarea' }, { id: 'propertyType', label: 'نوع العقار', type: 'select', options: [ { value: 'apartment', label: 'شقة' }, { value: 'villa', label: 'فيلا' }, { value: 'suite', label: 'سويت' }, { value: 'room', label: 'غرفة ضمن شقة' } ], }, { id: 'furnished', label: 'حالة العقار', type: 'radio', options: [ { value: true, label: 'مفروش' }, { value: false, label: 'غير مفروش' } ], } ] }, { title: 'التفاصيل', fields: [ { id: 'bedrooms', label: 'عدد الغرف', type: 'number' }, { id: 'bathrooms', label: 'عدد الحمامات', type: 'number' }, { id: 'livingRooms', label: 'عدد الصالونات', type: 'number' }, { id: 'area', label: 'المساحة (م²)', type: 'number' } ] }, { title: 'الموقع', fields: [ { id: 'address', label: 'العنوان الكامل', type: 'text' }, { id: 'city', label: 'المدينة', type: 'text' }, { id: 'district', label: 'الحي', type: 'text' } ] }, { title: 'السعر', fields: formData?.purpose === 'rent' ? [ { id: 'dailyPrice', label: 'السعر اليومي', type: 'number' }, { id: 'monthlyPrice', label: 'السعر الشهري', type: 'number' }, { id: 'rentType', label: 'نوع الإيجار', type: 'select', options: [ { value: 'daily', label: 'يومي' }, { value: 'monthly', label: 'شهري' }, { value: 'both', label: 'يومي وشهري' } ], } ] : [ { id: 'salePrice', label: 'سعر البيع', type: 'number' } ] } ]; const startEditing = (fieldId) => { setEditingField(fieldId); setTempValues({ ...tempValues, [fieldId]: formData[fieldId] }); }; const cancelEditing = () => { setEditingField(null); setTempValues({}); }; const saveField = (fieldId) => { setFormData({ ...formData, [fieldId]: tempValues[fieldId] }); setEditingField(null); setTempValues({}); const fieldLabel = sections.flatMap(s => s.fields).find(f => f.id === fieldId)?.label; toast.success(`تم تحديث ${fieldLabel}`); }; const handleTempChange = (fieldId, value) => { setTempValues({ ...tempValues, [fieldId]: value }); }; const handleSave = () => { setIsSaving(true); setTimeout(() => { onSave(formData); setIsSaving(false); onClose(); toast.success('تم تحديث العقار بنجاح'); }, 1000); }; if (!isOpen || !property) return null; return ( e.stopPropagation()} >

تعديل العقار

يمكنك تعديل أي حقل بالضغط على أيقونة القلم

{formData.images && formData.images.length > 0 && (

صور العقار

{formData.images.map((image, index) => (
{`Property
))}
)} {sections.map((section, sectionIndex) => (

{section.title}

{section.fields.map((field) => (
{editingField !== field.id && ( )}
{editingField === field.id ? (
{field.type === 'textarea' ? (