merge signup process
This commit is contained in:
+105
-99
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user