diff --git a/.env.example b/.env.example index aad4da7ae..d1903cf48 100644 --- a/.env.example +++ b/.env.example @@ -4,4 +4,8 @@ NEXT_PUBLIC_PLACEHOLDER_SMALL_IMAGE_URL="https://res.cloudinary.com/placeholder- NEXT_PUBLIC_PLACEHOLDER_LARGE_IMAGE_URL="https://via.placeholder.com/600" NEXT_PUBLIC_ALGOLIA_APP_ID = "changeme" NEXT_PUBLIC_ALGOLIA_PUBLIC_API_KEY = "changeme" -NODE_ENV="development" \ No newline at end of file +NODE_ENV="development" +NEXT_PUBLIC_AUTH_TOKEN_SS_KEY="auth-token" +NEXT_PUBLIC_REFRESH_TOKEN_LS_KEY="refresh-token" +NEXT_PUBLIC_SESSION_TOKEN_LS_KEY="session-token" +NEXT_PUBLIC_AUTH_KEY_TIMEOUT="300000" diff --git a/src/components/Header/Navbar.component.tsx b/src/components/Header/Navbar.component.tsx index 4d498ce81..a27acc232 100644 --- a/src/components/Header/Navbar.component.tsx +++ b/src/components/Header/Navbar.component.tsx @@ -1,5 +1,6 @@ import Link from 'next/link'; - +import { useEffect, useState } from 'react'; +import { hasCredentials } from '../../utils/auth'; import Cart from './Cart.component'; import AlgoliaSearchBox from '../AlgoliaSearch/AlgoliaSearchBox.component'; import MobileSearch from '../AlgoliaSearch/MobileSearch.component'; @@ -9,6 +10,12 @@ import MobileSearch from '../AlgoliaSearch/MobileSearch.component'; * Includes mobile menu. */ const Navbar = () => { + const [loggedIn, setLoggedIn] = useState(false); + + useEffect(() => { + setLoggedIn(hasCredentials()); + }, []); + return (