Skip to content

Commit a950767

Browse files
authored
Revert "Refactored routes to be more like standard practice react router"
1 parent 318aa03 commit a950767

File tree

7 files changed

+660
-188
lines changed

7 files changed

+660
-188
lines changed

client/src/App.js

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -28,37 +28,19 @@ const App = () => {
2828
return (
2929
<div>
3030
<Switch>
31-
<Route exact path="/">
32-
<Home />
33-
</Route>
34-
<Route exact path="/about">
35-
<About/>
36-
</Route>
37-
<Route exact path="/teacherlogin">
38-
<TeacherLogin history={history}/>
39-
</Route>
40-
<Route exact path="/login">
41-
<StudentLogin history={history} />
42-
</Route>
43-
<PrivateRoute exact path="/dashboard" render={() => <Dashboard history={history}/>}/>
44-
<PrivateRoute exact path="/student" render={() => <Student history={history} /> } />
45-
<Route path="/workspace">
46-
<Workspace history={history} />
47-
</Route>
48-
<Route path="/sandbox">
49-
<Sandbox history={history}/>
50-
</Route>
51-
<PrivateRoute exact path="/day" render={() => <Day history={history} /> } />
52-
<PrivateRoute path="/classroom/:id" render={() => <Classroom history={history} /> } />
53-
<Route exact path="/ccdashboard">
54-
<ContentCreator history={history} />
55-
</Route>
56-
<Route exact path="/unitcreator">
57-
<UnitCreator history={history} />
58-
</Route>
59-
<Route exact path="/addblocks">
60-
<UploadBlocks history={history} />
61-
</Route>
31+
<Route exact path={"/"} render={() => <Home history={history}/>}/>
32+
<Route exact path={"/about"} render={() => <About history={history}/>}/>
33+
<Route exact path={"/teacherlogin"} render={() => <TeacherLogin history={history}/>}/>
34+
<Route exact path={"/login"} render={() => <StudentLogin history={history} />}/>
35+
<PrivateRoute exact path={"/dashboard"} render={() => <Dashboard history={history}/>}/>
36+
<PrivateRoute exact path={"/student"} render={() => <Student history={history} /> } />
37+
<Route path={"/workspace"} render={() => <Workspace history={history} />}/>
38+
<Route path={"/sandbox"} render={() => <Sandbox history={history}/>} />
39+
<PrivateRoute exact path={"/day"} render={() => <Day history={history} /> } />
40+
<PrivateRoute path={"/classroom/:id"} render={() => <Classroom history={history} /> } />
41+
<Route exact path={"/ccdashboard"} render={() => <ContentCreator history={history} />}/>
42+
<Route exact path={"/unitcreator"} render={() => <UnitCreator history={history} />}/>
43+
<Route exact path={"/addblocks"} render={() => <UploadBlocks history={history} />}/>
6244

6345
<Route component={NotFound}/>
6446
</Switch>

client/src/views/Home/Home.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ import Logo from "../../assets/casmm_logo.png"
44
import HomeJoin from "./HomeJoin"
55
import NavBar from "../../components/NavBar/NavBar";
66

7-
const Home = () => (
8-
<div className='container nav-padding'>
9-
<NavBar />
10-
<div id='join-wrapper'>
11-
<img src={Logo} id='casmm-logo' alt='logo'/>
12-
<HomeJoin />
13-
</div>
14-
</div>
15-
)
7+
export default function Home(props) {
168

17-
export default Home;
9+
return(
10+
<div className='container nav-padding'>
11+
<NavBar />
12+
<div id='join-wrapper'>
13+
<img src={Logo} id='casmm-logo' alt='logo'/>
14+
<HomeJoin history={props.history}/>
15+
</div>
16+
</div>
17+
)
18+
}

client/src/views/Home/HomeJoin.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
import React, {useState} from 'react'
2-
import { useHistory } from 'react-router';
32
import {message} from 'antd'
43
import './Home.less'
54
import { getStudents } from "../../Utils/requests";
65

76
export default function HomeJoin(props) {
87
const [loading, setLoading] = useState(false);
98
const [joinCode, setJoinCode] = useState('');
10-
const history = useHistory();
9+
1110
const handleLogin = () => {
1211
setLoading(true);
1312

1413
getStudents(joinCode).then(res => {
1514
if(res.data){
1615
setLoading(false);
1716
localStorage.setItem('join-code', joinCode);
18-
history.push('/login');
17+
props.history.push('/login');
1918
} else {
2019
setLoading(false);
2120
message.error('Join failed. Please input a valid join code.');

0 commit comments

Comments
 (0)