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