Skip to content

Commit 8c64a47

Browse files
committed
reset cart on sign-out
1 parent 08be905 commit 8c64a47

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/Components/Navbar/NavBarComponent.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import MyRouter from "../Router";
55
import { deleteToken, authFalse } from "../../store/actions/user";
66
import { resetHistoryOrders } from "../../store/actions/orders";
77
import { resetCategory } from "../../store/actions/category";
8+
import { resetCart } from "../../store/actions/cart";
89
import { connect } from "react-redux";
910
import WaveAnimationComponent from "../Animation/WaveAnimation";
1011
import NavbarWithToken from "./NavbarWithToken";
@@ -14,16 +15,21 @@ class Navbare extends Component {
1415
deleteToken() {
1516
this.props.authFalse();
1617
this.props.deleteToken();
17-
this.props.history.push("/");
1818
this.props.resetHistoryOrders();
1919
this.props.resetCategory();
20+
this.props.resetCart();
21+
this.props.history.push("/");
2022
}
2123

2224
render() {
2325
return (
2426
<div>
2527
<WaveAnimationComponent />
26-
{this.props.token ? <NavbarWithToken onClick={this.deleteToken.bind(this)} /> : <NavbarWithoutToken />}
28+
{this.props.token ? (
29+
<NavbarWithToken onClick={this.deleteToken.bind(this)} />
30+
) : (
31+
<NavbarWithoutToken />
32+
)}
2733
<MyRouter />
2834
</div>
2935
);
@@ -39,6 +45,7 @@ const mapDispatchToProps = {
3945
authFalse,
4046
resetHistoryOrders,
4147
resetCategory,
48+
resetCart,
4249
};
4350
export default connect(
4451
mapStateToProps,

0 commit comments

Comments
 (0)