|
|
|
@ -1,5 +1,10 @@ |
|
|
|
|
import React, { useState, useEffect } from "react"; |
|
|
|
|
import { userProduct, userFactor, publicApi } from "../../redux/actions"; |
|
|
|
|
import { |
|
|
|
|
userProduct, |
|
|
|
|
userFactor, |
|
|
|
|
publicApi, |
|
|
|
|
dialog, |
|
|
|
|
} from "../../redux/actions"; |
|
|
|
|
import separate from "../../utils/separate"; |
|
|
|
|
import { toast } from "react-toastify"; |
|
|
|
|
import DeliveryForm from "../DeliveryForm"; |
|
|
|
@ -26,7 +31,9 @@ function ShoppingCart({ |
|
|
|
|
setHeaderOptions, |
|
|
|
|
desktopContentTransform, |
|
|
|
|
userProducts, |
|
|
|
|
payFactor, |
|
|
|
|
loading, |
|
|
|
|
setDialog, |
|
|
|
|
}) { |
|
|
|
|
const [phase, setPhase] = useState("products"); |
|
|
|
|
|
|
|
|
@ -49,9 +56,22 @@ function ShoppingCart({ |
|
|
|
|
const next = { |
|
|
|
|
products: () => |
|
|
|
|
productsLength |
|
|
|
|
? setPhase("deliveryForm") |
|
|
|
|
? userProducts.filter((object) => object.productType === 2).length > 0 |
|
|
|
|
? setPhase("deliveryForm") |
|
|
|
|
: setDialog({ |
|
|
|
|
type: "confirm", |
|
|
|
|
text: "به درگاه پرداخت بریم؟", |
|
|
|
|
open: true, |
|
|
|
|
accept: () => payFactor({ userId: user.id }), |
|
|
|
|
}) |
|
|
|
|
: toast.info("ابتدا یک محصول را به سبد خرید خود اضافه کنید."), |
|
|
|
|
deliveryForm: () => console.log("Go to shaparak"), |
|
|
|
|
deliveryForm: () => |
|
|
|
|
setDialog({ |
|
|
|
|
type: "confirm", |
|
|
|
|
text: "به درگاه پرداخت بریم؟", |
|
|
|
|
open: true, |
|
|
|
|
accept: () => payFactor({ userId: user.id }), |
|
|
|
|
}), |
|
|
|
|
profile: () => { |
|
|
|
|
console.log("Set profile"); |
|
|
|
|
console.log("Go to shaparak"); |
|
|
|
@ -284,7 +304,7 @@ function ShoppingCart({ |
|
|
|
|
</p> |
|
|
|
|
</div> |
|
|
|
|
)} |
|
|
|
|
{phase === "deliveryForm" && ( |
|
|
|
|
{null && phase === "deliveryForm" && ( |
|
|
|
|
<div className="flex flex-col mt-10"> |
|
|
|
|
<strong className="text-tiny text-blue52 mb-5 font-medium"> |
|
|
|
|
انتخاب شیوه پرداخت |
|
|
|
@ -310,8 +330,17 @@ function ShoppingCart({ |
|
|
|
|
<br /> |
|
|
|
|
</div> |
|
|
|
|
)} |
|
|
|
|
<br /> |
|
|
|
|
<br /> |
|
|
|
|
<Button |
|
|
|
|
title="ادامه فرایند خرید" |
|
|
|
|
title={ |
|
|
|
|
phase === "deliveryForm" |
|
|
|
|
? "پرداخت" |
|
|
|
|
: userProducts.filter((object) => object.productType === 2) |
|
|
|
|
.length > 0 |
|
|
|
|
? "ادامه فرایند خرید" |
|
|
|
|
: "پرداخت" |
|
|
|
|
} |
|
|
|
|
backgroundColor="bg-blueC0" |
|
|
|
|
border={{ color: "#196EC055", width: "0px" }} |
|
|
|
|
width="100%" |
|
|
|
@ -357,6 +386,7 @@ const mapDispatchToProps = { |
|
|
|
|
getFactorInfo: userFactor.info, |
|
|
|
|
payFactor: userFactor.payment, |
|
|
|
|
setHeaderOptions: publicApi.setHeaderOptions, |
|
|
|
|
setDialog: dialog.set, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(ShoppingCart); |
|
|
|
|