added a swicher on the properties
All checks were successful
Build frontend / build (push) Successful in 46s

This commit is contained in:
mouazkh
2026-05-26 20:24:37 +03:00
parent a3657e5c2f
commit caddf55811
2 changed files with 21 additions and 11 deletions

View File

@ -80,7 +80,7 @@ function mapApiProperty(item, index) {
features,
images,
status,
rating: item.rating || 4.5,
rating: item.rating || 0,
isNew: false,
_raw: item,
};
@ -299,10 +299,12 @@ const PropertyCard = ({ property, viewMode = 'grid', onLoginRequired }) => {
<span>{property.area}م²</span>
</div>
</div>
{property.rating > 0 && (
<div className="flex items-center gap-1">
<Star className="w-4 h-4 fill-gray-400 text-gray-400" />
<span className="text-sm font-medium text-gray-700">{property.rating || 4.5}</span>
<Star className="w-4 h-4 fill-amber-500 text-amber-500" />
<span className="text-sm font-medium text-gray-700">{property.rating.toFixed(1)}</span>
</div>
)}
</div>
<Link

View File

@ -15,7 +15,7 @@ import {
TreePine, Building, GraduationCap, ExternalLink,
Smile, Ban, Wine, Dog, CassetteTape, Info
} from 'lucide-react';
import { getRentProperty, getSaleProperty, getSalePropertyById, bookReservation, getAvailableDateRanges, getOwnerContactInformation, getMyRentListings } from '../../utils/api';
import { getRentProperty, getSaleProperty, getSalePropertyById, bookReservation, getAvailableDateRanges, getOwnerContactInformation, getMyRentListings, getMySaleListings } from '../../utils/api';
import AuthService from '../../services/AuthService';
import { useFavorites } from '@/app/contexts/FavoritesContext';
import { BuildingTypeKeys, PropertyStatusKeys, extractCity } from '../../enums';
@ -224,14 +224,22 @@ export default function PropertyDetailsPage() {
// Check if current user owns this property via their own listings
if (AuthService.isAuthenticated() && AuthService.isOwner()) {
try {
const myRent = await getMyRentListings();
const list = Array.isArray(myRent) ? myRent : (myRent ? [myRent] : []);
const [myRent, mySale] = await Promise.allSettled([
getMyRentListings(),
getMySaleListings(),
]);
const myPropIds = new Set();
list.filter(Boolean).forEach(p => {
const info = p.propertyInformation || {};
if (info.id) myPropIds.add(Number(info.id));
if (p.id) myPropIds.add(Number(p.id));
});
const collectIds = (result) => {
if (result.status !== 'fulfilled' || !result.value) return;
const list = Array.isArray(result.value) ? result.value : [result.value];
list.filter(Boolean).forEach(p => {
const info = p.propertyInformation || {};
if (info.id) myPropIds.add(Number(info.id));
if (p.id) myPropIds.add(Number(p.id));
});
};
collectIds(myRent);
collectIds(mySale);
const propInfoId = mapped._raw?.propertyInformation?.id;
if (myPropIds.has(Number(mapped.id)) || (propInfoId && myPropIds.has(Number(propInfoId)))) {
setIsOwnProperty(true);