'use client'; import { useState } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { Edit, Trash2, Eye, MapPin, Bed, Bath, Square, DollarSign, Percent, MoreVertical, X, CheckCircle, AlertCircle, Calendar, User, Home, Building, Clock } 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 = ({ property, isOpen, onClose }) => { if (!isOpen || !property) return null; const formatCurrency = (amount) => { return amount?.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + ' ل.س'; }; return ( e.stopPropagation()} >

{property.title}

{property.location}

{property.type === 'villa' ? 'فيلا' : property.type === 'apartment' ? 'شقة' : 'بيت'}
نوع العقار
{formatCurrency(property.price)}
السعر اليومي
{property.commission}%
نسبة العمولة
{property.bookings || 0}
عدد الحجوزات

الموقع

{property.location}

المواصفات

{property.bedrooms}
غرف نوم
{property.bathrooms}
حمامات
{property.area}
م²

معلومات العمولة

{property.commission}%
{property.commissionType}
{formatCurrency((property.price * property.commission) / 100)}
{property.status === 'available' ? 'متاح' : 'محجوز'}
); }; const PropertyEditModal = ({ property, isOpen, onClose, onSave }) => { const [formData, setFormData] = useState({ ...property }); const [isSaving, setIsSaving] = useState(false); const formatCurrency = (amount) => { return amount?.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); }; const handleSave = () => { setIsSaving(true); setTimeout(() => { onSave(formData); setIsSaving(false); onClose(); toast.success('تم تحديث العقار بنجاح'); }, 1000); }; if (!isOpen || !property) return null; return ( e.stopPropagation()} >

تعديل العقار

يمكنك تعديل معلومات العقار

setFormData({...formData, title: e.target.value})} className="w-full px-4 py-3 border border-gray-300 rounded-xl focus:ring-2 focus:ring-amber-500" />
setFormData({...formData, location: e.target.value})} className="w-full px-4 py-3 border border-gray-300 rounded-xl focus:ring-2 focus:ring-amber-500" />
setFormData({...formData, price: parseInt(e.target.value)})} className="w-full px-4 py-3 border border-gray-300 rounded-xl focus:ring-2 focus:ring-amber-500" />
setFormData({...formData, commission: parseFloat(e.target.value)})} className="w-full px-4 py-3 border border-gray-300 rounded-xl focus:ring-2 focus:ring-amber-500" />
setFormData({...formData, bedrooms: parseInt(e.target.value)})} className="w-full px-4 py-3 border border-gray-300 rounded-xl focus:ring-2 focus:ring-amber-500" />
setFormData({...formData, bathrooms: parseInt(e.target.value)})} className="w-full px-4 py-3 border border-gray-300 rounded-xl focus:ring-2 focus:ring-amber-500" />
setFormData({...formData, area: parseInt(e.target.value)})} className="w-full px-4 py-3 border border-gray-300 rounded-xl focus:ring-2 focus:ring-amber-500" />
); }; const MoreActionsMenu = ({ property, isOpen, onClose, onViewBookings, onViewReports }) => { if (!isOpen) return null; return ( <>
); }; export default function PropertiesTable() { const [properties, setProperties] = useState([ { id: 1, title: 'فيلا فاخرة في المزة', type: 'villa', location: 'دمشق, المزة', price: 500000, commission: 5, commissionType: 'من المالك', bedrooms: 5, bathrooms: 4, area: 450, status: 'available', bookings: 3 }, { id: 2, title: 'شقة حديثة في الشهباء', type: 'apartment', location: 'حلب, الشهباء', price: 250000, commission: 7, commissionType: 'من المستأجر', bedrooms: 3, bathrooms: 2, area: 180, status: 'booked', bookings: 1 } ]); const [viewModal, setViewModal] = useState({ isOpen: false, property: null }); const [editModal, setEditModal] = useState({ isOpen: false, property: null }); const [deleteModal, setDeleteModal] = useState({ isOpen: false, property: null }); const [moreMenu, setMoreMenu] = useState({ isOpen: false, property: null, anchorEl: null }); const formatCurrency = (amount) => { return amount.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") + ' ل.س'; }; const getStatusBadge = (status) => { const styles = { available: 'bg-green-100 text-green-800', booked: 'bg-red-100 text-red-800', maintenance: 'bg-yellow-100 text-yellow-800' }; const labels = { available: 'متاح', booked: 'محجوز', maintenance: 'صيانة' }; return ( {labels[status]} ); }; const handleView = (property) => { setViewModal({ isOpen: true, property }); }; const handleEdit = (property) => { setEditModal({ isOpen: true, property }); }; const handleDelete = (property) => { setDeleteModal({ isOpen: true, property }); }; const confirmDelete = () => { if (deleteModal.property) { setProperties(prev => prev.filter(p => p.id !== deleteModal.property.id)); setDeleteModal({ isOpen: false, property: null }); toast.success('تم حذف العقار بنجاح'); } }; const handleSaveEdit = (updatedProperty) => { setProperties(prev => prev.map(p => p.id === updatedProperty.id ? updatedProperty : p )); toast.success('تم تحديث العقار بنجاح'); }; const handleMoreClick = (event, property) => { event.stopPropagation(); setMoreMenu({ isOpen: true, property, anchorEl: event.currentTarget }); }; const handleViewBookings = (property) => { toast.success(`جاري عرض حجوزات ${property.title}`); }; const handleViewReports = (property) => { toast.success(`جاري عرض تقرير أرباح ${property.title}`); }; return (
{properties.map((property, index) => ( ))}
العقار الموقع السعر/يوم العمولة المصدر التفاصيل الحالة الإجراءات
{property.title}
{property.type === 'villa' ? 'فيلا' : property.type === 'apartment' ? 'شقة' : property.type === 'house' ? 'بيت' : 'استوديو'}
{property.location}
{formatCurrency(property.price)}
{property.commission}%
{property.commissionType}
{property.bedrooms} {property.bathrooms} {property.area}m²
{getStatusBadge(property.status)}
{moreMenu.isOpen && moreMenu.property?.id === property.id && ( setMoreMenu({ isOpen: false, property: null, anchorEl: null })} onViewBookings={handleViewBookings} onViewReports={handleViewReports} /> )}
{properties.length === 0 && (

لا توجد عقارات مضافة بعد

)} setViewModal({ isOpen: false, property: null })} /> setEditModal({ isOpen: false, property: null })} onSave={handleSaveEdit} /> setDeleteModal({ isOpen: false, property: null })} onConfirm={confirmDelete} propertyTitle={deleteModal.property?.title} />
); }