diff --git a/CHANGELOG.md b/CHANGELOG.md index 31acbb2f9..90d4b6a0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,8 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added +- Hightlight active page in Navbar, update page routes to nest under top-level routes ### Fixed +- Remove 1s login delay ## [0.6.0] - 2022-05-09 diff --git a/packages/frontend/src/components/periods/ActiveUserQuantificationsMessage.tsx b/packages/frontend/src/components/periods/ActiveUserQuantificationsMessage.tsx index 3dde0aabf..283ec915d 100644 --- a/packages/frontend/src/components/periods/ActiveUserQuantificationsMessage.tsx +++ b/packages/frontend/src/components/periods/ActiveUserQuantificationsMessage.tsx @@ -12,7 +12,7 @@ const QuantifierPeriodMessage = ({ if (!period?._id) return null; return (
  • - {period.name} + {period.name}
  • ); }; diff --git a/packages/frontend/src/navigation/AuthenticatedRoutes.tsx b/packages/frontend/src/navigation/AuthenticatedRoutes.tsx index 9c7c185ec..ba67a63e5 100644 --- a/packages/frontend/src/navigation/AuthenticatedRoutes.tsx +++ b/packages/frontend/src/navigation/AuthenticatedRoutes.tsx @@ -74,7 +74,7 @@ const AuthRoute = ({ children, ...props }: AuthRouteProps): JSX.Element => { const Routes = (): JSX.Element => { return ( - + @@ -82,35 +82,37 @@ const Routes = (): JSX.Element => { - - - - - + - - - - - - - - + + + + + + + + + + + + + + diff --git a/packages/frontend/src/navigation/NavItem.tsx b/packages/frontend/src/navigation/NavItem.tsx index 8c5dd6c60..f563df978 100644 --- a/packages/frontend/src/navigation/NavItem.tsx +++ b/packages/frontend/src/navigation/NavItem.tsx @@ -1,6 +1,6 @@ import { IconProp } from '@fortawesome/fontawesome-svg-core'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { Link } from 'react-router-dom'; +import { NavLink } from 'react-router-dom'; interface NavProps { icon?: IconProp; @@ -10,9 +10,13 @@ interface NavProps { const NavItem = ({ icon, description, to }: NavProps): JSX.Element => { return ( - + `relative px-4 py-1 cursor-pointer mr-[1px] no-underline flex items-center text-black ${ + isActive ? ' bg-gray-200' : ' hover:bg-gray-100' + }` + } id={to.substring(1) + '-nav-button'} > {icon && ( @@ -23,7 +27,7 @@ const NavItem = ({ icon, description, to }: NavProps): JSX.Element => {
    {description}
    - + ); }; diff --git a/packages/frontend/src/pages/ErrorPage.tsx b/packages/frontend/src/pages/ErrorPage.tsx index c0a828d8b..468e992e1 100644 --- a/packages/frontend/src/pages/ErrorPage.tsx +++ b/packages/frontend/src/pages/ErrorPage.tsx @@ -1,5 +1,7 @@ import { faPrayingHands } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { useSetRecoilState } from 'recoil'; +import { ActiveTokenSet } from '@/model/auth'; interface NotFoundProps { // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -7,9 +9,10 @@ interface NotFoundProps { } const ErrorPage = ({ error }: NotFoundProps): JSX.Element => { + const setActiveTokenSet = useSetRecoilState(ActiveTokenSet); + const logout = (): void => { - localStorage.clear(); - window.location.href = '/'; + setActiveTokenSet(undefined); }; return ( diff --git a/packages/frontend/src/pages/Login/components/Login.tsx b/packages/frontend/src/pages/Login/components/Login.tsx index 70c87631b..248225e21 100644 --- a/packages/frontend/src/pages/Login/components/Login.tsx +++ b/packages/frontend/src/pages/Login/components/Login.tsx @@ -69,10 +69,7 @@ const LoginButton: React.FC = (): ReactElement | null => { // 4. Redirect after login success if (accessToken) { - const { from } = location.state || { from: { pathname: '/' } }; - setTimeout(() => { - history.replace(from); - }, 1000); + history.replace('/'); } if (!accessToken && !signatureReceived) { diff --git a/packages/frontend/src/pages/Periods/Details/PeriodDetailsPage.tsx b/packages/frontend/src/pages/Periods/Details/PeriodDetailsPage.tsx index aff00d29c..fcb21ee3c 100644 --- a/packages/frontend/src/pages/Periods/Details/PeriodDetailsPage.tsx +++ b/packages/frontend/src/pages/Periods/Details/PeriodDetailsPage.tsx @@ -113,9 +113,6 @@ const PeriodDetailPage = (): JSX.Element | null => {
    - - - @@ -128,6 +125,9 @@ const PeriodDetailPage = (): JSX.Element | null => { disabled={period.status !== PeriodStatusType.OPEN || !isAdmin} /> + + +
    diff --git a/packages/frontend/src/pages/Periods/Details/components/QuantifierMessage.tsx b/packages/frontend/src/pages/Periods/Details/components/QuantifierMessage.tsx index 88df74f4b..27686cf56 100644 --- a/packages/frontend/src/pages/Periods/Details/components/QuantifierMessage.tsx +++ b/packages/frontend/src/pages/Periods/Details/components/QuantifierMessage.tsx @@ -28,7 +28,7 @@ export const QuantifierMessage = (): JSX.Element | null => {