Skip to content

Commit

Permalink
Some more routing + fix login routing
Browse files Browse the repository at this point in the history
  • Loading branch information
MinhPhan8803 committed Nov 27, 2022
1 parent cc6e28d commit 519f1f0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/frontend/src/pages/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { useState } from 'react';
import { useNavigate } from "react-router-dom";

function sendData(user: string, password: string) {
const navigate = useNavigate();
axios({
method: 'post',
url: '/login',
Expand All @@ -25,6 +26,7 @@ function sendData(user: string, password: string) {
})
.then((response) => {
console.log(response);
navigate('/');
})
.catch((error) => {
if (error.response) {
Expand All @@ -36,7 +38,6 @@ function sendData(user: string, password: string) {
}

export default function Login() {
const navigate = useNavigate();
const [user, setUser] = useState('');
const [password, setPassword] = useState('');

Expand Down Expand Up @@ -78,7 +79,6 @@ export default function Login() {
style={btnstyle}
onClick={() => {
sendData(user, password)
navigate('/')
}}
fullWidth
>
Expand Down
7 changes: 5 additions & 2 deletions src/frontend/src/pages/User.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@ export default function User() {
</Grid>
<Grid item>
<Box display="flex" justifyContent="flex-end" alignItems="flex-end">
<Button sx={{ color: '#fff' }} onClick={() => logout()}>
Logout
<Button sx={{ color: '#fff' }} onClick={() => {
logout()
navigate("/login")
}}>
Log out
</Button>
</Box>
</Grid>
Expand Down

3 comments on commit 519f1f0

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
app.py1332780%55–82
config.py10100% 
decorators.py270100% 
dataholders
   apt.py90100% 
   mainpage_get.py150100% 
   review.py70100% 
   user.py80100% 
pages
   login.py290100% 
   mainpage.py1000100% 
   userpage.py540100% 
TOTAL3832793% 

Tests Skipped Failures Errors Time
48 0 💤 3 ❌ 0 🔥 0.757s ⏱️

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
app.py1332780%55–82
config.py10100% 
decorators.py270100% 
dataholders
   apt.py90100% 
   mainpage_get.py150100% 
   review.py70100% 
   user.py80100% 
pages
   login.py290100% 
   mainpage.py1000100% 
   userpage.py540100% 
TOTAL3832793% 

Tests Skipped Failures Errors Time
48 0 💤 3 ❌ 0 🔥 1.153s ⏱️

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
app.py1332780%55–82
config.py10100% 
decorators.py270100% 
dataholders
   apt.py90100% 
   mainpage_get.py150100% 
   review.py70100% 
   user.py80100% 
pages
   login.py290100% 
   mainpage.py1000100% 
   userpage.py540100% 
TOTAL3832793% 

Tests Skipped Failures Errors Time
48 0 💤 3 ❌ 0 🔥 1.436s ⏱️

Please sign in to comment.