old version placed
This commit is contained in:
52
apicalls/company/company.tsx
Normal file
52
apicalls/company/company.tsx
Normal file
@@ -0,0 +1,52 @@
|
||||
"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 };
|
||||
Reference in New Issue
Block a user