From 26fc703df9aa4275ace70d6ec9a8533f54afff76 Mon Sep 17 00:00:00 2001 From: rohit-kumar-fullstack Date: Tue, 13 Jan 2026 13:00:16 +0530 Subject: [PATCH] merge signup process --- src/Screens/Auction/LiveAuction.tsx | 52 +++--- src/Screens/Auction/PurchaseAuction.tsx | 19 --- src/Screens/Login/Login.tsx | 204 ++++++++++++------------ src/Screens/Splash/Splash.tsx | 43 ++--- src/Services/BBPS/Hooks.ts | 4 - 5 files changed, 150 insertions(+), 172 deletions(-) diff --git a/src/Screens/Auction/LiveAuction.tsx b/src/Screens/Auction/LiveAuction.tsx index 40519f9..525c7c3 100644 --- a/src/Screens/Auction/LiveAuction.tsx +++ b/src/Screens/Auction/LiveAuction.tsx @@ -10,6 +10,8 @@ import { useDispatch, useSelector } from 'react-redux'; import { togglePurchaseAuction } from '../../Redux/Slices/selectPurchaseAuction'; import { apiCall } from '../../Axios/Axios'; import { GET_MY_AUCTION } from '../../Services/BBPS/ApiUrls'; +import SkeltonList from '../../Component/Skelton/SkeltonList'; +import Skeleton from '../../Component/Skelton/Skelton'; const LiveAuction = () => { const Dispatch = useDispatch() @@ -136,36 +138,40 @@ const LiveAuction = () => { )} + { + isPending ? : + { + onEndReachedCalledDuringMomentum.current = false; + }} - onMomentumScrollBegin={() => { - onEndReachedCalledDuringMomentum.current = false; - }} + ListFooterComponent={renderFooter} - ListFooterComponent={renderFooter} + refreshControl={ + + } - refreshControl={ - - } + } + - initialNumToRender={6} - maxToRenderPerBatch={6} - windowSize={7} - removeClippedSubviews - /> ); diff --git a/src/Screens/Auction/PurchaseAuction.tsx b/src/Screens/Auction/PurchaseAuction.tsx index da3969f..3d67f2a 100644 --- a/src/Screens/Auction/PurchaseAuction.tsx +++ b/src/Screens/Auction/PurchaseAuction.tsx @@ -65,25 +65,6 @@ const PurchaseAuction = () => { { }} placeholder='Search....' filterPress={() => { setAllBoolean((prev: any) => ({ ...prev, isShowFilter: !prev.isShowFilter })) }} /> {isPending ? : - // index.toString()} - // showsVerticalScrollIndicator={false} - // contentContainerStyle={{ paddingBottom: 200, paddingHorizontal: 10 }} - // renderItem={({ item, index }) => ( - // { - // }} - // onStartBidding={() => { - // Dispatch(setAuction(item)) - // navigation.navigate(NavigationString.Emd) - // }} - // buttonEnable={isAuctionActive(item)} - // isAuctionEnd={isAuctionEnd(item)} - // /> - // )} - // /> ( diff --git a/src/Screens/Login/Login.tsx b/src/Screens/Login/Login.tsx index 8c4bfb9..3cab46d 100644 --- a/src/Screens/Login/Login.tsx +++ b/src/Screens/Login/Login.tsx @@ -36,123 +36,129 @@ const Login = () => { const [auctionLoading, setAuctionLoading] = useState(false); const { mutate: loginMutate } = useLogin(); const { mutate: auctionMutate } = useAuctionLogin(); - const {data}=useGetDesignation(); + const { data } = useGetDesignation(); const { mutate: registrationStateMutate } = useRagistrationState(); - const { data: MasterData}=usefetchMasterData() + const { data: MasterData } = usefetchMasterData() -const handleGetData = async () => { + const handleGetData = async () => { registrationStateMutate(undefined, { - onSuccess: (res: any) => { - console.log('Registration status response try :', res); + onSuccess: (res: any) => { - if (res?.statusCode === 200) { - const { registrationStatus, contOtherId, contOrganization } = res.data; - const params = { otherId: contOtherId, orgType: contOrganization }; + if (res?.statusCode === 200) { + const { registrationStatus, contOtherId, contOrganization } = res.data; + const params = { otherId: contOtherId, orgType: contOrganization }; - switch (registrationStatus) { - case null: - case undefined: - - Navigation.replace(NavigationString.Registration); - break; - case 'Pending': + switch (registrationStatus) { + case null: + case undefined: - // handleRoute(params); - break; - case 'Complete': - case 'Completed': - Navigation.dispatch( - CommonActions.reset({ - index: 0, - routes: [{ name: NavigationString.Home }], - }), - ); - break; - default: - { - console.log("attempting navigation to Ragistration") - Navigation.replace(NavigationString.Registration);} - break; - } - return; - } + Navigation.replace(NavigationString.Registration); + break; + case 'Pending': - if (res?.statusCode === 404) { - console.warn('Registration API returned 404'); - Navigation.replace('Registration'); - return; - } - - Navigation.replace('Registration'); - }, - onError: (error: any) => { - console.error('Registration status error catch :', error); - - if (error?.response?.status === 500) { - Alert.alert('Server error', 'Something went wrong. Please try again later.'); - return; - } - - if (error?.request) { - Alert.alert('Network Error', 'Please check your internet connection.'); - return; - } - - Alert.alert('Error', error?.message || 'Something went wrong'); - Navigation.replace('Registration'); - }, - }); -}; - - - - const HandleLogin = async (values: any) => { - if (activeType === 'tender') { - setLoginLoading(true); - loginMutate( - { password: values.password, emailAdd: values.email }, - { - onSuccess: res => { - if (res.statusCode == 200) { - Dispatch(setToken({ ...res.data, token: res.token })); - handleGetData(); - - - } - setLoginLoading(false); - }, - onError: err => { - showErrorAlert(err.message); - setLoginLoading(false); - }, - }, - ); - } else { - setAuctionLoading(true); - auctionMutate( - { password: values.password, emailAdd: values.email }, - { - onSuccess: res => { - if (res.statusCode == 200) { - Dispatch(setToken({ ...res.data, token: res.token })); + // handleRoute(params); + break; + case 'Complete': + case 'Completed': Navigation.dispatch( CommonActions.reset({ index: 0, routes: [{ name: NavigationString.Home }], }), ); - } - setAuctionLoading(false); + break; + default: + { + console.log("attempting navigation to Ragistration") + Navigation.replace(NavigationString.Registration); + } + break; + } + return; + } + + if (res?.statusCode === 404) { + console.warn('Registration API returned 404'); + Navigation.replace('Registration'); + return; + } + + Navigation.replace('Registration'); + }, + onError: (error: any) => { + console.error('Registration status error catch :', error); + + if (error?.response?.status === 500) { + Alert.alert('Server error', 'Something went wrong. Please try again later.'); + return; + } + + if (error?.request) { + Alert.alert('Network Error', 'Please check your internet connection.'); + return; + } + + Alert.alert('Error', error?.message || 'Something went wrong'); + Navigation.replace('Registration'); + }, + }); + }; + + + + const HandleLogin = async (values: any) => { + try { + if (activeType === 'tender') { + setLoginLoading(true); + loginMutate( + { password: values.password, emailAdd: values.email }, + { + onSuccess: res => { + if (res.statusCode == 200) { + Dispatch(setToken({ ...res.data, token: res.token, userType: activeType })); + handleGetData(); + } else { + showErrorAlert(res.message) + } + + }, + onError: err => { + showErrorAlert(err.message); + }, }, - onError: err => { - showErrorAlert(err.message); - setAuctionLoading(false); + ); + } else { + setAuctionLoading(true); + auctionMutate( + { password: values.password, emailAdd: values.email }, + { + onSuccess: res => { + if (res.statusCode == 200) { + Dispatch(setToken({ ...res.data, token: res.token, userType: activeType })); + Navigation.dispatch( + CommonActions.reset({ + index: 0, + routes: [{ name: NavigationString.Home }], + }), + ); + } + + }, + onError: err => { + showErrorAlert(err.message); + setLoginLoading(false); + }, }, - }, - ); + ); + } + } catch (error) { + + } finally { + setAuctionLoading(false); } + }; const isLoading = activeType === 'tender' ? loginLoading : auctionLoading; diff --git a/src/Screens/Splash/Splash.tsx b/src/Screens/Splash/Splash.tsx index 2dcfd07..49d51bb 100644 --- a/src/Screens/Splash/Splash.tsx +++ b/src/Screens/Splash/Splash.tsx @@ -12,7 +12,7 @@ import NavigationString from '../../Constant/NavigationString'; // Navigation type export type Navigation = { reset(arg0: { - index: number; + index: number; routes: { name: string; }[]; }): unknown; navigate: (route: string, params?: { [key: string]: any }) => void; @@ -29,12 +29,11 @@ const Splash: React.FC = () => { const [isHydrated, setIsHydrated] = useState(false); const [isLoading, setIsLoading] = useState(true); - // Wait for Redux hydration (works with/without redux-persist) useEffect(() => { let unsubscribe: any; const checkHydration = () => { const token = (store.getState() as any).token?.token; - if (token !== undefined) { // Defined = hydrated (null/empty/string ok) + if (token !== undefined) { setIsHydrated(true); unsubscribe?.(); } @@ -46,23 +45,11 @@ const Splash: React.FC = () => { return () => unsubscribe?.(); }, []); - const getToken = useCallback(async (): Promise => { - try { - // Redux first (post-hydration), then AsyncStorage fallback - let token = reduxToken; - if (token === undefined) { - token = await AsyncStorage.getItem('token'); - } - return token || null; - } catch (error) { - console.error('Token fetch error:', error); - return null; - } - }, [reduxToken]); + const routeByOrgType = (params: { otherId: any; orgType: any }) => { const orgType = String(params.orgType); - console.log("hitting here ") + console.log("hitting here ") if (orgType === '4' || orgType === '5' || orgType === '6') { navigation.replace('StageThree', params); return; @@ -138,22 +125,25 @@ const Splash: React.FC = () => { useNativeDriver: true, }).start(); - const token = await getToken(); - console.log("Token after hydration -", token, typeof token, !!token); - if (!token) { - console.log('No valid token, navigating to Login'); + if (!reduxToken.token) { navigation.reset({ index: 0, - routes: [{ name: NavigationString.Login || 'Signin' }], // Fallback + routes: [{ name: NavigationString.Login }], }); return; } - console.log('Valid token, fetching registration data'); - await handleGetData(); + if (reduxToken.userType == 'tender') { + await handleGetData(); + } else { + navigation.reset({ + index: 0, + routes: [{ name: NavigationString.Home }], + }); + } + } catch (error) { - console.error('Splash Error:', error); navigation.reset({ index: 0, routes: [{ name: NavigationString.Login || 'Signin' }], @@ -163,10 +153,9 @@ const Splash: React.FC = () => { } }; - // Small delay ensures hydration + native animation complete const timeoutId = setTimeout(runSplash, 200); return () => clearTimeout(timeoutId); - }, [isFocused, isHydrated, getToken]); + }, [isFocused, isHydrated]); if (!isHydrated) { return ( diff --git a/src/Services/BBPS/Hooks.ts b/src/Services/BBPS/Hooks.ts index 7d29e60..b42008e 100644 --- a/src/Services/BBPS/Hooks.ts +++ b/src/Services/BBPS/Hooks.ts @@ -1,17 +1,14 @@ import { useInfiniteQuery, useMutation, useQuery } from '@tanstack/react-query'; import { contractorStageThreeSubmit, contractorStageTwoSubmit, fetchAuctionItem, fetchCityDropdown, fetchDashboard, fetchEmdCheck, fetchLiveAuction, fetchLiveTender, fetchMasterData, fetchPurchaseAuction, fetchPurchaseAuctionList, fetchPurchaseTender, fetchTenderById, getAuction, getDesignation, getRagistrationState, offlineAuctionPurchase, offlineTenderPurchase, partnerShipSubmit, proceedToBid, registerContractor, sendAadhaarOtp, submitEnvelopeA, submitEnvelopeB, uploadEnvelopeFile, userAuctionLogin, userLogin, verifyAadhaarOtp, verifyGstNumber, verifyPanHandler, viewAuctionDocumentDownload, viewAuctionDocuments, viewAuctionItemDocuments, fetchPurchaseAuctionPage } from './apis'; -import { apiCall } from '../../Axios/Axios'; // User export const useLogin = () => { - console.log("hitting here") return useMutation({ mutationFn: (payload: { emailAdd: string, password: string }) => userLogin(payload), }); }; export const useAuctionLogin = () => { - console.log("hitting here") return useMutation({ mutationFn: (payload: { emailAdd: string, password: string }) => userAuctionLogin(payload), }); @@ -194,7 +191,6 @@ export const useRagistrationState = () => { }); }; -////////////////////////////////////////////////////// export const usefetchMasterData = () => { return useQuery({