Skip to content

Commit

Permalink
feature/CPF-34 hardcode email display, remove scaffold layout
Browse files Browse the repository at this point in the history
  • Loading branch information
Vikariusu committed Dec 18, 2023
1 parent 1725971 commit 37b340b
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 31 deletions.
9 changes: 4 additions & 5 deletions web/src/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@
// 'src/pages/HomePage/HomePage.js' -> HomePage
// 'src/pages/Admin/BooksPage/BooksPage.js' -> AdminBooksPage

import { Set, Router, Route } from '@redwoodjs/router'

// import ScaffoldLayout from 'src/layouts/ScaffoldLayout'
import { PrivateSet, Router, Route } from '@redwoodjs/router'

import { useAuth } from './auth'
import AuthenticatedLayout from './layouts/AuthenticatedLayout/AuthenticatedLayout'

const Routes = () => {
return (
<Router useAuth={useAuth}>
<Set wrap={AuthenticatedLayout}>
<PrivateSet wrap={AuthenticatedLayout} unauthenticated="login">
{/* Uploads */}
<Route path="/" page={UploadUploadsPage} name="uploads" />
<Route path="/uploads/new" page={UploadNewUploadPage} name="newUpload" />
Expand All @@ -36,7 +34,8 @@ const Routes = () => {
<Route path="/organizations/{id:Int}/edit" page={OrganizationEditOrganizationPage} name="editOrganization" />
<Route path="/organizations/{id:Int}" page={OrganizationOrganizationPage} name="organization" />
<Route path="/organizations" page={OrganizationOrganizationsPage} name="organizations" />
</Set>
</PrivateSet>
<Route path="/login" page={LoginPage} name="login" />
<Route notfound page={NotFoundPage} />
</Router>
)
Expand Down
17 changes: 12 additions & 5 deletions web/src/components/Navigation/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,30 @@ const Navigation = () => {
</NavLink>
</Nav.Item>
<Nav.Item>
<div className="nav-link disabled">Subrecipients</div>
</Nav.Item>
<Nav.Item>
<div className="nav-link disabled">Users</div>
</Nav.Item>
{/* TODO: Replace disabled tabs with the tabs below when Users and Subrecipients pages are ready */}
{/* <Nav.Item>
<NavLink
to={routes.uploads()}
to={routes.subrecipients()}
activeClassName="active"
className="nav-link"
>
Subrecipients
</NavLink>
</Nav.Item>
<Nav.Item>
</Nav.Item> */}
{/* <Nav.Item>
<NavLink
to={routes.uploads()}
to={routes.users()}
activeClassName="active"
className="nav-link"
>
Users
</NavLink>
</Nav.Item>
</Nav.Item> */}
<Nav.Item>
<NavLink
to={routes.reportingPeriods()}
Expand Down
42 changes: 38 additions & 4 deletions web/src/layouts/AuthenticatedLayout/AuthenticatedLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import Button from 'react-bootstrap/Button'
import { useAuth } from 'web/src/auth'

import { Link, routes } from '@redwoodjs/router'

import Navigation from 'src/components/Navigation/Navigation'
Expand All @@ -7,12 +10,43 @@ type AuthenticatedLayoutProps = {
}

const AuthenticatedLayout = ({ children }: AuthenticatedLayoutProps) => {
const { isAuthenticated, currentUser, logOut } = useAuth()

Check failure on line 13 in web/src/layouts/AuthenticatedLayout/AuthenticatedLayout.tsx

View workflow job for this annotation

GitHub Actions / qa / Lint JavaScript

'isAuthenticated' is assigned a value but never used. Allowed unused vars must match /^_/u

Check failure on line 13 in web/src/layouts/AuthenticatedLayout/AuthenticatedLayout.tsx

View workflow job for this annotation

GitHub Actions / qa / Lint JavaScript

'currentUser' is assigned a value but never used. Allowed unused vars must match /^_/u

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused variable isAuthenticated.

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused variable currentUser.

return (
<div className="container-fluid" style={{ width: '90%' }}>
<nav className="row navbar navbar-light bg-light">
<Link to={routes.uploads()} className="navbar-brand">
CPF Reporter: USDR
</Link>
<nav className="row navbar navbar-light bg-light d-flex justify-content-between">
<div className="col">
<Link to={routes.uploads()} className="navbar-brand">
CPF Reporter: USDR
</Link>
</div>
<div className="col d-flex justify-content-end">
{/* Replace the code below when authentication is complete */}
<div className="navbar-text">[email protected]</div>
<Button
size="sm"
variant="link"
className="nav-link navbar-text mx-2"
onClick={logOut}
>
Logout
</Button>

{/* Use the code below for conditional currentUser logic */}
{/* {isAuthenticated && (
<>
<div className="navbar-text">{currentUser.email}</div>
<Button
size="sm"
variant="link"
className="nav-link navbar-text mx-2"
onClick={logOut}
>
Logout
</Button>
</>
)} */}
</div>
</nav>
<Navigation />

Expand Down
17 changes: 0 additions & 17 deletions web/src/layouts/ScaffoldLayout/ScaffoldLayout.tsx

This file was deleted.

13 changes: 13 additions & 0 deletions web/src/pages/LoginPage/LoginPage.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { Meta, StoryObj } from '@storybook/react'

import LoginPage from './LoginPage'

const meta: Meta<typeof LoginPage> = {
component: LoginPage,
}

export default meta

type Story = StoryObj<typeof LoginPage>

export const Primary: Story = {}
14 changes: 14 additions & 0 deletions web/src/pages/LoginPage/LoginPage.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { render } from '@redwoodjs/testing/web'

import LoginPage from './LoginPage'

// Improve this test with help from the Redwood Testing Doc:
// https://redwoodjs.com/docs/testing#testing-pages-layouts

describe('LoginPage', () => {
it('renders successfully', () => {
expect(() => {
render(<LoginPage />)
}).not.toThrow()
})
})
23 changes: 23 additions & 0 deletions web/src/pages/LoginPage/LoginPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { useAuth } from 'web/src/auth'

Check failure on line 1 in web/src/pages/LoginPage/LoginPage.tsx

View workflow job for this annotation

GitHub Actions / qa / Lint JavaScript

'useAuth' is defined but never used. Allowed unused vars must match /^_/u

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused import useAuth.

import { Link, routes } from '@redwoodjs/router'
import { MetaTags } from '@redwoodjs/web'

const LoginPage = () => {
return (
<>
<MetaTags title="Login" description="Login page" />

<h1>LoginPage</h1>
<p>
Find me in <code>./web/src/pages/LoginPage/LoginPage.tsx</code>
</p>
<p>
My default route is named <code>login</code>, link to me with `
<Link to={routes.login()}>Login</Link>`
</p>
</>
)
}

export default LoginPage

0 comments on commit 37b340b

Please sign in to comment.