Skip to content

Commit 4768326

Browse files
authored
Merge pull request #257 from CodeForPhilly/refactor-360-ui
UI re-factor 360
2 parents dca3811 + 7440cdc commit 4768326

30 files changed

+907
-1053
lines changed

src/client/src/App.js

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1-
import React from 'react'
1+
import React from 'react';
2+
3+
import {BrowserRouter as Router, Switch, Route, useHistory} from 'react-router-dom';
24

3-
import {BrowserRouter as Router, Switch, Route} from 'react-router-dom';
45
import Header, {AdminHeader} from "./components/Header";
56

67
import HomePage from './pages/Home';
78
import Admin from './pages/Admin';
8-
import DataView from './pages/DataView360/DataView360';
9+
import Search360 from './pages/DataView360/Search/Search';
10+
import View360 from './pages/DataView360/View/View';
911
import About from './pages/About';
1012
import Login from './components/Login/Login';
1113
import Check from './pages/Check/Check';
1214
import useToken from './components/Login/useToken';
1315
var jwt = require('jsonwebtoken');
1416

15-
// Triggers token expiration check
17+
18+
// Triggers token expiration check
1619
const sleep = time => new Promise(resolve => setTimeout(resolve, time))
17-
const expTimer = () => sleep(500).then(() => ({}))
20+
const expTimer = () => sleep(500).then(() => ({}))
1821

1922
const AuthContext = React.createContext()
2023

@@ -26,7 +29,7 @@ function AuthProvider({children}) {
2629

2730
React.useEffect(() => {
2831
expTimer().then(
29-
user => setState({status: 'success', error: null, user}) //
32+
user => setState({status: 'success', error: null, user}) //
3033
)
3134
}, )
3235

@@ -70,45 +73,51 @@ function AuthenticatedApp() {
7073

7174

7275
var decoded = jwt.decode(access_token, { complete: true });
73-
76+
7477
const userRole = decoded?.payload.role;
7578
var expTime = decoded?.payload.exp - Date.now()/1000;
7679

7780
const jwtExpired = expTime <= 0
7881

7982
const hdr = userRole === 'admin' ? <AdminHeader /> : <Header /> // If we're going to display a header, which one?
8083

84+
const history = useHistory();
85+
8186
return (
8287
<>
8388
<Router>
84-
85-
{ !jwtExpired && hdr ? hdr : '' /* Above-chosen header, or if logged out, no header */ }
86-
89+
90+
{ !jwtExpired && hdr ? hdr : '' /* Above-chosen header, or if logged out, no header */ }
91+
8792
{ /* If not logged in, show login screen */
88-
(!access_token | jwtExpired) ? <Login setToken={setToken} /> : <Switch>
93+
(!access_token | jwtExpired) ? <Login setToken={setToken} /> : <Switch>
8994

9095
<Route exact path="/">
9196
<HomePage/>
9297
</Route>
9398

9499

95100
{ /* If an admin, render Upload page */
96-
userRole === 'admin' &&
101+
userRole === 'admin' &&
97102
<Route path="/admin">
98103
<Admin/>
99104
</Route>
100-
}
105+
}
101106

102107

103108
<Route path="/about">
104109
<About/>
105110
</Route>
106111

107-
<Route path="/dataView">
108-
<DataView/>
112+
<Route path="/360view/search">
113+
<Search360/>
109114
</Route>
110115

111-
<Route path="/check">
116+
<Route path="/360view/view">
117+
<View360/>
118+
</Route>
119+
120+
<Route path="/check">
112121
<Check />
113122
</Route>
114123
</Switch>
@@ -128,7 +137,7 @@ function Home() {
128137
}
129138

130139
function App() {
131-
140+
132141
return (
133142
<AuthProvider>
134143
<div>

src/client/src/components/Header.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function AdminHeader(props){ // This one if user has the ADMIN role
1313
<div style={{"display":"flex", "justifyContent":"space-between", "margin":"16px 6px 16px 16px"}}>
1414

1515
<Button className={styles.header_link} component={RouterLink} to="/admin">Admin</Button>
16-
<Button className={styles.header_link} component={RouterLink} to="/dataView">360 DataView</Button>
16+
<Button className={styles.header_link} component={RouterLink} to="/360view/search">360 DataView</Button>
1717
{ /* <Button className={styles.header_link} component={RouterLink} to="/check">Check</Button> */ }
1818
</div>
1919
</Toolbar>
@@ -28,7 +28,7 @@ export default function Header(props){ // This one if user only has USER role -
2828
<Toolbar style={{"minWidth":"100", "dipslay":"flex", "justifyContent":"space-between"}}>
2929
<Typography className={styles.header_logo} variant="h6">PAWS Data Pipeline</Typography>
3030
<div style={{"display":"flex", "justifyContent":"space-between", "margin":"16px 6px 16px 16px"}}>
31-
<Button className={styles.header_link} component={RouterLink} to="/dataView">360 DataView</Button>
31+
<Button className={styles.header_link} component={RouterLink} to="/360view/search">360 DataView</Button>
3232
{ /* <Button className={styles.header_link} component={RouterLink} to="/check">Check</Button> */ }
3333
</div>
3434
</Toolbar>

src/client/src/pages/DataView360/DataView360.js

Lines changed: 0 additions & 233 deletions
This file was deleted.

0 commit comments

Comments
 (0)