Skip to content

Commit

Permalink
added login redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
Codebmk committed Feb 25, 2025
1 parent f7a7ee4 commit 1798bec
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/platform/src/pages/account/login/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
} from '@/lib/store/services/account/LoginSlice';
import { getIndividualUserPreferences } from '@/lib/store/services/account/UserDefaultsSlice';
import { postUserLoginDetails, getUserDetails } from '@/core/apis/Account';
import { GOOGLE_AUTH_URL } from '@/core/urls/authentication';

const MAX_RETRIES = 3;
const RETRY_DELAY = 1000;
Expand Down Expand Up @@ -110,6 +111,15 @@ const UserLogin = () => {
dispatch(setUserData({ key, value }));
};

const handleGoogleLogin = async () => {
try {
// Redirect to Google auth URL
window.location.href = GOOGLE_AUTH_URL;
} catch (error) {
console.error('Login error:', error);
}
};

return (
<AccountPageLayout
pageTitle="AirQo Analytics | Login"
Expand Down Expand Up @@ -168,6 +178,7 @@ const UserLogin = () => {
</div>
</div>
</div>

<div className="mt-10">
<button
data-testid="login-btn"
Expand All @@ -181,6 +192,19 @@ const UserLogin = () => {
'Login'
)}
</button>

<button
data-testid="google-login-btn"
className="w-full btn border-blue-900 rounded-[12px] text-white text-sm outline-none border"
disabled={loading}
onClick={handleGoogleLogin}
>
{loading ? (
<Spinner data-testid="spinner" width={25} height={25} />
) : (
'Login with Google'
)}
</button>
</div>
</form>
<div className="mt-8 w-full flex justify-center">
Expand Down

0 comments on commit 1798bec

Please sign in to comment.