// React import React, { useEffect, useState } from 'react' // Redux import { useDispatch, useSelector } from 'react-redux' // import { actionCreator as shopCartActionCreator } from '../../../store/reducers/ShopCart' import { ApplicationState } from '../../../store' import { Container } from 'reactstrap' import { FeatherIcon } from '../../../components/FeatherIcons' import style from './scss/style.module.scss' const Cart = () => { const dispatch = useDispatch() const { content, shopCart } = useSelector((state: ApplicationState) => state) const { currencySymbol = "" } = content?.localization ? content.localization : {} const { titleSection = { title: "", text: "" }, productsSection = { product: "", price: "", quantity: "", subtotal: "", continueShopping: { target: "#", anchorText: "" }, submit: { title: "" } } } = content?.shopCart ? content.shopCart : {} const [subtotal, setSubtotal] = useState(0) useEffect(() => { if(shopCart?.items) { let newSubtotal = 0 shopCart.items.forEach(item => { if(item.quantity) newSubtotal += (item.newPrice ? item.newPrice : item.price) * item.quantity }) setSubtotal(newSubtotal) } }, [shopCart?.items]) return

{titleSection.title}

{shopCart?.items ? shopCart.items.length : 0} {titleSection.text}

{(shopCart?.items ? shopCart.items : []).map((item, index) => )}
{productsSection.product} {productsSection.price} {productsSection.quantity}

{item.title}

{item.brandName}

{item.newPrice ? <>{currencySymbol}{item.price.toFixed(2)} {currencySymbol}{item.newPrice.toFixed(2)} : {currencySymbol}{item.price.toFixed(2)}}

{productsSection.subtotal}

{currencySymbol}{subtotal}

{productsSection.submit.title}
{productsSection.continueShopping.anchorText}
} export { Cart }