finish client table for now
This commit is contained in:
parent
60d3f35988
commit
f4d04e90a9
6 changed files with 254 additions and 106 deletions
|
|
@ -1,4 +1,3 @@
|
|||
import { da } from "vuetify/locale";
|
||||
import DataUtils from "./utils";
|
||||
|
||||
const ZIPPOPOTAMUS_BASE_URL = "https://api.zippopotam.us/us";
|
||||
|
|
@ -8,6 +7,7 @@ const FRAPPE_UPSERT_CLIENT_METHOD = "custom_ui.api.db.upsert_client";
|
|||
class Api {
|
||||
static async request(frappeMethod, args = {}) {
|
||||
args = DataUtils.toSnakeCaseObject(args);
|
||||
console.log("DEBUG: API - Request Args: ", { method: frappeMethod, args });
|
||||
try {
|
||||
let response = await frappe.call({
|
||||
method: frappeMethod,
|
||||
|
|
@ -207,8 +207,7 @@ class Api {
|
|||
const routes = getDocList("Pre-Built Routes");
|
||||
for (const rt of routes) {
|
||||
route = getDetailedDoc("Pre-Built Routes", rt.name);
|
||||
let tableRow = {
|
||||
};
|
||||
let tableRow = {};
|
||||
}
|
||||
|
||||
console.log("DEBUG: API - getRouteData result: ", data);
|
||||
|
|
@ -234,8 +233,8 @@ class Api {
|
|||
customer: timesheet.customer,
|
||||
totalHours: timesheet.total_hours,
|
||||
status: timesheet.status,
|
||||
totalPayFormatted: timesheet.total_costing_amount
|
||||
}
|
||||
totalPayFormatted: timesheet.total_costing_amount,
|
||||
};
|
||||
data.push(tableRow);
|
||||
}
|
||||
console.log("DEBUG: API - getTimesheetData result: ", data);
|
||||
|
|
@ -246,31 +245,31 @@ class Api {
|
|||
* Get paginated client data with filtering and sorting
|
||||
* @param {Object} paginationParams - Pagination parameters from store
|
||||
* @param {Object} filters - Filter parameters from store
|
||||
* @param {Object} sorting - Sorting parameters from store (optional)
|
||||
* @returns {Promise<{data: Array, pagination: Object}>}
|
||||
*/
|
||||
static async getPaginatedClientDetails(paginationParams = {}, filters = {}) {
|
||||
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,
|
||||
filters,
|
||||
sorting: sortField ? `${sortField} ${sortOrder === -1 ? "desc" : "asc"}` : null,
|
||||
sorting:
|
||||
actualSortField && actualSortOrder
|
||||
? `${actualSortField} ${actualSortOrder === -1 ? "desc" : "asc"}`
|
||||
: null,
|
||||
for_table: true,
|
||||
};
|
||||
|
||||
const result = await this.request("custom_ui.api.db.get_clients", { options });
|
||||
console.log("DEBUG: API - Sending options to backend:", options);
|
||||
|
||||
// Transform the response to match what the frontend expects
|
||||
return {
|
||||
data: result.data,
|
||||
pagination: {
|
||||
total: result.pagination.total,
|
||||
page: result.pagination.page,
|
||||
pageSize: result.pagination.page_size,
|
||||
totalPages: result.pagination.total_pages,
|
||||
},
|
||||
};
|
||||
const result = await this.request("custom_ui.api.db.get_clients", { options });
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue