@@ -294,13 +366,18 @@ const PropertyViewModal = ({ isOpen, onClose, property }) => {
{Object.entries(property.terms).map(([key, value]) => {
if (!value) return null;
return (
-
- {key.startsWith('No') || key.startsWith('Only') ? (
+
+ {key.startsWith("No") || key.startsWith("Only") ? (
) : (
)}
- {termLabels[key] || key}
+
+ {termLabels[key] || key}
+
);
})}
@@ -310,43 +387,56 @@ const PropertyViewModal = ({ isOpen, onClose, property }) => {
معلومات السعر
- {property.purpose === 'rent' ? (
+ {property.purpose === "rent" ? (
{property.dailyPrice > 0 && (
السعر اليومي:
- {Number(property.dailyPrice).toLocaleString()} ل.س
+
+ {Number(property.dailyPrice).toLocaleString()} ل.س
+
)}
{property.monthlyPrice > 0 && (
السعر الشهري:
- {Number(property.monthlyPrice).toLocaleString()} ل.س
+
+ {Number(property.monthlyPrice).toLocaleString()} ل.س
+
)}
{property.deposit > 0 && (
التأمين:
- {Number(property.deposit).toLocaleString()} ل.س
+
+ {Number(property.deposit).toLocaleString()} ل.س
+
)}
- نوع الإيجار: {
- property.rentType === 'daily' ? 'يومي' :
- property.rentType === 'monthly' ? 'شهري' : 'يومي وشهري'
- }
+ نوع الإيجار:{" "}
+ {property.rentType === "daily"
+ ? "يومي"
+ : property.rentType === "monthly"
+ ? "شهري"
+ : "يومي وشهري"}
{property.rating > 0 && (
التقييم:
- {Number(property.rating).toFixed(1)}
+
+ {Number(property.rating).toFixed(1)}{" "}
+
+
)}
) : (
سعر البيع:
- {Number(property.salePrice).toLocaleString()} ل.س
+
+ {Number(property.salePrice).toLocaleString()} ل.س
+
)}
@@ -364,70 +454,69 @@ const PropertyEditModal = ({ isOpen, onClose, property, onSave }) => {
const sections = [
{
- title: 'معلومات أساسية',
+ title: "معلومات أساسية",
fields: [
- { id: 'title', label: 'عنوان العقار', type: 'text' },
- { id: 'description', label: 'الوصف', type: 'textarea' },
- {
- id: 'propertyType',
- label: 'نوع العقار',
- type: 'select',
+ { 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: 'غرفة ضمن شقة' }
- ],
-
+ { value: "apartment", label: "شقة" },
+ { value: "villa", label: "فيلا" },
+ { value: "suite", label: "سويت" },
+ { value: "room", label: "غرفة ضمن شقة" },
+ ],
},
- {
- id: 'furnished',
- label: 'حالة العقار',
- type: 'radio',
+ {
+ id: "furnished",
+ label: "حالة العقار",
+ type: "radio",
options: [
- { value: true, label: 'مفروش' },
- { value: false, label: 'غير مفروش' }
- ],
-
- }
- ]
+ { value: true, label: "مفروش" },
+ { value: false, label: "غير مفروش" },
+ ],
+ },
+ ],
},
{
- title: 'التفاصيل',
+ title: "التفاصيل",
fields: [
- { id: 'bedrooms', label: 'عدد الغرف', type: 'number' },
- { id: 'bathrooms', label: 'عدد الحمامات', type: 'number' },
- { id: 'livingRooms', label: 'عدد الصالونات', type: 'number' },
- { id: 'area', label: 'المساحة (م²)', type: 'number' }
- ]
+ { id: "bedrooms", label: "عدد الغرف", type: "number" },
+ { id: "bathrooms", label: "عدد الحمامات", type: "number" },
+ { id: "livingRooms", label: "عدد الصالونات", type: "number" },
+ { id: "area", label: "المساحة (م²)", type: "number" },
+ ],
},
{
- title: 'الموقع',
+ title: "الموقع",
fields: [
- { id: 'address', label: 'العنوان الكامل', type: 'text' },
- { id: 'city', label: 'المدينة', type: 'text' },
- { id: 'district', label: 'الحي', type: 'text' }
- ]
+ { 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' }
- ]
- }
+ 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) => {
@@ -443,11 +532,13 @@ const PropertyEditModal = ({ isOpen, onClose, property, onSave }) => {
const saveField = (fieldId) => {
setFormData({
...formData,
- [fieldId]: tempValues[fieldId]
+ [fieldId]: tempValues[fieldId],
});
setEditingField(null);
setTempValues({});
- const fieldLabel = sections.flatMap(s => s.fields).find(f => f.id === fieldId)?.label;
+ const fieldLabel = sections
+ .flatMap((s) => s.fields)
+ .find((f) => f.id === fieldId)?.label;
toast.success(`تم تحديث ${fieldLabel}`);
};
@@ -457,12 +548,12 @@ const PropertyEditModal = ({ isOpen, onClose, property, onSave }) => {
const handleSave = () => {
setIsSaving(true);
-
+
setTimeout(() => {
onSave(formData);
setIsSaving(false);
onClose();
- toast.success('تم تحديث العقار بنجاح');
+ toast.success("تم تحديث العقار بنجاح");
}, 1000);
};
@@ -486,7 +577,9 @@ const PropertyEditModal = ({ isOpen, onClose, property, onSave }) => {
تعديل العقار
-
قم بتحديث معلومات العقار
+
+ قم بتحديث معلومات العقار
+