All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
- Integrated InfoActionButtons into multiple components across the Finance and Inventory sections, enhancing user interaction and providing contextual actions for invoices, payment policies, payments, tax records, and various inventory items. - Updated the respective components to include the new buttons with appropriate object types and list mode settings, improving the overall functionality and user experience in the dashboard.
42 lines
768 B
JavaScript
42 lines
768 B
JavaScript
export async function fetchAllObjectPages({
|
|
fetchObjects,
|
|
type,
|
|
filter = {},
|
|
sorter = {},
|
|
limit = 25
|
|
}) {
|
|
if (!type || typeof fetchObjects !== 'function') return []
|
|
|
|
const all = []
|
|
let page = 1
|
|
let totalPages = 1
|
|
|
|
do {
|
|
const result = await fetchObjects(type, {
|
|
page,
|
|
limit,
|
|
filter,
|
|
sorter
|
|
})
|
|
|
|
if (!result || Array.isArray(result)) {
|
|
break
|
|
}
|
|
|
|
const data = Array.isArray(result.data) ? result.data : []
|
|
all.push(...data)
|
|
|
|
if (Number.isFinite(result.totalPages) && result.totalPages > 0) {
|
|
totalPages = result.totalPages
|
|
} else if (result.hasMore) {
|
|
totalPages = page + 1
|
|
} else {
|
|
totalPages = page
|
|
}
|
|
|
|
page += 1
|
|
} while (page <= totalPages)
|
|
|
|
return all
|
|
}
|