Skip to content

Commit 066a320

Browse files
authored
Merge pull request #264 from CodeForPhilly/263-about
Adds AboutUs to User,Login header
2 parents bee37e8 + dbfc580 commit 066a320

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

src/client/src/App.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22

33
import {BrowserRouter as Router, Switch, Route, useHistory} from 'react-router-dom';
44

5-
import Header, {AdminHeader} from "./components/Header";
5+
import Header, {AdminHeader, LoginHeader} from "./components/Header";
66

77
import HomePage from './pages/Home';
88
import Admin from './pages/Admin';
@@ -79,7 +79,7 @@ function AuthenticatedApp() {
7979

8080
const userRole = decoded?.payload.role;
8181
var expTime = decoded?.payload.exp - Date.now()/1000;
82-
const jwtExpired = expTime <= 0
82+
const jwtExpired = !expTime || expTime <= 0
8383

8484
const popRefreshAlert = expTime > 0 && expTime < REFRESH_POPUP_TIME; // Time in secs to pop up refresh dialog
8585

@@ -91,13 +91,15 @@ function AuthenticatedApp() {
9191
<>
9292
<Router>
9393

94-
{ !jwtExpired && hdr ? hdr : '' /* Above-chosen header, or if logged out, no header */ }
94+
{ !jwtExpired && hdr ? hdr : <LoginHeader /> /* Above-chosen header, or if logged out, no header */ }
9595

9696
{popRefreshAlert && <RefreshDlg shouldOpen={true} setToken={setToken} /> } {/* Pop up the refresh dialog */}
9797

9898
{jwtExpired && <RefreshDlg shouldOpen={false} setToken={setToken} /> } { /* Too late, expired: close the dialog */}
9999

100-
100+
<Route path="/about">
101+
<About/>
102+
</Route>
101103

102104
{ /* If not logged in, show login screen */
103105
(!access_token | jwtExpired) ? <Login setToken={setToken} /> : <Switch>
@@ -115,9 +117,6 @@ function AuthenticatedApp() {
115117
}
116118

117119

118-
<Route path="/about">
119-
<About/>
120-
</Route>
121120

122121
<Route path="/360view/search">
123122
<Search360 access_token = {access_token} />

src/client/src/components/Header.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,24 @@ export function AdminHeader(props){ // This one if user has the ADMIN role
2222
);
2323
}
2424

25+
export function LoginHeader(props){ // This one for login page
26+
27+
return(
28+
<AppBar position="static" id="header" className={styles.header} elevation={1}>
29+
<Toolbar style={{"minWidth":"100", "dipslay":"flex", "justifyContent":"space-between"}}>
30+
<Typography className={styles.header_logo} variant="h6">PAWS Data Pipeline</Typography>
31+
<div style={{"display":"flex", "justifyContent":"space-between", "margin":"16px 6px 16px 16px"}}>
32+
<Button className={styles.header_link} component={RouterLink} to="/about">About us</Button>
33+
{ /* <Button className={styles.header_link} component={RouterLink} to="/check">Check</Button> */ }
34+
</div>
35+
</Toolbar>
36+
</AppBar>
37+
);
38+
}
39+
40+
41+
42+
2543
export default function Header(props){ // This one if user only has USER role - no link to Admin page
2644

2745
return(
@@ -30,9 +48,11 @@ export default function Header(props){ // This one if user only has USER role -
3048
<Typography className={styles.header_logo} variant="h6">PAWS Data Pipeline</Typography>
3149
<div style={{"display":"flex", "justifyContent":"space-between", "margin":"16px 6px 16px 16px"}}>
3250
<Button className={styles.header_link} component={RouterLink} to="/360view/search">360 DataView</Button>
51+
<Button className={styles.header_link} component={RouterLink} to="/about">About us</Button>
3352
{ /* <Button className={styles.header_link} component={RouterLink} to="/check">Check</Button> */ }
3453
</div>
3554
</Toolbar>
3655
</AppBar>
3756
);
38-
}
57+
}
58+

src/client/src/components/Login/Login.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React, { useState } from 'react';
22
import PropTypes from 'prop-types';
33
import './Login.css';
44

5-
65
function checkLoginResponse(response) {
76
let gotError = !response.ok;
87
if (gotError) {
@@ -42,6 +41,7 @@ export default function Login({ setToken }) {
4241
}
4342

4443
return (
44+
4545
<div className="login-wrapper">
4646
<h1>Please Log In</h1>
4747
<form onSubmit={handleSubmit}>

0 commit comments

Comments
 (0)