Ignore:
Timestamp:
09/08/22 12:38:24 (22 months ago)
Author:
Nace Gjorgjievski <nace.gorgievski123@…>
Branches:
master
Children:
ee05663
Parents:
717ceae
Message:

Added Order Functionality

File:
1 edited

Legend:

Unmodified
Added
Removed
  • frontend/src/Store.js

    r717ceae r16237c4  
    44
    55const initialState = {
     6  userInfo: localStorage.getItem("userInfo")
     7    ? JSON.parse(localStorage.getItem("userInfo"))
     8    : null,
    69  cart: {
     10    shippingAddress: localStorage.getItem("shippingAddress")
     11      ? JSON.parse(localStorage.getItem("shippingAddress"))
     12      : {},
     13    paymentMethod: localStorage.getItem("paymentMethod")
     14      ? localStorage.getItem("paymentMethod")
     15      : "",
    716    cartItems: localStorage.getItem("cartItems")
    817      ? JSON.parse(localStorage.getItem("cartItems"))
     
    3241      return { ...state, cart: { ...state.cart, cartItems } };
    3342    }
     43    case "CART_CLEAR":
     44      return { ...state, cart: { ...state.cart, cartItems: [] } };
     45    case "USER_SIGNIN":
     46      return { ...state, userInfo: action.payload };
     47    case "USER_SIGNOUT":
     48      return {
     49        ...state,
     50        userInfo: null,
     51        cart: { cartItems: [], shippingAddress: {}, paymentMethod: "" },
     52      };
     53    case "SAVE_SHIPPING_ADDRESS":
     54      return {
     55        ...state,
     56        cart: { ...state.cart, shippingAddress: action.payload },
     57      };
     58    case "SAVE_PAYMENT_METHOD":
     59      return {
     60        ...state,
     61        cart: { ...state.cart, paymentMethod: action.payload },
     62      };
    3463    default:
    3564      return state;
Note: See TracChangeset for help on using the changeset viewer.