stuctured envelopa and envelopb integration

This commit is contained in:
Jaanu423
2026-01-09 18:31:43 +05:30
parent fa8303fb89
commit d803a89baa
4 changed files with 139 additions and 102 deletions
+12 -24
View File
@@ -1,5 +1,5 @@
import { useInfiniteQuery, useMutation, useQuery } from '@tanstack/react-query';
import { fetchDashboard, fetchLiveAuction, fetchLiveTender, fetchPurchaseAuction, fetchPurchaseTender, offlineAuctionPurchase, userLogin, offlineTenderPurchase, fetchTenderById, proceedToBid, submitEnvelopeA, submitEnvelopeB } from './apis';
import { fetchDashboard, fetchLiveAuction, fetchLiveTender, fetchPurchaseAuction, fetchPurchaseTender, offlineAuctionPurchase, userLogin, offlineTenderPurchase, fetchTenderById, proceedToBid, submitEnvelopeA, submitEnvelopeB, uploadEnvelopeFile, UploadArgs } from './apis';
import { ToastAndroid } from 'react-native';
// User
@@ -32,7 +32,7 @@ export const useFetchPurchaseTender = () => {
getNextPageParam: (lastPage, allPages) => {
console.log('last page : ', lastPage)
console.log("all page : ", allPages)
const {totalCount } = lastPage;
const { totalCount } = lastPage;
const totalPages = Math.ceil(totalCount / 10);
const nextPage = allPages.length;
@@ -122,29 +122,17 @@ export const useProceedToBid = (tenderId?: string) => {
};
export const useSubmitEnvelopeA = (onSuccessCallback?: () => void) => {
return useMutation({
export const useSubmitEnvelopeA = () =>
useMutation({
mutationFn: submitEnvelopeA,
onSuccess: (data) => {
ToastAndroid.show(data?.message || 'Submitted successfully', ToastAndroid.SHORT)
onSuccessCallback?.()
},
onError: (error: any) => {
console.log('Envelope A submit error:', error)
ToastAndroid.show('Something went wrong', ToastAndroid.SHORT)
},
})
}
export const useSubmitEnvelopeB = (onSuccessCallback?: () => void) => {
return useMutation({
export const useSubmitEnvelopeB = () =>
useMutation({
mutationFn: submitEnvelopeB,
onSuccess: (data) => {
ToastAndroid.show(data?.message || 'Submitted successfully', ToastAndroid.SHORT)
onSuccessCallback?.()
},
onError: (error: any) => {
console.log('Envelope A submit error:', error)
ToastAndroid.show('Something went wrong', ToastAndroid.SHORT)
},
})
}
export const useUploadEnvelopeFile = () =>
useMutation({
mutationFn: uploadEnvelopeFile,
})
+39 -3
View File
@@ -3,7 +3,15 @@ import { DASHBOARD_COUNT, GET_MY_AUCTION, GET_MY_TENDER, GET_TENDER_DETAILS, LIV
import { apiCall } from "../../Axios/Axios";
// User
export type UploadArgs = {
activeEnvelope: 'A' | 'B'
file: {
uri: string
name: string
type: string
}
payload: any
}
export const userLogin = async (payload: { emailAdd: string, password: string }): Promise<any> => {
try {
// const response = await axios.post(LOG_IN_URL, { ...payload, divice: "mobileApp" });
@@ -85,14 +93,42 @@ export const proceedToBid = async (tenderId: string): Promise<any> => {
}
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 submitEnvelopeFileB = async (payload: any) => {
const { data } = await apiCall<any>('post', SUBMIT_ENVELOPE_FILE_B, payload)
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
}