2025-10-23 17:08:17 -05:00

34 lines
1.0 KiB
JavaScript

import DataUtils from "./utils";
class Api {
static async getClientDetails() {
// const data = [];
// const addresses = await this.getDocsList("Address");
// for (const addr of addresses) {
// const clientDetail = {};
// const fullAddress = await this.getDetailedDoc("Address", addr["name"] || addr["Name"]);
// const customer = await this.getDetailedCustomer(fullAddress["links"][0]["link_name"]);
// clientDetail.customer = customer;
// clientDetail.address = fullAddress;
// data.push(clientDetail);
// }
// console.log("DEBUG: API - Fetched Client Details: ", data);
const data = DataUtils.dummyClientData;
return data;
}
static async getDocsList(doctype, fields = []) {
const docs = await frappe.db.get_list(doctype, { fields });
console.log(`DEBUG: API - Fetched ${doctype} list: `, docs);
return docs;
}
static async getDetailedDoc(doctype, name) {
const doc = await frappe.db.get_doc(doctype, name);
console.log(`DEBUG: API - Fetched Detailed ${doctype}: `, doc);
return doc;
}
}
export default Api;