From baab8bdc4beeffa652f872990cc0f8cad770ecfe Mon Sep 17 00:00:00 2001 From: Cody O'Donnell Date: Tue, 23 Jul 2024 10:44:49 -0700 Subject: [PATCH] Convert account tabs to navigation tabs with separate routes --- src/app/Routes.tsx | 21 ++++++- src/features/account/Account.tsx | 78 +++++++++--------------- src/features/account/AccountInfo.tsx | 7 ++- src/features/account/LinkedProviders.tsx | 7 ++- src/features/account/LogInSessions.tsx | 7 ++- src/features/account/UseAgreements.tsx | 8 ++- 6 files changed, 73 insertions(+), 55 deletions(-) diff --git a/src/app/Routes.tsx b/src/app/Routes.tsx index 451bb1fc..8e5af5d7 100644 --- a/src/app/Routes.tsx +++ b/src/app/Routes.tsx @@ -33,6 +33,10 @@ import { LoggedOut } from '../features/login/LoggedOut'; import { SignUp } from '../features/signup/SignUp'; import ORCIDLinkCreateLink from '../features/orcidlink/CreateLink'; import { Account } from '../features/account/Account'; +import { AccountInfo } from '../features/account/AccountInfo'; +import { LinkedProviders } from '../features/account/LinkedProviders'; +import { LogInSessions } from '../features/account/LogInSessions'; +import { UseAgreements } from '../features/account/UseAgreements'; export const LOGIN_ROUTE = '/login'; export const SIGNUP_ROUTE = '/signup'; @@ -69,7 +73,22 @@ const Routes: FC = () => { } /> {/* Account */} - } />} /> + } />}> + } />} /> + } />} /> + } />} + /> + } />} + /> + } />} + /> + {/* Navigator */} { - const [activeTab, setActiveTab] = useState(0); + const navigate = useNavigate(); + const location = useLocation(); + const [activeTab, setActiveTab] = useState(() => { + switch (location.pathname) { + case '/account/info': + return 0; + case '/account/providers': + return 1; + case '/account/logins': + return 2; + case '/account/use-agreements': + return 3; + default: + return 0; + } + }); const handleChange = (event: React.SyntheticEvent, newValue: number) => { setActiveTab(newValue); @@ -24,70 +36,36 @@ export const Account: FC = () => { navigate('info')} /> navigate('providers')} /> navigate('sessions')} /> navigate('use-agreements')} /> - - - - - - - - - - - - + ); }; - -interface TabPanelProps { - children?: React.ReactNode; - index: number; - value: number; - name: string; -} - -/** - * Tab panel wrapper that conditionally displays tab content - * depending on the active tab. - */ -const CustomTabPanel: FC = ({ - value, - index, - name, - children, - ...rest -}) => { - return ( - - ); -}; diff --git a/src/features/account/AccountInfo.tsx b/src/features/account/AccountInfo.tsx index c06a16dc..d6bd142d 100644 --- a/src/features/account/AccountInfo.tsx +++ b/src/features/account/AccountInfo.tsx @@ -16,7 +16,12 @@ import { FC } from 'react'; */ export const AccountInfo: FC = () => { return ( - + Edit Account { const linkedProviders = sampleProviders; return ( - + Currently Linked Providers { const otherSessions: any[] = []; return ( - + My Current Log In Sessions { }, [showExpired, currentPolicies]); return ( - + My Policy Agreements { /> {policies.map((policy) => (