diff --git a/src/Redux/actions/index.js b/src/Redux/actions/index.js
index 00e0510..14d1016 100644
--- a/src/Redux/actions/index.js
+++ b/src/Redux/actions/index.js
@@ -7,5 +7,6 @@ export { default as user } from "./user.js";
export { default as qr } from "./qr.js";
export { default as book } from "./book.js";
export { default as userProduct } from "./userProduct.js";
+export { default as userFactor } from "./userFactor.js";
export { default as transport } from "./transport.js";
export { default as comment } from "./comment.js";
diff --git a/src/Redux/actions/userFactor.js b/src/Redux/actions/userFactor.js
new file mode 100644
index 0000000..f88b7fe
--- /dev/null
+++ b/src/Redux/actions/userFactor.js
@@ -0,0 +1,31 @@
+import proxy from "../proxy";
+const userFactor = {
+ list:
+ (data = {}) =>
+ async (dispatch) =>
+ await proxy.get("userFactor/list", data, { dispatch }),
+ info:
+ (data = {}) =>
+ async (dispatch) =>
+ await proxy.get("userFactor/info", data, { dispatch }),
+ update:
+ (data = {}, data2 = {}) =>
+ async (dispatch) => {
+ await proxy.put("userFactor/update", data);
+ await proxy.get("userFactor/list", data2, { dispatch });
+ },
+ add:
+ (data = {}, data2 = {}) =>
+ async (dispatch) => {
+ await proxy.post("userFactor/add", data, { dispatch });
+ await proxy.get("userFactor/list", data2, { dispatch });
+ },
+ del:
+ (data = {}, data2 = {}) =>
+ async (dispatch) => {
+ await proxy.delete("userFactor/delete", data);
+ await proxy.get("userFactor/list", data2, { dispatch });
+ },
+};
+
+export default userFactor;
diff --git a/src/Redux/reducers/index.js b/src/Redux/reducers/index.js
index 67acb5d..f1e8812 100644
--- a/src/Redux/reducers/index.js
+++ b/src/Redux/reducers/index.js
@@ -7,5 +7,6 @@ export { default as user } from "./user.js";
export { default as qr } from "./qr.js";
export { default as book } from "./book.js";
export { default as userProduct } from "./userProduct.js";
+export { default as userFactor } from "./userFactor.js";
export { default as transport } from "./transport.js";
export { default as comment } from "./comment.js";
diff --git a/src/Redux/reducers/userFactor.js b/src/Redux/reducers/userFactor.js
new file mode 100644
index 0000000..43278ac
--- /dev/null
+++ b/src/Redux/reducers/userFactor.js
@@ -0,0 +1,44 @@
+import { toast } from "react-toastify";
+
+const initialState = {
+ loading: false,
+ error: null,
+ list: [],
+ info: null,
+ sum: null,
+ checkEmpty: false,
+};
+export default function userFactor(state = initialState, action) {
+ let { type, data, message } = action;
+ switch (type) {
+ case "userFactor/list":
+ const checkEmpty = data.filter(
+ (item) => item.condition === 2 && item.product.productType === (1 || 3)
+ );
+ return {
+ ...state,
+ loading: false,
+ list: data,
+ checkEmpty: checkEmpty.length > 0 ? false : true,
+ error: null,
+ };
+ case "userFactor/info":
+ return { ...state, loading: false, info: data, error: null };
+ case "userFactor/update":
+ return { ...state, loading: false, error: null };
+ case "userFactor/add":
+ console.log(data);
+ toast.success("درخواست شما با موفقیت انجام شد.");
+ return { ...state, loading: false, error: null, sum: data.payPrice };
+ case "userFactor/delete":
+ return { ...state, loading: false, error: null };
+ /////////////
+ case "loading":
+ return { ...state, loading: true };
+ case "error":
+ toast.error(data.message);
+ return { ...state, loading: false, error: data.message };
+ default:
+ return state;
+ }
+}
diff --git a/src/views/Cart/Discount/index.js b/src/views/Cart/Discount/index.js
index 41b05b4..dd6d406 100644
--- a/src/views/Cart/Discount/index.js
+++ b/src/views/Cart/Discount/index.js
@@ -1,5 +1,7 @@
import React from "react";
import "./index.scss";
+import { connect } from "react-redux";
+import { userFactor } from "~/Redux/actions";
const maxDesktopSize = 1250;
const maxMobileSize = 550;
@@ -19,19 +21,29 @@ const fontSize = {
},
};
-const DiscoutCode = (props) => {
+const DiscoutCode = ({ codeId, setCodeId }) => {
+ const [value, setValue] = React.useState(codeId || "");
+ function setOff() {
+ setCodeId({ codeId: value });
+ }
return (
<>
{window.innerWidth > 1000 ? (
کد تخفیف
- اگر کد تخفیفی دارید آن را در کادر زیر وارد نمائید و دکمه ثبت کد را
- بزنید
+ اگر کد تخفیفی دارید آن را در کادر زیر وارد نمائید
-
-
@@ -41,12 +53,20 @@ const DiscoutCode = (props) => {
) : null}
@@ -54,4 +74,6 @@ const DiscoutCode = (props) => {
);
};
-export default DiscoutCode;
+export default connect((state) => ({ codeId: state.userFactor.codeId }), {
+ setCodeId: userFactor.update,
+})(DiscoutCode);
diff --git a/src/views/Cart/Factor/index.js b/src/views/Cart/Factor/index.js
index 9618fd1..34fbf14 100644
--- a/src/views/Cart/Factor/index.js
+++ b/src/views/Cart/Factor/index.js
@@ -26,11 +26,10 @@ const fontSize = {
const Factor = (props) => {
const { list, parent } = props;
-
const totalPrice = () => {
let total = 0;
- for (let i = 0; i < parent.state.list.length; i++) {
- total += parent.state.list[i].price * parent.state.list[i].number;
+ for (let i = 0; i < list.length; i++) {
+ total += list[i].product.price * list[i].count;
}
return total;
};
@@ -44,7 +43,12 @@ const Factor = (props) => {
هزینه ارسال
- {props.parent.state.selectedDelivery.price} تومان
+
+ {props.parent.props.list.length
+ ? props.parent.state.selectedDelivery.price
+ : 0}{" "}
+ تومان
+
میزان تخفیف
@@ -67,7 +71,10 @@ const Factor = (props) => {
هزینه ارسال
- {props.parent.state.selectedDelivery.price} تومان
+ {props.parent.props.list.length
+ ? props.parent.state.selectedDelivery.price
+ : 0}{" "}
+ تومان
diff --git a/src/views/Cart/Table/index.js b/src/views/Cart/Table/index.js
index 966868a..ed23287 100644
--- a/src/views/Cart/Table/index.js
+++ b/src/views/Cart/Table/index.js
@@ -111,7 +111,7 @@ function BasicTable(props) {
- مبلغ کل {props.payPrice}
+ مبلغ کل {Math.round(props.payPrice)}
@@ -153,7 +153,7 @@ function BasicTable(props) {
- مبلغ کل {props.payPrice}
+ مبلغ کل {Math.round(props.payPrice)}
@@ -186,7 +186,7 @@ const Item = (props) => {
{`کتاب ${
- data.product.productType === "1" ? "دیجیتال" : "فیزیکی"
+ +data.product.productType === 1 ? "دیجیتال" : "فیزیکی"
}` +
" " +
data.product.book.name}
@@ -195,16 +195,28 @@ const Item = (props) => {
{data.product.book.category}
- {data.product.book.item || "هیچی"}
+ {data.product.book.item || ""}
{route !== "callback" ? (
handleDelete(data.id)}
+ onClick={() =>
+ pushToCart({
+ productId: data.productId,
+ userId: id,
+ count: -data.count,
+ })
+ }
/>
handleDelete(data.id)}
+ onClick={() =>
+ pushToCart({
+ productId: data.productId,
+ userId: id,
+ count: -data.count,
+ })
+ }
style={{
fontSize: fontSize.mobile.delete.span,
color: "#FC120A",
@@ -221,11 +233,11 @@ const Item = (props) => {
- {data.product.book.price || "1000"}
+ {data.product.price * data.count || "1000"}
{route !== "callback" ? (
- {data.product.book.subPrice || "100"} قیمت هر واحد
+ {data.product.price || "100"} قیمت هر واحد
) : null}
@@ -271,6 +283,7 @@ const Item = (props) => {
) : null}
) : null}
+ {console.log(data)}
{window.innerWidth > 1000 ? (
@@ -282,7 +295,7 @@ const Item = (props) => {
{`کتاب ${
- data.product.productType === "1" ? "دیجیتال" : "فیزیکی"
+ +data.product.productType === 1 ? "دیجیتال" : "فیزیکی"
}` +
" " +
data.product.book.name}
@@ -299,10 +312,12 @@ const Item = (props) => {
- {data.product.book.price || "1000"} تومان
+ {data.product.price * data.count || "1000"} تومان
- {data.product.book.subPrice || "100"} قیمت هر واحد
+ قیمت هر عدد
+ {data.product.price || "100"}
+ تومان
@@ -365,5 +380,5 @@ export default connect(
info: state.book.info,
id: state.user.status.id,
}),
- { pushToCart: userProduct.add }
+ { pushToCart: userProduct.update }
)(BasicTable);
diff --git a/src/views/Cart/Table/index.scss b/src/views/Cart/Table/index.scss
index 7e0b2df..0d29f07 100644
--- a/src/views/Cart/Table/index.scss
+++ b/src/views/Cart/Table/index.scss
@@ -95,7 +95,7 @@
}
div {
strong {
- font-family: numeralBold;
+ font-family: numeralLight;
color: #373737;
}
p {
@@ -114,7 +114,7 @@
&__price {
color: #4d4d4f;
strong {
- font-family: numeralBold;
+ font-family: numeralLight;
}
span {
font-family: numeralLight;
diff --git a/src/views/Cart/index.js b/src/views/Cart/index.js
index bc07199..4877f88 100644
--- a/src/views/Cart/index.js
+++ b/src/views/Cart/index.js
@@ -43,38 +43,7 @@ class Cart extends Component {
selectedDelivery: { name: "", price: 0 },
discount: 0,
totalPrice: null,
- list: [
- {
- id: 0,
- title: " گسسته ",
- subTitle: " گیرد",
- options: "بپشتی",
- image: sciense_6,
- slicePrice: 200000,
- number: 1,
- price: 1899900,
- },
- {
- id: 1,
- title: "ریاضیات گسسته خیلی پیشرفته",
- subTitle: "در این قسمت توضیح بسیار کوتاهی قرار می گیرد",
- options: "بستههای الحاقی: کیف، کفش و کوله پشتی",
- image: sciense_6,
- slicePrice: 300000,
- number: 1,
- price: 2500000,
- },
- {
- id: 2,
- title: "ریاضیات گسسته خیلی پیشرفته",
- subTitle: "در این قسمت توضیح بسیار کوتاهی قرار می گیرد",
- options: "بستههای الحاقی: کیف، کفش و کوله پشتی",
- image: sciense_6,
- slicePrice: 150000,
- number: 1,
- price: 1000000,
- },
- ],
+ list: this.props.list,
};
componentDidUpdate(prevProps, prevState) {
@@ -165,7 +134,7 @@ class Cart extends Component {
-
+
جمع کل
@@ -181,7 +150,7 @@ class Cart extends Component {
-
+ {/*
روشهای ارسال
@@ -193,7 +162,7 @@ class Cart extends Component {
))}
-
+ */}
پرداخت
@@ -236,7 +205,7 @@ class Cart extends Component {
-
+
جمع کل
@@ -250,7 +219,7 @@ class Cart extends Component {
تومان
-
+ {/*
روشهای ارسال
با توجه به شرایط یکی از دو گزینه زیر را انتخاب کنید
@@ -261,7 +230,7 @@ class Cart extends Component {
))}
-
+ */}
پرداخت
) : (
diff --git a/src/views/Cart/index.scss b/src/views/Cart/index.scss
index 08f0ce0..67650f6 100644
--- a/src/views/Cart/index.scss
+++ b/src/views/Cart/index.scss
@@ -18,7 +18,7 @@
div {
margin-right: 20px;
strong {
- font-family: numeralBold;
+ font-family: numeralLight;
color: #4d4d4f;
margin-left: 5px;
}
@@ -40,7 +40,7 @@
&--header {
h2 {
- font-family: numeralBold;
+ font-family: numeralLight;
color: #2580ec;
}
p {
diff --git a/src/views/Home/Navbar/Laptop/index.scss b/src/views/Home/Navbar/Laptop/index.scss
index 857ae34..384562a 100644
--- a/src/views/Home/Navbar/Laptop/index.scss
+++ b/src/views/Home/Navbar/Laptop/index.scss
@@ -20,7 +20,7 @@
position: relative;
left: 14px;
img {
- max-height: 88%;
+ max-height: 60px;
}
}
&__list {