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

This commit is contained in:
mouazkh
2026-05-26 18:22:21 +03:00
parent 3f24696c48
commit bf044cef45

View File

@ -161,6 +161,7 @@ function mapApiDetail(item) {
isSmokeAllow: item.isSmokeAllow, isSmokeAllow: item.isSmokeAllow,
isVisitorAllow: item.isVisitorAllow, isVisitorAllow: item.isVisitorAllow,
specializedFor: item.specializedFor, specializedFor: item.specializedFor,
ownerId: item.userId || item.ownerId || info.userId || info.ownerId || null,
_raw: item, _raw: item,
}; };
} }
@ -221,7 +222,18 @@ export default function PropertyDetailsPage() {
} }
} }
// Check if current user owns this property // Check if current user owns this property
if (AuthService.isAuthenticated() && AuthService.isOwner()) { if (AuthService.isAuthenticated()) {
const currentUserId = AuthService.getUserId();
const raw = mapped._raw || {};
const rawInfo = raw.propertyInformation || {};
console.log('[OwnerCheck] currentUserId:', currentUserId);
console.log('[OwnerCheck] raw keys:', Object.keys(raw));
console.log('[OwnerCheck] rawInfo keys:', Object.keys(rawInfo));
console.log('[OwnerCheck] raw.userId:', raw.userId, 'raw.ownerId:', raw.ownerId, 'rawInfo.userId:', rawInfo.userId, 'rawInfo.ownerId:', rawInfo.ownerId);
const possibleOwnerFields = [raw.userId, raw.ownerId, rawInfo.userId, rawInfo.ownerId, raw.userID, raw.ownerID, rawInfo.userID, rawInfo.ownerID].filter(Boolean);
if (possibleOwnerFields.some(id => String(id) === String(currentUserId))) {
setIsOwnProperty(true);
} else if (AuthService.isOwner()) {
try { try {
const [myRent, mySale] = await Promise.allSettled([ const [myRent, mySale] = await Promise.allSettled([
getMyRentListings(), getMyRentListings(),
@ -239,12 +251,14 @@ export default function PropertyDetailsPage() {
}; };
collectIds(myRent); collectIds(myRent);
collectIds(mySale); collectIds(mySale);
const checkId = Number(mapped.id) || mapped.id; const checkId = mapped.id ? Number(mapped.id) : null;
const checkInfoId = Number(mapped._raw?.propertyInformation?.id) || mapped._raw?.propertyInformation?.id; const checkInfoId = rawInfo.id ? Number(rawInfo.id) : null;
if (myPropIds.has(checkId) || (checkInfoId && myPropIds.has(checkInfoId))) { console.log('[OwnerCheck] myPropIds:', [...myPropIds], 'checkId:', checkId, 'checkInfoId:', checkInfoId);
if ((checkId && myPropIds.has(checkId)) || (checkInfoId && myPropIds.has(checkInfoId))) {
setIsOwnProperty(true); setIsOwnProperty(true);
} }
} catch {} } catch (e) { console.error('[OwnerCheck] fallback error:', e); }
}
} }
} }
} catch (err) { } catch (err) {