53 lines
1.2 KiB
TypeScript
53 lines
1.2 KiB
TypeScript
"use server";
|
|
import { fetchDataWithToken, updateDataWithToken } from "../api-fetcher";
|
|
import {
|
|
baseUrl,
|
|
FilterList,
|
|
FilterListInterface,
|
|
defaultFilterList,
|
|
} from "../basics";
|
|
|
|
const CompanyListEndpoint = `${baseUrl}/company/list`;
|
|
const CompanyCreateEndpoint = `${baseUrl}/company/create`;
|
|
const CompanyUpdateEndpoint = `${baseUrl}/company/update`;
|
|
|
|
interface CompanyUpdateInterface {
|
|
uuid: string;
|
|
payload: any;
|
|
}
|
|
|
|
async function retrieveCompanyList(payload: FilterListInterface) {
|
|
const feedObject = new FilterList(payload).filter();
|
|
const tokenResponse: any = await fetchDataWithToken(
|
|
CompanyListEndpoint,
|
|
feedObject,
|
|
"POST",
|
|
false
|
|
);
|
|
return tokenResponse;
|
|
}
|
|
|
|
async function updateCompany(payload: any) {
|
|
const { uu_id: extractedField, ...payloadBody } = payload;
|
|
const tokenResponse: any = await updateDataWithToken(
|
|
CompanyUpdateEndpoint,
|
|
extractedField,
|
|
payloadBody,
|
|
"POST",
|
|
false
|
|
);
|
|
return tokenResponse;
|
|
}
|
|
|
|
async function createCompany(payload: any) {
|
|
const tokenResponse: any = await fetchDataWithToken(
|
|
CompanyCreateEndpoint,
|
|
payload,
|
|
"POST",
|
|
false
|
|
);
|
|
return tokenResponse;
|
|
}
|
|
|
|
export { retrieveCompanyList, updateCompany, createCompany };
|