Fix booking search, shrink time picker

This commit is contained in:
2026-01-17 19:59:03 +00:00
parent 3a77e582e3
commit 73610e5d8e
3 changed files with 29 additions and 35 deletions
@@ -136,43 +136,40 @@
const response = await fetch(
`/api/admin/bookings/search?q=${encodeURIComponent(bookingQuery)}`,
{
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${authStore.currentToken}`
}
}
);
if (response.ok) {
const data = await response.json();
bookings = data.bookings.map((b: any) => ({
id: b.id,
start_time: b.start_time,
status: b.status,
notes: b.notes,
created_at: b.created_at,
updated_at: b.updated_at,
created_by: b.created_by,
user: b.user
? {
id: b.user.id,
full_name: b.user.full_name
}
: undefined,
services: b.services || [],
total_amount: b.total_amount || 0,
amount_paid: b.amount_paid || 0,
amount_due: b.amount_due || 0,
duration_minutes: b.duration_minutes || 0
}));
} else {
const text = await response.text();
toast.error('Failed to search bookings: ' + text);
// HTTP error (400 / 401 / 500 etc)
if (!response.ok) {
const message = await response.text();
throw new Error(message || `Request failed (${response.status})`);
}
const data = await response.json();
const bookingsData = Array.isArray(data.bookings) ? data.bookings : [];
bookings = bookingsData.map((b: any) => ({
id: b.id,
start_time: b.start_time,
status: b.status,
notes: b.notes,
created_at: b.created_at,
updated_at: b.updated_at,
created_by: b.created_by,
user: b.user ? { id: b.user.id, full_name: b.user.full_name } : undefined,
services: b.services || [],
total_amount: b.total_amount || 0,
amount_paid: b.amount_paid || 0,
amount_due: b.amount_due || 0,
duration_minutes: b.duration_minutes || 0
}));
} catch (err) {
console.error('Error searching bookings:', err);
toast.error('Network error searching bookings');
console.error('Search bookings failed:', err);
toast.error(err instanceof Error ? err.message : 'Unexpected error searching bookings');
} finally {
loadingSearch = false;
}
@@ -297,9 +294,6 @@
</Card.Title>
<Card.Description>Search and manage booking history.</Card.Description>
</div>
<div class="rounded-full bg-gray-100 px-2 py-0.5 text-xs font-medium">
<span class="text-xs font-semibold">{bookings.length}</span>
</div>
</div>
</Card.Header>
<Card.Content class="space-y-4">