Fix reservation fetching
This commit is contained in:
parent
ec7f07d788
commit
56204f3324
@ -241,9 +241,9 @@ const UserDashboard: React.FC = () => {
|
|||||||
<div style={{ display: 'grid', gap: '1rem' }}>
|
<div style={{ display: 'grid', gap: '1rem' }}>
|
||||||
{reservations
|
{reservations
|
||||||
.sort((a, b) => new Date(b.startTime).getTime() - new Date(a.startTime).getTime())
|
.sort((a, b) => new Date(b.startTime).getTime() - new Date(a.startTime).getTime())
|
||||||
.map(reservation => (
|
.map(reservation => (
|
||||||
<div
|
<div
|
||||||
key={reservation.id}
|
key={reservation.referenceNumber}
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: 'white',
|
backgroundColor: 'white',
|
||||||
padding: '1.5rem',
|
padding: '1.5rem',
|
||||||
|
|||||||
@ -123,9 +123,21 @@ export class SimpleLibreBookingClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = resourceId
|
// Use a wide date range to get all reservations
|
||||||
? `${this.baseUrl}/Services/index.php/Reservations/?resourceId=${resourceId}`
|
const today = new Date();
|
||||||
: `${this.baseUrl}/Services/index.php/Reservations/`;
|
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> = {
|
const headers: Record<string, string> = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -145,7 +157,11 @@ export class SimpleLibreBookingClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const data = await response.json();
|
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 || [];
|
return data.reservations || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user