diff --git a/backend/internal/utils/paging_util.go b/backend/internal/utils/paging_util.go index 13143d7..8698bba 100644 --- a/backend/internal/utils/paging_util.go +++ b/backend/internal/utils/paging_util.go @@ -63,8 +63,13 @@ func Paginate(page int, pageSize int, query *gorm.DB, result interface{}) (Pagin return PaginationResponse{}, err } + totalPages := (totalItems + int64(pageSize) - 1) / int64(pageSize) + if totalItems == 0 { + totalPages = 1 + } + return PaginationResponse{ - TotalPages: (totalItems + int64(pageSize) - 1) / int64(pageSize), + TotalPages: totalPages, TotalItems: totalItems, CurrentPage: page, ItemsPerPage: pageSize, diff --git a/frontend/src/lib/components/advanced-table.svelte b/frontend/src/lib/components/advanced-table.svelte index c7ef605..c41a9f3 100644 --- a/frontend/src/lib/components/advanced-table.svelte +++ b/frontend/src/lib/components/advanced-table.svelte @@ -32,6 +32,8 @@ rows: Snippet<[{ item: T }]>; } = $props(); + let searchValue = $state(''); + if (!requestOptions) { requestOptions = { search: '', @@ -55,9 +57,10 @@ return true; }); - const onSearch = debounced(async (searchValue: string) => { - requestOptions.search = searchValue; - onRefresh(requestOptions); + const onSearch = debounced(async (search: string) => { + requestOptions.search = search; + await onRefresh(requestOptions); + searchValue = search; }, 300); async function onAllCheck(checked: boolean) { @@ -95,122 +98,124 @@ } -{#if items.data.length === 0} +{#if !withoutSearch} + onSearch((e.target as HTMLInputElement).value)} + /> +{/if} + +{#if items.data.length === 0 && searchValue === ''}
No items found
Items per page
-Items per page
+