Skip to content

Commit

Permalink
Fix signup order
Browse files Browse the repository at this point in the history
  • Loading branch information
jahongiry committed Mar 7, 2024
1 parent cb25eea commit be19c19
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
8 changes: 7 additions & 1 deletion src/pages/cards/popup/Popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,13 @@ const PopUp = ({
) : (
<button
className='sotib-olish'
onClick={() => navigate('/signup')}
onClick={() => {
localStorage.setItem(
'redirectToAfterAuth',
window.location.pathname
);
navigate('/signup');
}}
>
{translations.popup.buy}
</button>
Expand Down
5 changes: 5 additions & 0 deletions src/pages/login/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ const Login = () => {
navigate(lastPath);
localStorage.removeItem('lastPath');
}
const redirectTo = localStorage.getItem('redirectToAfterAuth');
if (redirectTo) {
navigate(redirectTo);
localStorage.removeItem('redirectToAfterAuth');
}
} catch (error) {
toast.error(<p className='red-text-important'>{error.message}</p>);
}
Expand Down
13 changes: 8 additions & 5 deletions src/pages/signup/confirm/Confirm.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,19 @@ const Confirm = () => {
const actionResult = await dispatch(verifyNumber(otp));
const userData = actionResult.payload;

if (userData && userData.token) {
const redirectTo = localStorage.getItem('redirectToAfterAuth');
if (redirectTo) {
console.log('Redirecting to:', redirectTo);
navigate(redirectTo);
localStorage.removeItem('redirectToAfterAuth');
} else if (userData && userData.token) {
const lastPath = localStorage.getItem('lastPath') || '/';
console.log('Navigating to last path:', lastPath);
navigate(lastPath);
localStorage.removeItem('lastPath');
} else {
// Handle login failure (e.g., show an error message)
}
} catch (error) {
// Handle error (e.g., incorrect credentials, server error)
}
} catch (error) {}
};

return (
Expand Down

0 comments on commit be19c19

Please sign in to comment.