Skip to content

Commit 28d4a34

Browse files
author
WebDeveloperGuide
committed
Remove Cart and Address data if User Logged Out
1 parent 26e8a30 commit 28d4a34

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

web_panel/src/redux/actions/userActions.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import axios from "axios";
22
import { toast } from "react-toastify";
33
import {ToastObjects} from "../../util/toastObject";
44
import {UserConstants} from "../constants";
5+
import {ActionTypes} from "../constants";
56

67
const {
78
USER_LIST_RESET,
@@ -15,6 +16,12 @@ const {
1516
USER_LOGOUT,
1617
} = UserConstants;
1718

19+
const {
20+
CLEAR_CART_ITEM,
21+
CART_REMOVE_SHIPPING_ADDRESS
22+
} = ActionTypes;
23+
24+
1825
// Register
1926
export const Register = (name, email, password) => async (dispatch) => {
2027

@@ -107,5 +114,9 @@ export const Login = (email, password) => async (dispatch) => {
107114
// Logout
108115
export const logout = () => (dispatch) => {
109116
localStorage.removeItem("userPanelInfo");
117+
localStorage.removeItem("shippingAddress");
118+
localStorage.removeItem("cartItems");
110119
dispatch({ type: USER_LOGOUT });
120+
dispatch({ type: CLEAR_CART_ITEM });
121+
dispatch({ type: CART_REMOVE_SHIPPING_ADDRESS });
111122
};

0 commit comments

Comments
 (0)