diff --git a/app/owner/properties/add/page.js b/app/owner/properties/add/page.js index ce74496..0620a49 100644 --- a/app/owner/properties/add/page.js +++ b/app/owner/properties/add/page.js @@ -99,22 +99,21 @@ export default function AddPropertyPage() { livingRooms: 1, services: { - electricity: false, - internet: false, - heating: false, - water: false, - airConditioning: false, - parking: false, - elevator: false + [PropertyService.ELECTRICITY]: false, + [PropertyService.INTERNET]: false, + [PropertyService.HEATING]: false, + [PropertyService.WATER]: false, + [PropertyService.CENTRAL_AIR_CONDITIONING]: false, + [PropertyService.PARKING]: false, + [PropertyService.ELEVATOR]: false }, + serviceDetails: {}, + terms: { - noSmoking: false, - noPets: false, - noParties: false, - noAlcohol: false, - suitableForChildren: true, - suitableForElderly: true + [PropertyTerm.NO_SMOKING]: false, + [PropertyTerm.NO_ANIMALS]: false, + [PropertyTerm.NO_PARTIES]: false }, offerType: 'daily', @@ -831,34 +830,37 @@ const handleMapClick = async (coords) => {
-

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

-
+

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

+
{serviceList.map((service) => { const Icon = service.icon; + const isSelected = formData.services[service.id]; return ( - +
+ + {isSelected && ( +
+ updateServiceDetail(service.id, e.target.value)} + className="w-full px-3 py-2 border border-gray-200 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-amber-500" + placeholder="تفاصيل الخدمة (مثال: في جميع الغرف)" + /> +
+ )} +
); })}
diff --git a/app/owner/properties/page.js b/app/owner/properties/page.js index 63302cc..ede78f4 100644 --- a/app/owner/properties/page.js +++ b/app/owner/properties/page.js @@ -746,7 +746,11 @@ export default function OwnerPropertiesPage() { area: info.space || 0, livingRooms: details.livingRooms || 0, status: { 0: 'available', 1: 'booked', 2: 'maintenance' }[info.status] || 'available', - images: ['/property-placeholder.jpg'], + images: (() => { + const apiBase = typeof window !== 'undefined' ? (process.env.NEXT_PUBLIC_API_URL || 'http://45.93.137.91/api') : ''; + const raw = Array.isArray(info.images) ? info.images : []; + return raw.length > 0 ? raw.map(img => img.startsWith('http') ? img : `${apiBase}${img}`) : ['/property-placeholder.jpg']; + })(), createdAt: item.createdAt || new Date().toISOString(), furnished: details.furnished || false, description: info.description || '', diff --git a/app/page.js b/app/page.js index a7505e4..8598a30 100644 --- a/app/page.js +++ b/app/page.js @@ -51,6 +51,13 @@ function mapApiProperty(item, index) { if (info.numberOfBedRooms) features.push(`${info.numberOfBedRooms} غرف نوم`); if (info.numberOfBathRooms) features.push(`${info.numberOfBathRooms} حمامات`); + // Extract images from API and build full URLs + const apiBase = typeof window !== 'undefined' ? (process.env.NEXT_PUBLIC_API_URL || 'http://45.93.137.91/api') : ''; + const rawImages = Array.isArray(info.images) ? info.images : []; + const images = rawImages.length > 0 + ? rawImages.map(img => img.startsWith('http') ? img : `${apiBase}${img}`) + : ['/property-placeholder.jpg']; + return { id: item.id ?? index + 1, title: info.address || `عقار #${item.id || index + 1}`, @@ -70,7 +77,7 @@ function mapApiProperty(item, index) { bathrooms: info.numberOfBathRooms || 0, area: info.space || 0, features, - images: ['/property-placeholder.jpg'], + images, status, rating: item.rating || 4.5, isNew: false, diff --git a/app/properties/page.js b/app/properties/page.js index ad186ec..eb20922 100644 --- a/app/properties/page.js +++ b/app/properties/page.js @@ -53,6 +53,13 @@ function mapApiProperty(item, index) { if (info.numberOfBedRooms) features.push(`${info.numberOfBedRooms} غرف نوم`); if (info.numberOfBathRooms) features.push(`${info.numberOfBathRooms} حمامات`); + // Extract images from API and build full URLs + const apiBase = typeof window !== 'undefined' ? (process.env.NEXT_PUBLIC_API_URL || 'http://45.93.137.91/api') : ''; + const rawImages = Array.isArray(info.images) ? info.images : []; + const images = rawImages.length > 0 + ? rawImages.map(img => img.startsWith('http') ? img : `${apiBase}${img}`) + : ['/property-placeholder.jpg']; + return { id: item.id ?? index + 1, title: info.address || `عقار #${item.id || index + 1}`, @@ -68,7 +75,7 @@ function mapApiProperty(item, index) { bathrooms: info.numberOfBathRooms || 0, area: info.space || 0, features, - images: ['/property-placeholder.jpg'], + images, status, rating: item.rating || 4.5, isNew: false, diff --git a/app/property/[id]/page.js b/app/property/[id]/page.js index c93b741..b6bb4aa 100644 --- a/app/property/[id]/page.js +++ b/app/property/[id]/page.js @@ -70,6 +70,13 @@ function mapApiDetail(item) { const typeLabels = { 0: 'شقة', 1: 'فيلا', 2: 'بيت' }; + // Extract images from API and build full URLs + const apiBase = typeof window !== 'undefined' ? (process.env.NEXT_PUBLIC_API_URL || 'http://45.93.137.91/api') : ''; + const rawImages = Array.isArray(info.images) ? info.images : []; + const images = rawImages.length > 0 + ? rawImages.map(img => img.startsWith('http') ? img : `${apiBase}${img}`) + : ['/property-placeholder.jpg', '/villa1.jpg', '/villa2.jpg']; + return { id: item.id, title: info.address || `عقار #${item.id}`, @@ -90,7 +97,7 @@ function mapApiDetail(item) { features: features.length > 0 ? features : [ { name: 'متاح للإيجار', available: true, description: '' }, ], - images: ['/property-placeholder.jpg', '/villa1.jpg', '/villa2.jpg'], + images, status, rating: item.rating || 4.5, reviews: 0,