merge signup process

This commit is contained in:
rohit-kumar-fullstack
2026-01-13 13:00:16 +05:30
parent eb849681a9
commit 26fc703df9
5 changed files with 150 additions and 172 deletions
+7 -1
View File
@@ -10,6 +10,8 @@ import { useDispatch, useSelector } from 'react-redux';
import { togglePurchaseAuction } from '../../Redux/Slices/selectPurchaseAuction'; import { togglePurchaseAuction } from '../../Redux/Slices/selectPurchaseAuction';
import { apiCall } from '../../Axios/Axios'; import { apiCall } from '../../Axios/Axios';
import { GET_MY_AUCTION } from '../../Services/BBPS/ApiUrls'; import { GET_MY_AUCTION } from '../../Services/BBPS/ApiUrls';
import SkeltonList from '../../Component/Skelton/SkeltonList';
import Skeleton from '../../Component/Skelton/Skelton';
const LiveAuction = () => { const LiveAuction = () => {
const Dispatch = useDispatch() const Dispatch = useDispatch()
@@ -136,7 +138,8 @@ const LiveAuction = () => {
</Text> </Text>
</Animated.View> </Animated.View>
)} )}
{
isPending ? <Skeleton /> :
<FlatList <FlatList
data={allBoolean.liveAuctionData ?? []} data={allBoolean.liveAuctionData ?? []}
renderItem={renderItem} renderItem={renderItem}
@@ -166,6 +169,9 @@ const LiveAuction = () => {
windowSize={7} windowSize={7}
removeClippedSubviews removeClippedSubviews
/> />
}
</View> </View>
); );
-19
View File
@@ -65,25 +65,6 @@ const PurchaseAuction = () => {
<SearchInput onChange={() => { }} placeholder='Search....' filterPress={() => { setAllBoolean((prev: any) => ({ ...prev, isShowFilter: !prev.isShowFilter })) }} /> <SearchInput onChange={() => { }} placeholder='Search....' filterPress={() => { setAllBoolean((prev: any) => ({ ...prev, isShowFilter: !prev.isShowFilter })) }} />
{isPending ? <Skelton /> {isPending ? <Skelton />
: :
// <FlatList
// data={data.data ||[]}
// keyExtractor={(_, index) => index.toString()}
// showsVerticalScrollIndicator={false}
// contentContainerStyle={{ paddingBottom: 200, paddingHorizontal: 10 }}
// renderItem={({ item, index }) => (
// <PurchaseAuctionTile
// item={item}
// onPressDetails={() => {
// }}
// onStartBidding={() => {
// Dispatch(setAuction(item))
// navigation.navigate(NavigationString.Emd)
// }}
// buttonEnable={isAuctionActive(item)}
// isAuctionEnd={isAuctionEnd(item)}
// />
// )}
// />
<FlatList <FlatList
data={data.result ?? []} data={data.result ?? []}
renderItem={({ item, index }) => ( renderItem={({ item, index }) => (
+20 -14
View File
@@ -36,15 +36,14 @@ const Login = () => {
const [auctionLoading, setAuctionLoading] = useState(false); const [auctionLoading, setAuctionLoading] = useState(false);
const { mutate: loginMutate } = useLogin(); const { mutate: loginMutate } = useLogin();
const { mutate: auctionMutate } = useAuctionLogin(); const { mutate: auctionMutate } = useAuctionLogin();
const {data}=useGetDesignation(); const { data } = useGetDesignation();
const { mutate: registrationStateMutate } = useRagistrationState(); const { mutate: registrationStateMutate } = useRagistrationState();
const { data: MasterData}=usefetchMasterData() const { data: MasterData } = usefetchMasterData()
const handleGetData = async () => { const handleGetData = async () => {
registrationStateMutate(undefined, { registrationStateMutate(undefined, {
onSuccess: (res: any) => { onSuccess: (res: any) => {
console.log('Registration status response try :', res);
if (res?.statusCode === 200) { if (res?.statusCode === 200) {
const { registrationStatus, contOtherId, contOrganization } = res.data; const { registrationStatus, contOtherId, contOrganization } = res.data;
@@ -73,7 +72,8 @@ const handleGetData = async () => {
default: default:
{ {
console.log("attempting navigation to Ragistration") console.log("attempting navigation to Ragistration")
Navigation.replace(NavigationString.Registration);} Navigation.replace(NavigationString.Registration);
}
break; break;
} }
return; return;
@@ -104,11 +104,12 @@ const handleGetData = async () => {
Navigation.replace('Registration'); Navigation.replace('Registration');
}, },
}); });
}; };
const HandleLogin = async (values: any) => { const HandleLogin = async (values: any) => {
try {
if (activeType === 'tender') { if (activeType === 'tender') {
setLoginLoading(true); setLoginLoading(true);
loginMutate( loginMutate(
@@ -116,16 +117,15 @@ const handleGetData = async () => {
{ {
onSuccess: res => { onSuccess: res => {
if (res.statusCode == 200) { if (res.statusCode == 200) {
Dispatch(setToken({ ...res.data, token: res.token })); Dispatch(setToken({ ...res.data, token: res.token, userType: activeType }));
handleGetData(); handleGetData();
} else {
showErrorAlert(res.message)
} }
setLoginLoading(false);
}, },
onError: err => { onError: err => {
showErrorAlert(err.message); showErrorAlert(err.message);
setLoginLoading(false);
}, },
}, },
); );
@@ -136,7 +136,7 @@ const handleGetData = async () => {
{ {
onSuccess: res => { onSuccess: res => {
if (res.statusCode == 200) { if (res.statusCode == 200) {
Dispatch(setToken({ ...res.data, token: res.token })); Dispatch(setToken({ ...res.data, token: res.token, userType: activeType }));
Navigation.dispatch( Navigation.dispatch(
CommonActions.reset({ CommonActions.reset({
index: 0, index: 0,
@@ -144,15 +144,21 @@ const handleGetData = async () => {
}), }),
); );
} }
setAuctionLoading(false);
}, },
onError: err => { onError: err => {
showErrorAlert(err.message); showErrorAlert(err.message);
setAuctionLoading(false); setLoginLoading(false);
}, },
}, },
); );
} }
} catch (error) {
} finally {
setAuctionLoading(false);
}
}; };
const isLoading = activeType === 'tender' ? loginLoading : auctionLoading; const isLoading = activeType === 'tender' ? loginLoading : auctionLoading;
+13 -24
View File
@@ -29,12 +29,11 @@ const Splash: React.FC = () => {
const [isHydrated, setIsHydrated] = useState(false); const [isHydrated, setIsHydrated] = useState(false);
const [isLoading, setIsLoading] = useState(true); const [isLoading, setIsLoading] = useState(true);
// Wait for Redux hydration (works with/without redux-persist)
useEffect(() => { useEffect(() => {
let unsubscribe: any; let unsubscribe: any;
const checkHydration = () => { const checkHydration = () => {
const token = (store.getState() as any).token?.token; const token = (store.getState() as any).token?.token;
if (token !== undefined) { // Defined = hydrated (null/empty/string ok) if (token !== undefined) {
setIsHydrated(true); setIsHydrated(true);
unsubscribe?.(); unsubscribe?.();
} }
@@ -46,19 +45,7 @@ const Splash: React.FC = () => {
return () => unsubscribe?.(); return () => unsubscribe?.();
}, []); }, []);
const getToken = useCallback(async (): Promise<string | null> => {
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 routeByOrgType = (params: { otherId: any; orgType: any }) => {
const orgType = String(params.orgType); const orgType = String(params.orgType);
@@ -138,22 +125,25 @@ const Splash: React.FC = () => {
useNativeDriver: true, useNativeDriver: true,
}).start(); }).start();
const token = await getToken();
console.log("Token after hydration -", token, typeof token, !!token);
if (!token) { if (!reduxToken.token) {
console.log('No valid token, navigating to Login');
navigation.reset({ navigation.reset({
index: 0, index: 0,
routes: [{ name: NavigationString.Login || 'Signin' }], // Fallback routes: [{ name: NavigationString.Login }],
}); });
return; return;
} }
console.log('Valid token, fetching registration data'); if (reduxToken.userType == 'tender') {
await handleGetData(); await handleGetData();
} else {
navigation.reset({
index: 0,
routes: [{ name: NavigationString.Home }],
});
}
} catch (error) { } catch (error) {
console.error('Splash Error:', error);
navigation.reset({ navigation.reset({
index: 0, index: 0,
routes: [{ name: NavigationString.Login || 'Signin' }], 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); const timeoutId = setTimeout(runSplash, 200);
return () => clearTimeout(timeoutId); return () => clearTimeout(timeoutId);
}, [isFocused, isHydrated, getToken]); }, [isFocused, isHydrated]);
if (!isHydrated) { if (!isHydrated) {
return ( return (
-4
View File
@@ -1,17 +1,14 @@
import { useInfiniteQuery, useMutation, useQuery } from '@tanstack/react-query'; 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 { 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 // User
export const useLogin = () => { export const useLogin = () => {
console.log("hitting here")
return useMutation({ return useMutation({
mutationFn: (payload: { emailAdd: string, password: string }) => userLogin(payload), mutationFn: (payload: { emailAdd: string, password: string }) => userLogin(payload),
}); });
}; };
export const useAuctionLogin = () => { export const useAuctionLogin = () => {
console.log("hitting here")
return useMutation({ return useMutation({
mutationFn: (payload: { emailAdd: string, password: string }) => userAuctionLogin(payload), mutationFn: (payload: { emailAdd: string, password: string }) => userAuctionLogin(payload),
}); });
@@ -194,7 +191,6 @@ export const useRagistrationState = () => {
}); });
}; };
//////////////////////////////////////////////////////
export const usefetchMasterData = () => { export const usefetchMasterData = () => {
return useQuery({ return useQuery({