stuctured envelopa and envelopb integration

This commit is contained in:
Jaanu423
2026-01-09 15:34:10 +05:30
parent 0e93334941
commit fa8303fb89
6 changed files with 263 additions and 75 deletions
+1
View File
@@ -7,6 +7,7 @@ const colors = {
// Secondary (Warm contrast)
secondary: '#1B4B66', // Deep blue for balance
secondaryLight: '#639599', // Muted blue
secondaryHighLight: '#e1eff2', // Very light blue (backgrounds)
// Status colors
success: '#22C55E', // Green
@@ -15,6 +15,10 @@ import MyInput from '../../../../src/Component/MyInput';
import { pick, types } from '@react-native-documents/picker';
import { InsideHeader } from '../../../Component/Index';
import colors from '../../../Constant/Color';
import { SUBMIT_ENVELOPE_A, SUBMIT_ENVELOPE_B } from '../../../Services/BBPS/ApiUrls';
import axios from 'axios';
import { Fontisto } from '@react-native-vector-icons/fontisto';
import { useSubmitEnvelopeA, useSubmitEnvelopeB } from '../../../Services/BBPS/Hooks';
type EnvelopeType = 'A' | 'B' | 'C';
type EnvelopeFormState = {
@@ -33,27 +37,18 @@ interface InfoRowProps {
value: string;
}
interface TenderBiddingData {
data?: {
tenderNumber?: string;
nitNo?: string;
emdInFig?: string;
tenderRebid?: boolean;
showEA?: boolean;
showEB?: boolean;
showEC?: boolean;
tenderEnvelopeAList?: any[];
tenderEnvelopeBList?: any[];
tenderEnvelopeCList?: any[];
};
}
const TenderBidding = () => {
const route = useRoute();
const route = useRoute<any>();
const navigation = useNavigation();
const { mutate: submitEnvelopeA, isPending } = useSubmitEnvelopeA(() => {
navigation.goBack()
})
const { mutate: submitEnvelopeB, isPending: isPendingB } = useSubmitEnvelopeB(() => {
navigation.goBack()
})
const [bidData] = useState<any>(route.params?.tenderData || null);
const tenderData = route.params?.bidData || null;
const tenderData: any= route.params?.bidData || null;
const [activeEnvelope, setActiveEnvelope] = useState<EnvelopeType | null>('A');
const [isLoading, setIsLoading] = useState(false);
const [envelopForm, setEnvelopForm] = useState<EnvelopeFormState>({
@@ -64,7 +59,7 @@ const TenderBidding = () => {
const [loading, setLoading] = useState(false)
const [loadingUpload, setLoadingUpload] = useState(false)
const [check, setCheck] = useState(false)
const InfoRow = ({ title, value }: InfoRowProps) => (
<View style={styles.infoRow}>
@@ -145,7 +140,7 @@ const TenderBidding = () => {
activeEnvelope === envelopeType !== 'C' &&
!bidData?.[`envelope${envelopeType}SubmittStatus`];
// console.log("tender ana : ", tenderData)
return (
<View key={sequenceId}>
<View style={styles.envelopeItem}>
@@ -255,8 +250,9 @@ const TenderBidding = () => {
};
const buildEnvelopePayload = () => {
const list =
bidData?.[`tenderEnvelope${activeEnvelope}List`] || [];
tenderData?.[`tenderEnvelope${activeEnvelope}List`] || [];
const formValues = envelopForm?.[activeEnvelope] || {};
// 🔹 NON-FILE FIELDS (labelType !== '3')
@@ -306,17 +302,17 @@ const TenderBidding = () => {
};
});
return payload = {
deptId: bidData?.deptId,
tenderId: bidData?.tenderId,
const payload: any = {
deptId: tenderData?.deptId,
tenderId: tenderData?.tenderId,
[`tenderEnvelope${activeEnvelope}NameId`]:
bidData?.[`tenderEnvelope${activeEnvelope}List`]?.[0]?.[
tenderData?.[`tenderEnvelope${activeEnvelope}List`]?.[0]?.[
`tenderEnvelope${activeEnvelope}NameId`
],
[`envelope${activeEnvelope}TemplateName`]:
bidData?.[`tenderEnvelope${activeEnvelope}List`]?.[0]?.[
tenderData?.[`tenderEnvelope${activeEnvelope}List`]?.[0]?.[
`envelope${activeEnvelope}TemplateName`
],
@@ -324,10 +320,11 @@ const TenderBidding = () => {
? fileData
: saveData,
};
// console.log("payload : ", payload)
return payload;
};
const validateEnvelope = () => {
const list = bidData?.[`tenderEnvelope${activeEnvelope}List`] || [];
const formValues = envelopForm[activeEnvelope];
@@ -351,57 +348,35 @@ const TenderBidding = () => {
return !missing;
};
const handleSubmitEnvelopeA = async () => {
const handleSubmitEnvelopeA = () => {
if (!validateEnvelope()) {
Alert.alert('Validation Error', 'Please fill all mandatory fields');
return;
Alert.alert('Validation Error', 'Please fill all mandatory fields')
return
}
const payload = buildEnvelopePayload();
console.log('Envelope A Payload:', payload);
setLoading(true)
const payload = buildEnvelopePayload()
console.log('Envelope A Payload:', payload)
if (envelopForm?.[activeEnvelope]?.[3]) {
handleSubmitEnvelopeFile()
}
try {
const res = await apiCallForPostWithToken(SUBMIT_ENVELOPE_A, payload)
console.log("res A envelop : ", res)
ToastAndroid.show(res.message, ToastAndroid.SHORT)
navigation.goBack()
} catch (error) {
console.log("error A envelop submit : ", error)
} finally {
setLoading(false)
}
};
const handleSubmitEnvelopeB = async () => {
submitEnvelopeA(payload)
}
const handleSubmitEnvelopeB = () => {
if (!validateEnvelope()) {
Alert.alert('Validation Error', 'Please fill all mandatory fields');
return;
Alert.alert('Validation Error', 'Please fill all mandatory fields')
return
}
setLoading(true)
const payload = buildEnvelopePayload();
console.log('Envelope B Payload:', payload);
const payload = buildEnvelopePayload()
console.log('Envelope A Payload:', payload)
if (envelopForm?.[activeEnvelope]?.[3]) {
handleSubmitEnvelopeFile()
}
try {
const res = await apiCallForPostWithToken(SUBMIT_ENVELOPE_B, payload)
console.log("res B envelop : ", res)
ToastAndroid.show(res.message, ToastAndroid.SHORT)
navigation.goBack()
} catch (error) {
console.log("error B envelop submit : ", error)
} finally {
setLoading(false)
}
submitEnvelopeB(payload)
}
const handleSubmitEnvelopeFile = async () => {
@@ -422,7 +397,7 @@ const TenderBidding = () => {
console.log("reuestDto for fil doc : ", formData)
// return
const res = await apiCallForPostWithToken(activeEnvelope === 'B' ? SUBMIT_ENVELOPE_B : SUBMIT_ENVELOPE_A, payload)
const res = await axios.post(activeEnvelope === 'B' ? SUBMIT_ENVELOPE_B : SUBMIT_ENVELOPE_A, payload)
console.log(`res file ${activeEnvelope} Payload:`, res)
ToastAndroid.show(res.message, ToastAndroid.SHORT)
// navigation.goBack()
@@ -508,13 +483,13 @@ const TenderBidding = () => {
renderItem={({ item }) => renderEnvelopeItem({ item, envelopeType: activeEnvelope })}
scrollEnabled={false}
/>
{/* <View style={[styles.infoRow, { flexDirection: 'row', gap: 10 }]}>
<View style={[styles.infoRow, { flexDirection: 'row', gap: 10 }]}>
<TouchableOpacity onPress={() => setCheck(!check)}>
{check ? <Fontisto name="checkbox-active" size={24} color={colors.primary} /> :
<Fontisto name="checkbox-passive" size={24} color={colors.primary} />
}</TouchableOpacity>
<Text>Check First Terms&Condition</Text>
</View> */}
</View>
</View>
)}
<View style={styles.footer}>
@@ -566,7 +541,7 @@ const styles = StyleSheet.create({
alignItems: 'center',
},
card: {
backgroundColor: '#fff',
backgroundColor: colors.primaryHighlight,
borderRadius: 12,
padding: 16,
marginBottom: 16,
@@ -607,7 +582,7 @@ const styles = StyleSheet.create({
flexWrap: 'wrap',
},
envelopeButton: {
backgroundColor: '#EEF2FF',
backgroundColor: colors.secondaryHighLight,
paddingVertical: 10,
paddingHorizontal: 14,
borderRadius: 8,
@@ -615,7 +590,7 @@ const styles = StyleSheet.create({
alignItems: 'center',
},
envelopeButtonText: {
color: '#3F51B5',
color: colors.primary,
fontWeight: '600',
fontSize: 14,
},
@@ -625,7 +600,7 @@ const styles = StyleSheet.create({
borderRadius: 10,
padding: 12,
marginBottom: 12,
backgroundColor: '#f9f9f9',
backgroundColor: colors.primaryHighlight,
flexDirection: 'row',
justifyContent: 'space-between'
},
@@ -635,7 +610,7 @@ const styles = StyleSheet.create({
marginVertical: 20,
},
primaryButton: {
backgroundColor: '#3F51B5',
backgroundColor: colors.primary,
paddingVertical: 14,
paddingHorizontal: 28,
borderRadius: 10,
@@ -657,7 +632,7 @@ const styles = StyleSheet.create({
alignItems: 'center',
},
secondaryButtonText: {
color: '#3F51B5',
color: colors.primary,
fontWeight: '600',
fontSize: 15,
},
+28 -1
View File
@@ -1,5 +1,6 @@
import { useInfiniteQuery, useMutation, useQuery } from '@tanstack/react-query';
import { fetchDashboard, fetchLiveAuction, fetchLiveTender, fetchPurchaseAuction, fetchPurchaseTender, offlineAuctionPurchase, userLogin, offlineTenderPurchase, fetchTenderById, proceedToBid } from './apis';
import { fetchDashboard, fetchLiveAuction, fetchLiveTender, fetchPurchaseAuction, fetchPurchaseTender, offlineAuctionPurchase, userLogin, offlineTenderPurchase, fetchTenderById, proceedToBid, submitEnvelopeA, submitEnvelopeB } from './apis';
import { ToastAndroid } from 'react-native';
// User
@@ -121,3 +122,29 @@ export const useProceedToBid = (tenderId?: string) => {
};
export const useSubmitEnvelopeA = (onSuccessCallback?: () => void) => {
return 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({
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)
},
})
}
+14 -1
View File
@@ -1,5 +1,5 @@
import axios from "axios";
import { DASHBOARD_COUNT, 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 } from "./ApiUrls";
import { DASHBOARD_COUNT, 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, SUBMIT_ENVELOPE_A, SUBMIT_ENVELOPE_B, SUBMIT_ENVELOPE_FILE_A, SUBMIT_ENVELOPE_FILE_B, TENDER_LOGIN } from "./ApiUrls";
import { apiCall } from "../../Axios/Axios";
// User
@@ -83,3 +83,16 @@ export const proceedToBid = async (tenderId: string): Promise<any> => {
);
return data;
}
export const submitEnvelopeA = async (payload: any) => {
const { data } = await apiCall<any>('post', SUBMIT_ENVELOPE_A, payload)
return data
}
export const submitEnvelopeB = async (payload: any) => {
const { data } = await apiCall<any>('post', SUBMIT_ENVELOPE_B, payload)
return data
}
export const submitEnvelopeFileB = async (payload: any) => {
const { data } = await apiCall<any>('post', SUBMIT_ENVELOPE_FILE_B, payload)
return data
}