fixed the details
All checks were successful
Build frontend / build (push) Successful in 43s

This commit is contained in:
mouazkh
2026-05-26 00:20:20 +03:00
parent 085c60ec33
commit 9f6492cf41
4 changed files with 115 additions and 8 deletions

View File

@ -75,7 +75,7 @@ const proximityLabels = {
function mapApiDetail(item) {
if (!item) return null;
const info = item.propertyInformation || {};
const details = (() => { try { return JSON.parse(info.detailsJSON || '{}'); } catch { return {}; } })();
const details = typeof info.detailsJSON === 'object' && info.detailsJSON ? info.detailsJSON : (() => { try { return JSON.parse(info.detailsJSON || '{}'); } catch { return {}; } })();
const isRent = item.dailyRent != null || item.monthlyRent != null;
const dailyPrice = item.dailyRent || 0;
@ -117,6 +117,10 @@ function mapApiDetail(item) {
});
const roomDetails = details.room || details.roomDetails || {};
const displayType = details.displayType || (isRent ? (monthlyPrice && dailyPrice ? 'Both' : monthlyPrice ? 'Monthly' : 'Daily') : 'Sale');
const propertyCondition = details.propertyCondition || '';
const furnished = propertyCondition.toLowerCase().includes('furniture') ? propertyCondition.toLowerCase() === 'withfurniture' : !!item.isFurnished;
return {
id: item.id,
propertyInformationId: info.id,
@ -128,6 +132,9 @@ function mapApiDetail(item) {
priceUnit,
priceDisplay: { daily: dailyPrice, monthly: monthlyPrice, sale: salePrice },
isRent,
displayType,
propertyCondition,
furnished,
location: {
city: extractCity(info.address) || 'دمشق',
address: info.address || '',
@ -374,9 +381,23 @@ export default function PropertyDetailsPage() {
<motion.div initial={{ opacity: 0, y: 20 }} animate={{ opacity: 1, y: 0 }} className="bg-white rounded-2xl p-5 shadow-sm border border-gray-200">
<div className="flex justify-between items-start mb-3">
<div>
<div className="flex items-center gap-2 mb-1">
<div className="flex items-center gap-1.5 mb-1 flex-wrap">
<span className="px-2 py-0.5 bg-amber-100 text-amber-800 rounded-full text-xs">{property.typeLabel}</span>
<span className={`px-2 py-0.5 rounded-full text-xs ${property.status === 'available' ? 'bg-green-100 text-green-800' : 'bg-yellow-100 text-yellow-800'}`}>{property.statusLabel}</span>
{property.isRent && property.displayType && (
<span className="px-2 py-0.5 bg-blue-100 text-blue-800 rounded-full text-xs">
{(() => {
const dt = property.displayType.toLowerCase();
if (dt === 'both' || dt.includes('both')) return 'يومي وشهري';
if (dt.includes('daily')) return 'يومي';
if (dt.includes('monthly')) return 'شهري';
return dt;
})()}
</span>
)}
<span className={`px-2 py-0.5 rounded-full text-xs ${property.furnished ? 'bg-purple-100 text-purple-800' : 'bg-gray-100 text-gray-600'}`}>
{property.furnished ? 'مفروش' : 'غير مفروش'}
</span>
</div>
<h1 className="text-xl font-bold text-gray-900">{property.title}</h1>
<div className="flex items-center gap-1 text-gray-500 text-xs mt-0.5">

View File

@ -19,7 +19,13 @@ async function fetchPropertyForMeta(id) {
function mapProperty(item) {
const info = item.propertyInformation || item.PropertyInformation || {};
let details = {};
try { details = JSON.parse(info.detailsJSON || info.DetailsJSON || '{}'); } catch {}
if (typeof info.detailsJSON === 'object' && info.detailsJSON) {
details = info.detailsJSON;
} else if (typeof info.DetailsJSON === 'object' && info.DetailsJSON) {
details = info.DetailsJSON;
} else {
try { details = JSON.parse(info.detailsJSON || info.DetailsJSON || '{}'); } catch {}
}
const price = item.monthlyRent || item.MonthlyRent || item.dailyRent || item.DailyRent || 0;
const priceUnit = item.monthlyRent || item.MonthlyRent ? 'monthly' : 'daily';