Commit b9273ddd authored by Christopher Cottier's avatar Christopher Cottier

user cannot access cart if not logged in

parent 6994d175
This diff is collapsed.
...@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react' ...@@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react'
import CartItem from './CartItem.js' import CartItem from './CartItem.js'
import './shopping-cart.css' import './shopping-cart.css'
import { useSelector, useDispatch } from 'react-redux' import { useSelector, useDispatch } from 'react-redux'
import { Link } from 'react-router-dom' import { Link, Redirect } from 'react-router-dom'
import { updateUserCart } from './../../actions/cart_actions' import { updateUserCart } from './../../actions/cart_actions'
...@@ -74,7 +74,7 @@ export default function ShoppingCart() { ...@@ -74,7 +74,7 @@ export default function ShoppingCart() {
// Sync Cart with backend and redux global state // Sync Cart with backend and redux global state
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
useEffect(() => { useEffect(() => {
if (!userSession) return;
const cartUpdateObj = { const cartUpdateObj = {
userId: userSession.email, userId: userSession.email,
cartItems: cartRefs cartItems: cartRefs
...@@ -85,6 +85,7 @@ export default function ShoppingCart() { ...@@ -85,6 +85,7 @@ export default function ShoppingCart() {
}, [cartItems]) }, [cartItems])
if (!userSession) return <Redirect to="/product-market" />
return ( return (
<div id="shoppingCartContainer"> <div id="shoppingCartContainer">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment