build datatable
This commit is contained in:
parent
6b0a3d9fa9
commit
73a3b67e0f
5 changed files with 141 additions and 65 deletions
|
|
@ -1,42 +1,33 @@
|
|||
import DataUtils from "./utils";
|
||||
|
||||
class Api {
|
||||
static async getAddresses(fields = []) {
|
||||
const addressNames = await frappe.db.get_list("Address", { fields });
|
||||
console.log("DEBUG: API - Fetched Address list: ", addressNames);
|
||||
return addressNames;
|
||||
}
|
||||
|
||||
static async getDetailedAddress(name) {
|
||||
const address = await frappe.db.get_doc("Address", name);
|
||||
console.log("DEBUG: API - Fetched Detailed Address: ", address);
|
||||
return address;
|
||||
}
|
||||
|
||||
static async getCustomerList(fields = []) {
|
||||
const customers = await frappe.db.get_list("Customer", { fields });
|
||||
console.log("DEBUG: API - Fetched Customer list: ", customers);
|
||||
return customers;
|
||||
}
|
||||
|
||||
static async getDetailedCustomer(name) {
|
||||
const customer = await frappe.db.get_doc("Customer", name);
|
||||
console.log("DEBUG: API - Fetched Detailed Customer: ", customer);
|
||||
return customer;
|
||||
}
|
||||
|
||||
static async getClientDetails() {
|
||||
const data = [];
|
||||
const addresses = await this.getAddresses();
|
||||
for (const addr of addresses) {
|
||||
const clientDetail = {};
|
||||
const fullAddress = await this.getDetailedAddress(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 = [];
|
||||
// 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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue