import React, { useState, useEffect } from "react";
import { userProduct, userFactor, publicApi } from "../../redux/actions";
// import DeliveryForm from "../DeliveryForm";
import Product from "./Product";
import Code from "./Code";
import Button from "../../components/Button";
//assets
import alertIcon from "../../assets/img/alert.svg";
import { connect } from "react-redux";
function ShoppingCart({
isDark,
isMobile,
list,
payPrice,
factorInfo,
userId,
hasPhysical,
getList,
getInfo,
getFactorInfo,
payFactor,
headerOptions,
setHeaderOptions,
desktopContentTransform,
}) {
const [phase, setPhase] = useState("products");
useEffect(() => {
getList();
getFactorInfo({ userId });
setHeaderOptions(headerOptions);
}, []);
// const Table = () => {
// return (
//
//
//
// کالاهای انتخابی{" "}
//
//
// تعداد سفارش
//
//
// مبلغ
//
//
//
// {list.map((product, index) => (
//
// ))}
//
//
// );
// };
// const PriceStatus = ({ name, value, type }) => {
// return isMobile ? (
//
// {name}
//
// {value + " " + "تومان"}
//
//
// ) : (
//
//
// {name}
//
//
// {value}
//
// تومان
//
//
//
// );
// };
// isMobile ? (
//
// {list.map((product, index) => (
//
// ))}
//
//
//
//
// جمع کل سبد خرید
//
//
// {factorInfo?.payPrice + " " + "تومان"}
//
//
//
// ) : (
//
//
// {/* {phase === "products" &&
}
// {phase === "delivery-form" &&
} */}
//
//
//
//
//
// جمع کل سبد خرید
//
//
// {factorInfo?.payPrice}
// تومان
//
//
// {phase === "delivery-form" && (
//
//
// انتخاب شیوه پرداخت
//
//
// )}
//
setPhase(phase === "products" ? "delivery-form" : "")}
// />
//
//
return(isMobile ?
3 && 'overflow-x-hidden overflow-scroll'}`} style={{height: '35%'}}>
{list.map((product, index) => (
))}
{/* {console.log(list)} */}
جمع مبالغ خدمات
{factorInfo?.sumPrice} تومان
تخفیف
{factorInfo?.offPrice} - تومان
:
3 && 'overflow-x-hidden overflow-scroll'}`} style={{height: '35%'}}>
{list.map((product, index) => (
))}
{/* {console.log(list)} */}
جمع مبالغ خدمات
{factorInfo?.sumPrice} تومان
تخفیف
{factorInfo?.offPrice} - تومان
);
}
const mapStateToProps = (state) => ({
isDark: state.publicApi.isDark,
isMobile: state.publicApi.isMobile,
list: state.userProduct.list,
payPrice: state.userProduct.sum,
factorInfo: state.userFactor.info,
userId: state.user.status.id,
hasPhysical: state.userProduct.hasPhysical,
desktopContentTransform: state.publicApi.desktopContentTransform,
});
const mapDispatchToProps = {
getList: userProduct.list,
getInfo: userProduct.info,
getFactorInfo: userFactor.info,
payFactor: userFactor.payment,
setHeaderOptions: publicApi.setHeaderOptions,
};
export default connect(mapStateToProps, mapDispatchToProps)(ShoppingCart);