refactor(api): consolidate query param transformation into utility function

Move URL parameter construction logic from multiple list components to a shared transform function in usePaginatedList. This improves code reuse and maintainability while keeping the same functionality.

Standardize query parameter names to match backend expectations ('page-number' and 'page-size' instead of 'page' and 'pageSize'). Update related schema and default params accordingly.
This commit is contained in:
Khafid Prayoga
2025-09-11 13:28:07 +07:00
parent 140bfa0420
commit 26b0cf12e3
7 changed files with 70 additions and 125 deletions
+2 -12
View File
@@ -24,19 +24,9 @@ const items = [
{ value: 'item-3', label: 'Item 3' },
]
// Fungsi untuk fetch data division
async function fetchDeviceData(params: any) {
// Prepare query parameters for pagination and search
const urlParams = new URLSearchParams({
'page-number': params.page.toString(),
'page-size': params.pageSize.toString(),
})
if (params.q) {
urlParams.append('search', params.q)
}
return await xfetch(`/api/v1/device?${urlParams.toString()}`)
const endpoint = transform('/api/v1/device', params)
return await xfetch(endpoint)
}
// Menggunakan composable untuk pagination