Spaces:
Runtime error
Runtime error
import { Column, DataStructure } from "shared/interfaces/pwWorkOrdersInterface"; | |
import { PW_CONFIG } from "../../config/app.config"; | |
import { apiClientPW } from "./api.service"; | |
import axios from 'axios'; | |
export const fetchGLAccounts = async (params = []) => { | |
const response = await apiClientPW.get(`/accounting/glaccounts`, { params }); | |
return response.data; | |
}; | |
export const fetchGLAccountsForSync = async (params: { limit: number; offset: number; includeDeactivated:boolean } | undefined = undefined) => { | |
const response = await apiClientPW.get(`/accounting/glaccounts`, { params }); | |
return response; | |
}; | |
export const fetchGLAccountById = async (glAccountID: number) => { | |
const response = await apiClientPW.get(`/accounting/glaccounts/` + glAccountID); | |
return response.data; | |
}; | |
export const fetchVendors = async (params = []) => { | |
const response = await apiClientPW.get(`/vendors`, { params }); | |
return response.data; | |
}; | |
export const fetchVendorById = async (vendorId: number) => { | |
const response = await apiClientPW.get(`/vendors/${vendorId}`); | |
return response.data; | |
}; | |
export const fetchPortfolio = async (params = []) => { | |
const response = await apiClientPW.get(`/portfolios`, { params }); | |
return response.data; | |
}; | |
export const fetchPortfolioById = async (portfolioId: number) => { | |
const response = await apiClientPW.get(`/portfolios/${portfolioId}`); | |
return response.data; | |
}; | |
export const fetchBuildings = async (params: Record<string, string> = {} ) => { | |
const response = await apiClientPW.get(`/buildings`, { params }); | |
return response.data; | |
}; | |
export const fetchBuildingPropertyManager = async (buildingId: number ) => { | |
const response = await apiClientPW.get(`/buildings/${buildingId}/managers`); | |
return response.data; | |
}; | |
export const fetchBuildingsById = async (buildingId: number) => { | |
const response = await apiClientPW.get(`/buildings/${buildingId}`); | |
return response.data; | |
}; | |
export const fetchUnits = async (params: Record<string, string> = {}) => { | |
const response = await apiClientPW.get(`/units`, { params }); | |
return response.data; | |
}; | |
export const fetchUnitsById = async (unitId: number) => { | |
const response = await apiClientPW.get(`/units/${unitId}`); | |
return response.data; | |
}; | |
export const fetchWorkorderById = async (workOrderID: number) => { | |
const response = await apiClientPW.get(`/workorders/${workOrderID}`); | |
return response.data; | |
}; | |
export const createBill = async (params: unknown) => { | |
const response = await apiClientPW.post(`/bills/`, params); | |
return response.data; | |
}; | |
export const uploadBill = async (billId: string, params: any) => { | |
const response = await apiClientPW.post(`/docs?entityId=${billId}&entityType=Bill`, params, { | |
headers: { | |
'Content-Type': 'multipart/form-data' | |
} | |
}); | |
return response.data; | |
}; | |
export const uploadBillToOwnerPortal = async (documentId: string, fileName: string) => { | |
const response = await apiClientPW.put(`/docs/${documentId}`, { | |
publishToOwnerPortal: true, | |
fileName: fileName, | |
}); | |
return response.data; | |
}; | |
export const fetchAllWorkorders = async () => { | |
const response = await apiClientPW.get(`/workorders?limit=5000`); | |
return response.data; | |
}; | |
export const fetchUnitsJson = async () => { | |
const response = await axios.get(PW_CONFIG.PW_FETCH_ALL_UNITS); | |
return response.data; | |
}; | |
export const fetchAllWorkordersJson = async () => { | |
const response = await axios.get(PW_CONFIG.PW_FETCH_ALL_WORKORDERS); | |
return response.data; | |
}; | |
export const fetchLatestWorkordersJson = async () => { | |
const response = await axios.get(PW_CONFIG.PW_FETCH_LATEST_WORKORDERS); | |
return response.data; | |
}; | |
export const fetchAllVendorsJson = async () => { | |
const response = await axios.get(PW_CONFIG.PW_FETCH_ALL_VENDORS); | |
return response.data; | |
}; | |
export const getIndexByLabel = (data: Column[], label: string): number | undefined => { | |
const column = data.find((col) => col.label === label); | |
return column ? parseInt(column.index) : undefined; | |
}; | |