Fix reservation fetching
This commit is contained in:
parent
ec7f07d788
commit
56204f3324
@ -243,7 +243,7 @@ const UserDashboard: React.FC = () => {
|
||||
.sort((a, b) => new Date(b.startTime).getTime() - new Date(a.startTime).getTime())
|
||||
.map(reservation => (
|
||||
<div
|
||||
key={reservation.id}
|
||||
key={reservation.referenceNumber}
|
||||
style={{
|
||||
backgroundColor: 'white',
|
||||
padding: '1.5rem',
|
||||
|
||||
@ -123,9 +123,21 @@ export class SimpleLibreBookingClient {
|
||||
}
|
||||
}
|
||||
|
||||
const url = resourceId
|
||||
? `${this.baseUrl}/Services/index.php/Reservations/?resourceId=${resourceId}`
|
||||
: `${this.baseUrl}/Services/index.php/Reservations/`;
|
||||
// Use a wide date range to get all reservations
|
||||
const today = new Date();
|
||||
const threeMonthsAgo = new Date(today.getTime() - (90 * 24 * 60 * 60 * 1000));
|
||||
const threeMonthsFromNow = new Date(today.getTime() + (90 * 24 * 60 * 60 * 1000));
|
||||
|
||||
const params = new URLSearchParams({
|
||||
startDateTime: threeMonthsAgo.toISOString().split('.')[0] + 'Z',
|
||||
endDateTime: threeMonthsFromNow.toISOString().split('.')[0] + 'Z',
|
||||
});
|
||||
|
||||
if (resourceId) {
|
||||
params.append('resourceId', resourceId);
|
||||
}
|
||||
|
||||
const url = `${this.baseUrl}/Services/index.php/Reservations/?${params.toString()}`;
|
||||
|
||||
const headers: Record<string, string> = {
|
||||
'Content-Type': 'application/json',
|
||||
@ -145,7 +157,11 @@ export class SimpleLibreBookingClient {
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
console.log('Reservations response:', data);
|
||||
console.log('API date range:', {
|
||||
start: data.startDateTime,
|
||||
end: data.endDateTime
|
||||
});
|
||||
console.log('Found reservations:', data.reservations.length);
|
||||
return data.reservations || [];
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user