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
+29 -23
View File
@@ -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 = () => {
</Text>
</Animated.View>
)}
{
isPending ? <Skeleton /> :
<FlatList
data={allBoolean.liveAuctionData ?? []}
renderItem={renderItem}
showsVerticalScrollIndicator={false}
contentContainerStyle={{ paddingBottom: 50, paddingTop: 10 }}
<FlatList
data={allBoolean.liveAuctionData ?? []}
renderItem={renderItem}
showsVerticalScrollIndicator={false}
contentContainerStyle={{ paddingBottom: 50, paddingTop: 10 }}
onEndReached={loadMore}
onEndReachedThreshold={0.1}
onEndReached={loadMore}
onEndReachedThreshold={0.1}
onMomentumScrollBegin={() => {
onEndReachedCalledDuringMomentum.current = false;
}}
onMomentumScrollBegin={() => {
onEndReachedCalledDuringMomentum.current = false;
}}
ListFooterComponent={renderFooter}
ListFooterComponent={renderFooter}
refreshControl={
<RefreshControl
refreshing={isRefetching}
onRefresh={refetch}
tintColor="transparent"
colors={[colors.primary]}
/>
}
refreshControl={
<RefreshControl
refreshing={isRefetching}
onRefresh={refetch}
tintColor="transparent"
colors={[colors.primary]}
initialNumToRender={6}
maxToRenderPerBatch={6}
windowSize={7}
removeClippedSubviews
/>
}
}
initialNumToRender={6}
maxToRenderPerBatch={6}
windowSize={7}
removeClippedSubviews
/>
</View>
);
-19
View File
@@ -65,25 +65,6 @@ const PurchaseAuction = () => {
<SearchInput onChange={() => { }} placeholder='Search....' filterPress={() => { setAllBoolean((prev: any) => ({ ...prev, isShowFilter: !prev.isShowFilter })) }} />
{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
data={data.result ?? []}
renderItem={({ item, index }) => (
+105 -99
View File
@@ -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;
+16 -27
View File
@@ -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<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 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 (
-4
View File
@@ -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({