Skip to content

Commit b09a1fe

Browse files
committed
[WIP] Account settings flow.
1 parent 201bd4d commit b09a1fe

File tree

4 files changed

+55
-13
lines changed

4 files changed

+55
-13
lines changed

src/components/elements/AppRoutes.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import ContactPage from 'components/pages/ContactPage';
2323
import PrivacyPage from 'components/pages/PrivacyPolicyPage';
2424
import ContactSuccessPage from 'components/pages/ContactSuccessPage';
2525
import TermsPage from 'components/pages/TermsPage';
26+
import AccountSettingsPage from 'components/pages/AccountSettingsPage';
2627

2728
// Elements
2829
import RequireAuth from 'components/elements/RequireAuth';
@@ -94,6 +95,7 @@ function AppRoutes() {
9495
element={<VerifyMagicLinkPage />}
9596
/>
9697
<Route path="/contact-success" element={<ContactSuccessPage />} />
98+
<Route path="/account-settings" element={<AccountSettings />} />
9799
</Routes>
98100
);
99101
}

src/components/elements/DropdownMenu.jsx

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@ import { Link } from 'react-router-dom';
33
import { navStyleClasses } from 'styles/navbar';
44
import DownArrowIcon from 'components/elements/DownArrowIcon';
55

6+
function DropDownAction({ value, label, route, action }) {
7+
if (action) {
8+
return (
9+
<a href="#" onClick={action} className={navStyleClasses.navDropdownItem}>{label}</a>
10+
)
11+
} else {
12+
return (
13+
<Link
14+
to={route}
15+
value={value}
16+
className={navStyleClasses.navDropdownItem}
17+
>
18+
{label}
19+
</Link>
20+
)
21+
}
22+
}
23+
624
function DropdownMenu({ label, options }) {
725
return (
826
<div className="flex justify-center mt-4 mr-10">
@@ -22,16 +40,15 @@ function DropdownMenu({ label, options }) {
2240
className={navStyleClasses.navSelectMenu}
2341
aria-labelledby="dropdownMenuButton2"
2442
>
25-
{options.map(({ value, label, route }) => {
43+
{options.map(({ value, label, route, action }) => {
2644
return (
2745
<li key={value}>
28-
<Link
29-
to={route}
46+
<DropDownAction
3047
value={value}
31-
className={navStyleClasses.navDropdownItem}
32-
>
33-
{label}
34-
</Link>
48+
label={label}
49+
route={route}
50+
action={action}
51+
/>
3552
</li>
3653
)
3754
})}

src/components/elements/NavigationBar.jsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ import { NAVBAR_EVENT_OPTIONS } from 'constants/navbar';
1313
function NavigationBar() {
1414
const auth = useAuth();
1515
const [colorTheme, setTheme] = useDarkMode();
16-
const signOut = () => auth.signOutCurrentUser();
16+
const authLinks = [
17+
{ label: 'Settings', value: 'settings', route: '/account-settings' },
18+
{ label: 'Sign Out', value: 'sign-out', action: () => auth.signOutCurrentUser() },
19+
]
1720

1821
return (
1922
<>
@@ -44,12 +47,14 @@ function NavigationBar() {
4447
alt="logo"
4548
/>
4649
</div>
47-
<div className={navStyleClasses.navLink}>
48-
{auth.currentUser.isAuthenticated
49-
? <button onClick={signOut}>Sign Out</button>
50-
: <Link to="/sign-in">Sign In</Link>
50+
51+
<div>
52+
{ auth.currentUser.isAuthenticated
53+
? <DropdownMenu label="Account" options={authLinks} />
54+
: <div className={navStyleClasses.navLink}><Link to="/sign-in">Sign In</Link></div>
5155
}
5256
</div>
57+
5358
<div className={navStyleClasses.navLink}>
5459
<a
5560
href="https://www.dataumbrella.org"
@@ -64,7 +69,10 @@ function NavigationBar() {
6469
Sponsors
6570
</a>
6671
</div>
67-
<DropdownMenu label="Events" options={NAVBAR_EVENT_OPTIONS} />
72+
73+
<div>
74+
<DropdownMenu label="Events" options={NAVBAR_EVENT_OPTIONS} />
75+
</div>
6876
</div>
6977
</div>
7078
</div>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from 'react';
2+
import { useAuth } from 'hooks/authentication';
3+
4+
function AccountSettingsPage() {
5+
const auth = useAuth();
6+
7+
return (
8+
<div className="w-3/4 container mx-auto p-20">
9+
<h1 className="text-2xl font-bold">Email</h1>
10+
<p>{auth.currentUser.email}</p>
11+
</div>
12+
);
13+
}
14+
15+
export default AccountSettingsPage;

0 commit comments

Comments
 (0)