346 lines
9.2 KiB
TypeScript
346 lines
9.2 KiB
TypeScript
import axios from "axios";
|
|
import { AUCTION_DOCUMENT_DOWNLOAD, DASHBOARD_COUNT, EMD_CHECK, FORARD_AUCTION_ITEM, GET_AUCTION_DETAILS, GET_MY_AUCTION, GET_MY_TENDER, GET_TENDER_DETAILS, LIVE_AUCTION, LIVE_TENDER, LOG_IN_URL, PROCEED_PURCHASE_AUCTION, PROCEED_TO_BID, PURCHASE_TENDER_OFFLINE, TENDER_LOGIN, PURCHASE_AUCTION_LIST, PURCHASE_OFFLINE_AUCTION, REVERSE_AUCTION_ITEM, VIEW_AUCTION_DOCUMENTS, VIEW_AUCTION_ITEM_DETAIL, STAGETHREE, REJ_STAGE_TWO, GETCONTRACTORBYSTATE, GET_MASTER_DATA, ALL_DESIGNATION, GET_REGISTRATION_STATE, PARTNER_API_ENDPOINT, SAVE_CONTRACTOR_STAGE1, VERIFY_GST, VERIFY_ADHAR, SEND_ADHAROTP, SUBMIT_ENVELOPE_FILE_B, SUBMIT_ENVELOPE_FILE_A, SUBMIT_ENVELOPE_A, SUBMIT_ENVELOPE_B, VERIFY_ORGPAN, PURCHASE_AUCTION_PAGE } from "./ApiUrls";
|
|
import { apiCall } from "../../Axios/Axios";
|
|
|
|
// User
|
|
export type UploadArgs = {
|
|
activeEnvelope: 'A' | 'B'
|
|
file: {
|
|
uri: string
|
|
name: string
|
|
type: string
|
|
}
|
|
payload: any
|
|
}
|
|
type DropdownOption = { label: string; value: number | string };
|
|
|
|
type State = { stateId: number; stateName: string };
|
|
type ContractorClass = { contClassId: number; contClassName?: string };
|
|
type Org = { orgId: number; organizationType: string };
|
|
type MSME = { msmeId: number; comName: string };
|
|
type Social = { socialCategoryId: number; categoryName: string };
|
|
type Designation = { designationid: number; designationName: string };
|
|
type City = { id: number; name: string };
|
|
|
|
export const userLogin = async (payload: { emailAdd: string, password: string }): Promise<any> => {
|
|
try {
|
|
// const response = await axios.post(LOG_IN_URL, { ...payload, divice: "mobileApp" });
|
|
const response = await axios.post(TENDER_LOGIN, { ...payload, device: "mobileApp" });
|
|
return response.data;
|
|
} catch (error: any) {
|
|
throw error.response?.data || error.message;
|
|
}
|
|
};
|
|
|
|
export const userAuctionLogin = async (payload: { emailAdd: string, password: string }): Promise<any> => {
|
|
try {
|
|
const response = await axios.post(LOG_IN_URL, { ...payload, device: "mobileApp" });
|
|
return response.data;
|
|
} catch (error: any) {
|
|
throw error.response?.data || error.message;
|
|
}
|
|
};
|
|
|
|
export const fetchDashboard = async (): Promise<any> => {
|
|
const data = await apiCall<any>('get', `${DASHBOARD_COUNT}`);
|
|
return data
|
|
}
|
|
|
|
export const fetchPurchaseAuction = async (): Promise<any> => {
|
|
const data = await apiCall<any>('get', `${GET_MY_AUCTION}`);
|
|
return data
|
|
}
|
|
export const fetchPurchaseAuctionPage = async (payload: any): Promise<any> => {
|
|
console.log(payload,'[[[[[[[[[[[[[[[[[[[[[[[[');
|
|
|
|
const data = await apiCall<any>('get', `${PURCHASE_AUCTION_PAGE}`, {}, payload);
|
|
return data
|
|
}
|
|
|
|
export const fetchLiveAuction = async (payload: any): Promise<any> => {
|
|
const data = await apiCall<any>('get', `${LIVE_AUCTION}`, {}, payload);
|
|
return data
|
|
}
|
|
|
|
// Auction Purchase offline
|
|
export const offlineAuctionPurchase = async (payload: any): Promise<any> => {
|
|
try {
|
|
const response = await apiCall<any>('post', `${PURCHASE_OFFLINE_AUCTION}`, payload);
|
|
return response;
|
|
} catch (error: any) {
|
|
throw error.response?.data || error.message;
|
|
}
|
|
};
|
|
|
|
// EMD
|
|
|
|
export const fetchEmdCheck = async (payload: any): Promise<any> => {
|
|
try {
|
|
const response = await apiCall<any>('get', `${EMD_CHECK}`, {}, payload);
|
|
return response;
|
|
} catch (error: any) {
|
|
throw error.response?.data || error.message;
|
|
}
|
|
};
|
|
|
|
export const fetchAuctionItem = async (payload: any): Promise<any> => {
|
|
try {
|
|
if (payload.status == 'Reverse') {
|
|
const response = await apiCall<any>('get', `${REVERSE_AUCTION_ITEM}`, {}, payload);
|
|
return response;
|
|
} else {
|
|
const response = await apiCall<any>('get', `${FORARD_AUCTION_ITEM}`, {}, payload);
|
|
return response;
|
|
}
|
|
|
|
|
|
} catch (error: any) {
|
|
throw error.response?.data || error.message;
|
|
}
|
|
};
|
|
|
|
// Tender Purchase offline
|
|
export const offlineTenderPurchase = async (payload: any): Promise<any> => {
|
|
try {
|
|
const response = await apiCall<any>('post', PURCHASE_TENDER_OFFLINE, payload);
|
|
return response.data;
|
|
} catch (error: any) {
|
|
throw error.response?.data || error.message;
|
|
}
|
|
};
|
|
|
|
// tender
|
|
export const fetchPurchaseTender = async ({
|
|
page,
|
|
size,
|
|
}: {
|
|
page: number;
|
|
size: number;
|
|
}) => {
|
|
return apiCall<any>(
|
|
'get',
|
|
`${GET_MY_TENDER}?page=${page}&size=${size}`
|
|
);
|
|
};
|
|
|
|
|
|
|
|
export const fetchLiveTender = async (): Promise<any> => {
|
|
const data = await apiCall<any>('get', `${LIVE_TENDER}`);
|
|
return data
|
|
}
|
|
export const fetchTenderById = async (tenderId: string): Promise<any> => {
|
|
const data = await apiCall<any>(
|
|
'get',
|
|
`${GET_TENDER_DETAILS}${tenderId}`
|
|
);
|
|
return data;
|
|
};
|
|
|
|
export const proceedToBid = async (tenderId: string): Promise<any> => {
|
|
const data = await apiCall<any>(
|
|
'get',
|
|
`${PROCEED_TO_BID}${tenderId}`
|
|
);
|
|
return data;
|
|
}
|
|
|
|
export const verifyPanHandler = (
|
|
payload: {
|
|
dob: string;
|
|
name: string;
|
|
panNumber: string;
|
|
}
|
|
): Promise<any> => {
|
|
return apiCall<any>(
|
|
'post',
|
|
VERIFY_ORGPAN,
|
|
payload,
|
|
);
|
|
};
|
|
|
|
|
|
export const fetchPurchaseAuctionList = async (payload: any): Promise<any> => {
|
|
const data = await apiCall<any>('post', `${PURCHASE_AUCTION_LIST}`, payload);
|
|
return data
|
|
}
|
|
|
|
export const getAuction = async (payload: any) => {
|
|
const selectedRes = await apiCall<any>('get', GET_AUCTION_DETAILS, {}, { id: payload.auctionId });
|
|
return selectedRes.data;
|
|
}
|
|
export const viewAuctionItemDocuments = async (payload: { auctionItemId: number }) => {
|
|
const selectedRes = await apiCall<any>('get', VIEW_AUCTION_ITEM_DETAIL, {}, payload);
|
|
return selectedRes.data;
|
|
}
|
|
export const viewAuctionDocuments = async (payload: { auctionId: number }) => {
|
|
const selectedRes = await apiCall<any>('get', VIEW_AUCTION_DOCUMENTS, {}, payload);
|
|
return selectedRes.data;
|
|
}
|
|
export const viewAuctionDocumentDownload = async (payload: { documentId: number, isAmendment: boolean }) => {
|
|
const selectedRes = await apiCall<any>('get', AUCTION_DOCUMENT_DOWNLOAD, {}, payload);
|
|
return selectedRes.data;
|
|
}
|
|
export const contractorStageThreeSubmit = (
|
|
payload: any
|
|
): Promise<any> => {
|
|
return apiCall<any>(
|
|
'post',
|
|
STAGETHREE,
|
|
payload,
|
|
);
|
|
};
|
|
|
|
export const contractorStageTwoSubmit = (
|
|
fileData: any
|
|
): Promise<any> => {
|
|
return apiCall<any>(
|
|
'post',
|
|
REJ_STAGE_TWO,
|
|
fileData,
|
|
undefined,
|
|
'multipart/form-data'
|
|
);
|
|
};
|
|
|
|
export const fetchCityDropdown = async (stateId: number): Promise<any> => {
|
|
const res = await apiCall<{ statusCode: number; data: City[] }>(
|
|
'get',
|
|
`${GETCONTRACTORBYSTATE}?stateId=${stateId}`,
|
|
);
|
|
console.log("--",res)
|
|
if (res.statusCode !== 200 || !res.data) {
|
|
throw new Error('Failed load cities');
|
|
}
|
|
|
|
return res.data.map(item => ({
|
|
label: item.name,
|
|
value: item.id,
|
|
}));
|
|
};
|
|
|
|
|
|
export const fetchMasterData = async (): Promise<any> => {
|
|
const data = await apiCall<any>(
|
|
'get',
|
|
`${GET_MASTER_DATA}`
|
|
);
|
|
return data;
|
|
};
|
|
export const getDesignation = async (): Promise<any> => {
|
|
const data = await axios.get(ALL_DESIGNATION).then((response) => response.data);
|
|
return data;
|
|
}
|
|
|
|
export const getRagistrationState = async (): Promise<any> => {
|
|
const data = await apiCall<any>(
|
|
'get',
|
|
`${GET_REGISTRATION_STATE}`
|
|
);
|
|
return data;
|
|
}
|
|
|
|
export const partnerShipSubmit = (
|
|
payload: any
|
|
): Promise<any> => {
|
|
return apiCall<any>(
|
|
'post',
|
|
PARTNER_API_ENDPOINT,
|
|
payload,
|
|
);
|
|
};
|
|
|
|
export const registerContractor = async (payload: any): Promise<any> => {
|
|
console.log("registerContractor payload : ", payload)
|
|
try {
|
|
const response = await axios.post(SAVE_CONTRACTOR_STAGE1, { ...payload, device: "mobileApp" });
|
|
return response.data;
|
|
} catch (error: any) {
|
|
throw error.response?.data || error.message;
|
|
}
|
|
};
|
|
|
|
|
|
|
|
export const sendAadhaarOtp = (
|
|
payload: any
|
|
): Promise<any> => {
|
|
return apiCall<any>('post', SEND_ADHAROTP, payload);
|
|
};
|
|
|
|
|
|
export type VerifyAadhaarOtpPayload = {
|
|
otp: string;
|
|
refNumber: string;
|
|
};
|
|
|
|
export const verifyAadhaarOtp = (
|
|
payload: {
|
|
otp: string;
|
|
refNumber: string;
|
|
}
|
|
): Promise<any> => {
|
|
return apiCall<any>(
|
|
'post',
|
|
VERIFY_ADHAR,
|
|
payload,
|
|
);
|
|
};
|
|
|
|
export type VerifyGstPayload = {
|
|
gstNumber: string;
|
|
};
|
|
|
|
export const verifyGstNumber = (
|
|
payload: {
|
|
gstNumber: string;
|
|
}
|
|
): Promise<any> => {
|
|
return apiCall<any>(
|
|
'post',
|
|
VERIFY_GST,
|
|
payload,
|
|
);
|
|
};
|
|
|
|
|
|
export const submitEnvelopeA = async (payload: any) => {
|
|
console.log('SUBMIT ENVELOPE A API CALLED', payload)
|
|
const { data } = await apiCall<any>('post', SUBMIT_ENVELOPE_A, payload)
|
|
console.log("data : ", data)
|
|
return data
|
|
}
|
|
export const submitEnvelopeB = async (payload: any) => {
|
|
console.log('SUBMIT ENVELOPE B API CALLED', payload)
|
|
const { data } = await apiCall<any>('post', SUBMIT_ENVELOPE_B, payload)
|
|
console.log("data : ", data)
|
|
return data
|
|
}
|
|
|
|
|
|
export const uploadEnvelopeFile = async ({
|
|
activeEnvelope,
|
|
file,
|
|
payload,
|
|
}: UploadArgs) => {
|
|
const formData = new FormData()
|
|
|
|
formData.append('files', {
|
|
uri: file.uri,
|
|
name: file.name,
|
|
type: file.type,
|
|
} as any)
|
|
|
|
formData.append('requestDto', JSON.stringify(payload))
|
|
|
|
const url =
|
|
activeEnvelope === 'B' ? SUBMIT_ENVELOPE_FILE_B : SUBMIT_ENVELOPE_FILE_A
|
|
|
|
const data = await apiCall('post', url, formData, {
|
|
headers: {
|
|
'Content-Type': 'multipart/form-data',
|
|
},
|
|
})
|
|
|
|
return data
|
|
} |