diff --git a/frontend/frontend/src/pages/Home/stages/Login.js b/frontend/frontend/src/pages/Home/stages/Login.js index ba23a206..4d4782f8 100644 --- a/frontend/frontend/src/pages/Home/stages/Login.js +++ b/frontend/frontend/src/pages/Home/stages/Login.js @@ -1,45 +1,29 @@ /* eslint-disable react/no-array-index-key */ import React from 'react'; +import PropTypes from 'prop-types'; +import { useDispatch, useSelector } from 'react-redux'; -import { Button, Card, CheckboxSection } from '../../../components'; -import { CardTypes, classnames } from '../../../utils'; +import { Button, Card } from '../../../components'; +import { classnames } from '../../../utils'; import { GITHUB_PRIVATE_AUTH_URL, GITHUB_PUBLIC_AUTH_URL, + HOST, } from '../../../constants'; import { FaGithub as GithubIcon } from 'react-icons/fa'; +import { logout as _logout } from '../../../redux/actions/userActions'; const LoginStage = ({ setCurrItem }) => { - const items = [ - { - url: GITHUB_PUBLIC_AUTH_URL, - label: 'GitHub Public Access\u00A0', - description: 'Generate stats based on your public repositories.', - buttonClassName: 'text-white bg-blue-500 hover:bg-blue-600', - onClick: null, - }, - { - url: GITHUB_PRIVATE_AUTH_URL, - label: 'GitHub Private Access', - description: - 'Includes contributions in your private repositories for more complete and accurate stats.', - buttonClassName: - 'text-black border border-black bg-white hover:bg-gray-100', - onClick: null, - }, - { - url: null, - label: 'Continue as Guest', - description: 'TODO', - buttonClassName: - 'text-black border border-black bg-white hover:bg-gray-100', - onClick: () => { - setCurrItem(1); - }, - }, - ]; + const userId = useSelector((state) => state.user.userId); + const userKey = useSelector((state) => state.user.userKey); + const privateAccess = useSelector((state) => state.user.privateAccess); + const isAuthenticated = userId && userId.length > 0; + const dispatch = useDispatch(); + const logout = () => { + dispatch(_logout()); + }; return (
@@ -49,30 +33,137 @@ const LoginStage = ({ setCurrItem }) => { 'lg:h-auto', )} > - {items.map((item, index) => { - const button = ( - - ); + {isAuthenticated ? ( + <> + {/* User is logged in */} +
+

+ You are logged in as{' '} + + {userId} + + . +

+

+ Access Level:{' '} + + {privateAccess ? 'Private Access' : 'Public Access'} + +

+

+ {privateAccess + ? 'You have granted access to both public and private repositories.' + : 'You have granted access to public repositories only.'} +

+
- return ( - - {index > 0 &&
} -
- {item.url ? {button} : button} -
{item.description}
-
- - ); - })} + {/* Access Level Management Buttons */} +
+ {privateAccess ? ( +
+ + + +

+ Switch to public access if you prefer not to share private + repository data. +

+
+ ) : ( +
+ + + +

+ Upgrade to include contributions from your private + repositories for more complete stats. +

+
+ )} +
+ + {/* Logout Button */} +
+ +

+ Sign out from your GitHub account. +

+
+ + ) : ( + <> + {/* User is not logged in - show login options */} +
+

+ You are not logged in. +

+

+ Please choose an option below to continue. +

+
+ +
+ + + +

+ Generate stats based on your public repositories. +

+
+ +
+ + + +

+ Includes contributions in your private repositories for more + complete and accurate stats. +

+
+ +
+ +

+ Try out Github Trends with data from an example + user/repository. +

+
+ + )}