58 lines
1.4 KiB
TypeScript
58 lines
1.4 KiB
TypeScript
import api from "../axios";
|
|
|
|
export const company = {
|
|
async fetch(
|
|
accessToken: string,
|
|
id: string,
|
|
options?: { includeAddress?: boolean },
|
|
) {
|
|
const params: Record<string, string> = {};
|
|
if (options?.includeAddress) params.includeAddress = "true";
|
|
|
|
const company = await api.get(`/v1/company/companies/${id}`, {
|
|
params,
|
|
headers: {
|
|
Authorization: `Bearer ${accessToken}`,
|
|
},
|
|
});
|
|
return company.data;
|
|
},
|
|
async fetchMany(
|
|
accessToken: string,
|
|
page: number = 1,
|
|
search?: string,
|
|
rpp: number = 30,
|
|
) {
|
|
const params: Record<string, unknown> = { page, rpp };
|
|
if (search && search.length > 0) params.search = search;
|
|
|
|
const companies = await api.get("/v1/company/companies", {
|
|
params,
|
|
headers: {
|
|
Authorization: `Bearer ${accessToken}`,
|
|
},
|
|
});
|
|
|
|
return companies.data;
|
|
},
|
|
async count(accessToken: string) {
|
|
const response = await api.get("/v1/company/count", {
|
|
headers: {
|
|
Authorization: `Bearer ${accessToken}`,
|
|
},
|
|
});
|
|
return response.data.data.count;
|
|
},
|
|
async fetchConfigurations(accessToken: string, id: string) {
|
|
const configurations = await api.get(
|
|
`/v1/company/companies/${id}/configurations`,
|
|
{
|
|
headers: {
|
|
Authorization: `Bearer ${accessToken}`,
|
|
},
|
|
},
|
|
);
|
|
return configurations.data;
|
|
},
|
|
};
|