fix filtering and sorting
This commit is contained in:
parent
ba507f8e6a
commit
3b86ed0ee7
7 changed files with 334 additions and 201 deletions
|
|
@ -32,7 +32,7 @@ class Api {
|
|||
}
|
||||
|
||||
static async getClientDetails(clientName) {
|
||||
return await this.request(FRAPPE_GET_CLIENT_DETAILS_METHOD);
|
||||
return await this.request(FRAPPE_GET_CLIENT_DETAILS_METHOD, { clientName });
|
||||
}
|
||||
|
||||
static async getJobDetails() {
|
||||
|
|
@ -107,24 +107,14 @@ class Api {
|
|||
* @param {Object} sorting - Sorting parameters from store (optional)
|
||||
* @returns {Promise<{data: Array, pagination: Object}>}
|
||||
*/
|
||||
static async getPaginatedClientDetails(paginationParams = {}, filters = {}, sorting = null) {
|
||||
const { page = 0, pageSize = 10, sortField = null, sortOrder = null } = paginationParams;
|
||||
|
||||
// Use sorting from the dedicated sorting parameter first, then fall back to pagination params
|
||||
const actualSortField = sorting?.field || sortField;
|
||||
const actualSortOrder = sorting?.order || sortOrder;
|
||||
|
||||
const options = {
|
||||
page: page + 1, // Backend expects 1-based pages
|
||||
page_size: pageSize,
|
||||
static async getPaginatedClientDetails(paginationParams = {}, filters = {}, sorting = []) {
|
||||
const { page = 0, pageSize = 10 } = paginationParams;
|
||||
const result = await this.request(FRAPPE_GET_CLIENT_TABLE_DATA_METHOD, {
|
||||
filters,
|
||||
sorting:
|
||||
actualSortField && actualSortOrder
|
||||
? `${actualSortField} ${actualSortOrder === -1 ? "desc" : "asc"}`
|
||||
: null,
|
||||
for_table: true,
|
||||
};
|
||||
const result = await this.request(FRAPPE_GET_CLIENT_TABLE_DATA_METHOD, { options });
|
||||
sorting,
|
||||
page: page + 1,
|
||||
pageSize,
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue