This commit is contained in:
@ -161,6 +161,7 @@ function mapApiDetail(item) {
|
||||
isSmokeAllow: item.isSmokeAllow,
|
||||
isVisitorAllow: item.isVisitorAllow,
|
||||
specializedFor: item.specializedFor,
|
||||
ownerId: item.userId || item.ownerId || info.userId || info.ownerId || null,
|
||||
_raw: item,
|
||||
};
|
||||
}
|
||||
@ -221,7 +222,18 @@ export default function PropertyDetailsPage() {
|
||||
}
|
||||
}
|
||||
// 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 {
|
||||
const [myRent, mySale] = await Promise.allSettled([
|
||||
getMyRentListings(),
|
||||
@ -239,12 +251,14 @@ export default function PropertyDetailsPage() {
|
||||
};
|
||||
collectIds(myRent);
|
||||
collectIds(mySale);
|
||||
const checkId = Number(mapped.id) || mapped.id;
|
||||
const checkInfoId = Number(mapped._raw?.propertyInformation?.id) || mapped._raw?.propertyInformation?.id;
|
||||
if (myPropIds.has(checkId) || (checkInfoId && myPropIds.has(checkInfoId))) {
|
||||
const checkId = mapped.id ? Number(mapped.id) : null;
|
||||
const checkInfoId = rawInfo.id ? Number(rawInfo.id) : null;
|
||||
console.log('[OwnerCheck] myPropIds:', [...myPropIds], 'checkId:', checkId, 'checkInfoId:', checkInfoId);
|
||||
if ((checkId && myPropIds.has(checkId)) || (checkInfoId && myPropIds.has(checkInfoId))) {
|
||||
setIsOwnProperty(true);
|
||||
}
|
||||
} catch {}
|
||||
} catch (e) { console.error('[OwnerCheck] fallback error:', e); }
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user