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

This commit is contained in:
mouazkh
2026-05-26 22:40:54 +03:00
parent e1204bf69e
commit 01b966c1d2

View File

@ -9,7 +9,7 @@ import {
} from 'lucide-react';
import toast, { Toaster } from 'react-hot-toast';
import AuthService from '../services/AuthService';
import { getRentProperty, getUserReservations, payDeposit } from '../utils/api';
import { getRentProperties, getUserReservations, payDeposit } from '../utils/api';
const API_BASE = process.env.NEXT_PUBLIC_API_URL || 'https://45.93.137.91.nip.io/api';
@ -37,17 +37,6 @@ function StatusBadge({ code }) {
);
}
async function enrich(reservation) {
if (!reservation.propertyId) return reservation;
try {
const prop = await getRentProperty(reservation.propertyId);
const info = prop?.propertyInformation ?? prop ?? {};
if (prop?.allowedPaymentPeriod) info.allowedPaymentPeriod = prop.allowedPaymentPeriod;
reservation._prop = info;
} catch { /* skip */ }
return reservation;
}
const propAddr = (p, r) => p?.address ?? r?.propertyAddress ?? '';
const propImages = (p, r) => {
if (p?.images && Array.isArray(p.images)) return p.images;
@ -248,9 +237,23 @@ export default function UserReservationsPage() {
const loadReservations = useCallback(async () => {
try {
const data = await getUserReservations();
const [data, rentProps] = await Promise.all([
getUserReservations(),
getRentProperties().catch(() => []),
]);
const list = Array.isArray(data) ? data : [];
const enriched = await Promise.all(list.map(enrich));
const propsList = Array.isArray(rentProps) ? rentProps : [];
const propMap = {};
propsList.forEach(rp => {
const info = rp?.propertyInformation ?? {};
if (rp?.allowedPaymentPeriod) info.allowedPaymentPeriod = rp.allowedPaymentPeriod;
propMap[rp.propertyInformationId] = info;
propMap[rp.propertyInformation?.id] = info;
});
const enriched = list.map(r => {
if (r.propertyId && propMap[r.propertyId]) r._prop = propMap[r.propertyId];
return r;
});
setReservations(enriched);
setFiltered(enriched);
} catch (err) {