big updates
This commit is contained in:
parent
34f2c110d6
commit
03a230b8f7
14 changed files with 2417 additions and 242 deletions
|
|
@ -2,12 +2,24 @@ import ApiUtils from "./apiUtils";
|
|||
import { useErrorStore } from "./stores/errors";
|
||||
|
||||
const ZIPPOPOTAMUS_BASE_URL = "https://api.zippopotam.us/us";
|
||||
// Proxy method for external API calls
|
||||
const FRAPPE_PROXY_METHOD = "custom_ui.api.proxy.request";
|
||||
// Estimate methods
|
||||
const FRAPPE_UPSERT_ESTIMATE_METHOD = "custom_ui.api.db.estimates.upsert_estimate";
|
||||
// Job methods
|
||||
const FRAPPE_GET_JOBS_METHOD = "custom_ui.api.db.get_jobs";
|
||||
const FRAPPE_UPSERT_JOB_METHOD = "custom_ui.api.db.jobs.upsert_job";
|
||||
// Invoice methods
|
||||
const FRAPPE_UPSERT_INVOICE_METHOD = "custom_ui.api.db.invoices.upsert_invoice";
|
||||
// Warranty methods
|
||||
const FRAPPE_GET_WARRANTY_CLAIMS_METHOD = "custom_ui.api.db.warranties.get_warranty_claims";
|
||||
// On-Site Meeting methods
|
||||
const FRAPPE_GET_WEEK_ONSITE_MEETINGS_METHOD =
|
||||
"custom_ui.api.db.onsite_meetings.get_week_onsite_meetings";
|
||||
const FRAPPE_GET_ONSITE_MEETINGS_METHOD = "custom_ui.api.db.onsite_meetings.get_onsite_meetings";
|
||||
// Address methods
|
||||
const FRAPPE_GET_ADDRESSES_METHOD = "custom_ui.api.db.addresses.get_addresses";
|
||||
// Client methods
|
||||
const FRAPPE_UPSERT_CLIENT_METHOD = "custom_ui.api.db.clients.upsert_client";
|
||||
const FRAPPE_GET_CLIENT_STATUS_COUNTS_METHOD = "custom_ui.api.db.clients.get_client_status_counts";
|
||||
const FRAPPE_GET_CLIENT_TABLE_DATA_METHOD = "custom_ui.api.db.clients.get_clients_table_data";
|
||||
|
|
@ -23,6 +35,7 @@ class Api {
|
|||
try {
|
||||
let response = await frappe.call(request);
|
||||
response = ApiUtils.toCamelCaseObject(response);
|
||||
response.method = frappeMethod;
|
||||
console.log("DEBUG: API - Request Response: ", response);
|
||||
if (response.message.status && response.message.status === "error") {
|
||||
throw new Error(response.message.message);
|
||||
|
|
@ -35,6 +48,45 @@ class Api {
|
|||
}
|
||||
}
|
||||
|
||||
static async searchAddresses(searchTerm) {
|
||||
const filters = {
|
||||
full_address: ["like", `%${searchTerm}%`],
|
||||
};
|
||||
return await this.getAddresses(["full_address"], filters);
|
||||
}
|
||||
|
||||
static async getAddresses(fields = ["*"], filters = {}) {
|
||||
return await this.request(FRAPPE_GET_ADDRESSES_METHOD, { fields, filters });
|
||||
}
|
||||
|
||||
static async getUnscheduledOnSiteMeetings() {
|
||||
return await this.request(
|
||||
"custom_ui.api.db.onsite_meetings.get_unscheduled_onsite_meetings",
|
||||
);
|
||||
}
|
||||
|
||||
static async getScheduledOnSiteMeetings(fields = ["*"], filters = {}) {
|
||||
return await this.request(FRAPPE_GET_ONSITE_MEETINGS_METHOD, { fields, filters });
|
||||
}
|
||||
|
||||
static async getWeekOnSiteMeetings(weekStart, weekEnd) {
|
||||
return await this.request(FRAPPE_GET_WEEK_ONSITE_MEETINGS_METHOD, { weekStart, weekEnd });
|
||||
}
|
||||
|
||||
static async updateOnSiteMeeting(name, data) {
|
||||
return await this.request("custom_ui.api.db.onsite_meetings.update_onsite_meeting", {
|
||||
name,
|
||||
data,
|
||||
});
|
||||
}
|
||||
|
||||
static async createOnSiteMeeting(address, notes = "") {
|
||||
return await this.request("custom_ui.api.db.onsite_meetings.create_onsite_meeting", {
|
||||
address,
|
||||
notes,
|
||||
});
|
||||
}
|
||||
|
||||
static async getClientStatusCounts(params = {}) {
|
||||
return await this.request(FRAPPE_GET_CLIENT_STATUS_COUNTS_METHOD, params);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue