added a swicher on the properties
All checks were successful
Build frontend / build (push) Successful in 46s
All checks were successful
Build frontend / build (push) Successful in 46s
This commit is contained in:
@ -80,7 +80,7 @@ function mapApiProperty(item, index) {
|
|||||||
features,
|
features,
|
||||||
images,
|
images,
|
||||||
status,
|
status,
|
||||||
rating: item.rating || 4.5,
|
rating: item.rating || 0,
|
||||||
isNew: false,
|
isNew: false,
|
||||||
_raw: item,
|
_raw: item,
|
||||||
};
|
};
|
||||||
@ -299,10 +299,12 @@ const PropertyCard = ({ property, viewMode = 'grid', onLoginRequired }) => {
|
|||||||
<span>{property.area}م²</span>
|
<span>{property.area}م²</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{property.rating > 0 && (
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
<Star className="w-4 h-4 fill-gray-400 text-gray-400" />
|
<Star className="w-4 h-4 fill-amber-500 text-amber-500" />
|
||||||
<span className="text-sm font-medium text-gray-700">{property.rating || 4.5}</span>
|
<span className="text-sm font-medium text-gray-700">{property.rating.toFixed(1)}</span>
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Link
|
<Link
|
||||||
|
|||||||
@ -15,7 +15,7 @@ import {
|
|||||||
TreePine, Building, GraduationCap, ExternalLink,
|
TreePine, Building, GraduationCap, ExternalLink,
|
||||||
Smile, Ban, Wine, Dog, CassetteTape, Info
|
Smile, Ban, Wine, Dog, CassetteTape, Info
|
||||||
} from 'lucide-react';
|
} 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 AuthService from '../../services/AuthService';
|
||||||
import { useFavorites } from '@/app/contexts/FavoritesContext';
|
import { useFavorites } from '@/app/contexts/FavoritesContext';
|
||||||
import { BuildingTypeKeys, PropertyStatusKeys, extractCity } from '../../enums';
|
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
|
// Check if current user owns this property via their own listings
|
||||||
if (AuthService.isAuthenticated() && AuthService.isOwner()) {
|
if (AuthService.isAuthenticated() && AuthService.isOwner()) {
|
||||||
try {
|
try {
|
||||||
const myRent = await getMyRentListings();
|
const [myRent, mySale] = await Promise.allSettled([
|
||||||
const list = Array.isArray(myRent) ? myRent : (myRent ? [myRent] : []);
|
getMyRentListings(),
|
||||||
|
getMySaleListings(),
|
||||||
|
]);
|
||||||
const myPropIds = new Set();
|
const myPropIds = new Set();
|
||||||
|
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 => {
|
list.filter(Boolean).forEach(p => {
|
||||||
const info = p.propertyInformation || {};
|
const info = p.propertyInformation || {};
|
||||||
if (info.id) myPropIds.add(Number(info.id));
|
if (info.id) myPropIds.add(Number(info.id));
|
||||||
if (p.id) myPropIds.add(Number(p.id));
|
if (p.id) myPropIds.add(Number(p.id));
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
collectIds(myRent);
|
||||||
|
collectIds(mySale);
|
||||||
const propInfoId = mapped._raw?.propertyInformation?.id;
|
const propInfoId = mapped._raw?.propertyInformation?.id;
|
||||||
if (myPropIds.has(Number(mapped.id)) || (propInfoId && myPropIds.has(Number(propInfoId)))) {
|
if (myPropIds.has(Number(mapped.id)) || (propInfoId && myPropIds.has(Number(propInfoId)))) {
|
||||||
setIsOwnProperty(true);
|
setIsOwnProperty(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user