diff --git a/src/components/Navbar/index.tsx b/src/components/Navbar/index.tsx index eeb8016ec..2c25f4415 100644 --- a/src/components/Navbar/index.tsx +++ b/src/components/Navbar/index.tsx @@ -1,5 +1,5 @@ import { useEffect } from 'react'; -import { LoginProvider } from '@fleek-platform/login-button'; +import { AuthButton, LoginProvider } from '@fleek-platform/login-button'; import { getAuthenticationMenu, navbarMenu, @@ -14,7 +14,6 @@ import { RxHamburgerMenu } from 'react-icons/rx'; import { isActivePath } from '@utils/url'; import { Button } from '../Button'; import { ProjectDropdown } from './ProjectDropdown/ProjectDropdown'; -import type { Project } from '@fleekxyz/sdk/dist-types/generated/graphqlClient/schema'; import { isClient } from '../../utils/common'; import { useSession } from '@hooks/useSession'; @@ -443,25 +442,7 @@ const SessionManagementActions: React.FC = () => { // `use-sync-external-store` prevent need for all this? // placeholder approach to prevent SSR issues if (!isClient) { - const buttonText = 'Log in'; - - return ( - <> - null} - /> - - ); + return } // TODO: The loading process can be improved @@ -476,7 +457,7 @@ const SessionManagementActions: React.FC = () => { onAuthenticationSuccess={onAuthenticationSuccess} > {(props) => { - const { accessToken, isLoading, error, login, logout } = props; + const { login } = props; // TODO: This should be removed added temporary // due to an issue with the expectation for /prices @@ -486,118 +467,74 @@ const SessionManagementActions: React.FC = () => { (window as any).__DYNAMIC_TOGGLE_LOGIN__ = login; } - const handleClick = () => { - if (accessToken) { - logout(); - } else { - login(); - } - }; - - // TODO: Move the button text computations - // into the button container scope - let buttonText = 'Log in'; - - if (error) { - buttonText = 'Login failed'; - } else if (isLoading) { - buttonText = 'Loading...'; - } else if (isLoggedIn) { - buttonText = 'Log out'; - } - return ( <> - + )} + {isLoggedIn && ( + + )} + + {!isLoggedIn && ( + + )} - ); + ) }} ); }; -type ButtonContainerProps = { - showProjectsDropDown: boolean; - userProjects: Project[]; - activeProjectId: string; - setActiveProject: (projectId?: string) => Promise; - isLoggedIn: boolean; - isLoggingIn: boolean; - handleLoginClick: ( - e?: React.MouseEvent, - ) => void; - dashboardAppUrl: string; - buttonText: string; - isLoadingProject: boolean; - handleClick: () => void; -}; - -const ButtonContainer: React.FC = ({ - showProjectsDropDown, - userProjects, - activeProjectId, - setActiveProject, - isLoggedIn, - isLoggingIn, - handleLoginClick, - dashboardAppUrl, - buttonText, - isLoadingProject, - handleClick, -}) => { - return ( - <> - {showProjectsDropDown && ( - - )} - {isLoggedIn && ( - - )} - - {!isLoggedIn && ( - - )} - - ); -}; +const ShellButtonContainer = () => ( + <> + + + +)