diff --git a/frontend/src/pages/Bookings.tsx b/frontend/src/pages/Bookings.tsx index ac02d2a..8544bd1 100644 --- a/frontend/src/pages/Bookings.tsx +++ b/frontend/src/pages/Bookings.tsx @@ -26,6 +26,15 @@ export function Bookings() { .catch(() => setError("Booking list is unavailable right now.")); }, [status]); + useEffect(() => { + if (!bookings) return; + const filteredCount = bookings.filter((b) => + `${b.public_ref} ${b.customer_name} ${b.vehicle_ref}`.toLowerCase().includes(query.toLowerCase()), + ).length; + const totalPages = Math.max(1, Math.ceil(filteredCount / perPage)); + setPage((p) => Math.min(p, totalPages)); + }, [bookings, query]); + return (
@@ -68,7 +77,7 @@ export function Bookings() { - {bookings.map((b) => ( + {visible.map((b) => ( {b.public_ref} diff --git a/frontend/src/pages/Vehicles.tsx b/frontend/src/pages/Vehicles.tsx index 9a69f0e..7a83896 100644 --- a/frontend/src/pages/Vehicles.tsx +++ b/frontend/src/pages/Vehicles.tsx @@ -75,7 +75,7 @@ export function Vehicles() { - {vehicles.map((v) => ( + {filtered.map((v) => ( {v.public_ref}