Skip to content

Commit

Permalink
feat: Enable bypass of login/logout to allow customized user auth con…
Browse files Browse the repository at this point in the history
…tent (#110)
  • Loading branch information
meissadia authored Aug 1, 2023
1 parent 0512196 commit 92e644c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/components/Navbar/Navbar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@ export const LoggedOut: Story = {
user: { loginHref: '#' }
}
};

export const NoUser: Story = {
args: {
links: ExampleLinks
}
};
9 changes: 6 additions & 3 deletions src/components/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { JSXElement } from '~/src/types/jsxElement';
import CFPBLogo from '../../assets/images/cfpb-logo.png';
import Link from '../Link/Link';
import './navbar.less';
Expand Down Expand Up @@ -35,11 +36,13 @@ interface UserActionsProperties {
user?: User;
}

const UserActions = ({ user }: UserActionsProperties): JSX.Element => {
if (!user?.name)
const UserActions = ({ user }: UserActionsProperties): JSXElement => {
if (!user) return null;

if (!user.name)
return (
<div className='user-actions'>
<Link href={user?.loginHref} className='nav-item login'>
<Link href={user.loginHref} className='nav-item login'>
LOGIN
</Link>
</div>
Expand Down

0 comments on commit 92e644c

Please sign in to comment.