From f040534f2ea021da461ef1248175d7f005605212 Mon Sep 17 00:00:00 2001 From: Jeppe Bundgaard Date: Mon, 10 Nov 2025 12:06:50 +0100 Subject: [PATCH] "Add pagination to OrderBookingsTable.vue with next/previous controls, dynamic page limit, and loading state management; refine empty state handling and table structure for improved user experience" --- .../displays/tables/OrderBookingsTable.vue | 223 +++++++++++------- 1 file changed, 139 insertions(+), 84 deletions(-) diff --git a/src/views/dashboards/userDashboard/bookings/displays/tables/OrderBookingsTable.vue b/src/views/dashboards/userDashboard/bookings/displays/tables/OrderBookingsTable.vue index 6360dcc6..0918c29b 100644 --- a/src/views/dashboards/userDashboard/bookings/displays/tables/OrderBookingsTable.vue +++ b/src/views/dashboards/userDashboard/bookings/displays/tables/OrderBookingsTable.vue @@ -8,12 +8,44 @@ import ActionSettingsWheelItemLabel from "@/components/displays/buttons/ActionSe import ActionSettingsWheelItem from "@/components/displays/buttons/ActionSettingsWheelItem.vue"; const bookings = ref([]); +const page = ref(1); +const limit = ref(10); +const loading = ref(false); +const isLastPage = ref(false); + const fetch = async () => { - SessionUser.objects.order_bookings.get.all().then((res) => { - bookings.value = res; + loading.value = true; + return SessionUser.objects.order_bookings.get.all({ page: page.value, limit: limit.value }).then((res) => { + bookings.value = res || []; + // Infer if this is the last page based on result size + isLastPage.value = bookings.value.length < limit.value; + }).catch((e) => { + console.error(e); + bookings.value = []; + isLastPage.value = true; + }).finally(() => { + loading.value = false; }); } +const nextPage = async () => { + if (isLastPage.value || loading.value) return; + page.value += 1; + await fetch(); +} + +const prevPage = async () => { + if (page.value === 1 || loading.value) return; + page.value -= 1; + await fetch(); +} + +const onLimitChange = async () => { + // Reset to first page when page size changes + page.value = 1; + await fetch(); +} + onMounted(() => { fetch(); }) @@ -109,95 +141,118 @@ const formatSummaryString = (items) => { Ydelser - + + +
+
+ +
+
+
+ +
+ Side {{ page }} +
+