Skip to content

Commit

Permalink
Merge pull request #9 from fluturecode/eae-20-feature-log-out-navigation
Browse files Browse the repository at this point in the history
#20-feature(log-out): navigation
  • Loading branch information
fluturecode authored Aug 28, 2020
2 parents 908dd48 + 902599e commit c2c9ab6
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 31 deletions.
42 changes: 21 additions & 21 deletions application/src/components/nav/nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@ import { Link } from "react-router-dom";
import "./nav.css";

const Nav = (props) => {
return (
<div className="nav-strip">
<Link to={"/order"} className="nav-link">
<div className="nav-link-style">
<label className="nav-label">Order Form</label>
</div>
</Link>
<Link to={"/view-orders"} className="nav-link" id="middle-link">
<div className="nav-link-style">
<label className="nav-label">View Orders</label>
</div>
</Link>
<Link to={"/login"} className="nav-link">
<div className="nav-link-style">
<label className="nav-label">Log Out</label>
</div>
</Link>
</div>
);
}
return (
<div className="nav-strip">
<Link to={"/order"} className="nav-link">
<div className="nav-link-style">
<label className="nav-label">Order Form</label>
</div>
</Link>
<Link to={"/view-orders"} className="nav-link" id="middle-link">
<div className="nav-link-style">
<label className="nav-label">View Orders</label>
</div>
</Link>
<Link to={"/"} className="nav-link">
<div className="nav-link-style">
<label className="nav-label">Log Out</label>
</div>
</Link>
</div>
);
};

export default Nav;
export default Nav;
24 changes: 14 additions & 10 deletions application/src/redux/reducers/authReducer.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { LOGIN, LOGOUT } from '../actions/types'
import { LOGIN, LOGOUT } from "../actions/types";

const INITIAL_STATE = { email: null, token: null };

export default (state = INITIAL_STATE, action) => {
switch (action.type) {
case LOGIN:
return { ...state, email: action.payload.login, token: action.payload.token }
case LOGOUT:
return { ...state, ...INITIAL_STATE }
default:
return state;
}
}
switch (action.type) {
case LOGIN:
return {
...state,
email: action.payload.login,
token: action.payload.token,
};
case LOGOUT:
return {};
default:
return state;
}
};

0 comments on commit c2c9ab6

Please sign in to comment.