Skip to content

Commit

Permalink
navigate to login when user not logged in
Browse files Browse the repository at this point in the history
  • Loading branch information
mouhsineelachbi committed Apr 23, 2022
1 parent 4f6ce4b commit 6ad6dcc
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion client_app/src/components/home.component/home.component.jsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import React from 'react'
import { useEffect } from 'react'
import { useDispatch, useSelector } from "react-redux";
import { useNavigate } from 'react-router-dom';
import {getUser} from "../../feature/user/user.slice";
import ShipItems from '../ship.items.component/ship.items.component';

export default function Home() {

const dispatch = useDispatch();
const {userLoading, user, error} = useSelector(state => state.user);
const navigate = useNavigate()

useEffect(()=>{
dispatch(getUser())
.unwrap()
.then(
()=>{},
()=>{

navigate("/login");
}
)
}, [])
Expand Down
2 changes: 1 addition & 1 deletion ship_management/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@

app.MapControllers();

app.Run();
app.Run("http://localhost:4000");
Binary file added ship_management/ship.db-shm
Binary file not shown.
Empty file added ship_management/ship.db-wal
Empty file.

0 comments on commit 6ad6dcc

Please sign in to comment.