massage data

This commit is contained in:
Casey 2025-11-06 18:24:19 -06:00
parent 616fa1be79
commit 60d3f35988
7 changed files with 174 additions and 48 deletions

View file

@ -246,23 +246,30 @@ class Api {
* Get paginated client data with filtering and sorting
* @param {Object} paginationParams - Pagination parameters from store
* @param {Object} filters - Filter parameters from store
* @returns {Promise<{data: Array, totalRecords: number}>}
* @returns {Promise<{data: Array, pagination: Object}>}
*/
static async getPaginatedClientDetails(paginationParams = {}, filters = {}) {
const { page = 0, pageSize = 10, sortField = null, sortOrder = null } = paginationParams;
const options = {
page: page + 1,
pageSize,
page: page + 1, // Backend expects 1-based pages
page_size: pageSize,
filters,
sortField,
sortOrder,
sorting: sortField ? `${sortField} ${sortOrder === -1 ? "desc" : "asc"}` : null,
for_table: true,
};
const result = await this.getClientDetails(options);
const result = await this.request("custom_ui.api.db.get_clients", { options });
// Transform the response to match what the frontend expects
return {
...result,
data: result.data,
pagination: {
total: result.pagination.total,
page: result.pagination.page,
pageSize: result.pagination.page_size,
totalPages: result.pagination.total_pages,
},
};
}