diff --git a/src/redux/actions/userFactor.js b/src/redux/actions/userFactor.js
index 7bb2c31..83e5ad4 100644
--- a/src/redux/actions/userFactor.js
+++ b/src/redux/actions/userFactor.js
@@ -22,6 +22,10 @@ const userFactor = {
await proxy.delete("userFactor/delete", data);
await proxy.get("userFactor/list", data2, { dispatch });
},
+ fullList:
+ (data = {}) =>
+ async (dispatch) =>
+ await proxy.get("userFactor/fullList", data, { dispatch }),
//vod
vodPayment:
diff --git a/src/redux/reducers/userFactor.js b/src/redux/reducers/userFactor.js
index 4b95047..e64e6f8 100644
--- a/src/redux/reducers/userFactor.js
+++ b/src/redux/reducers/userFactor.js
@@ -7,6 +7,7 @@ const initialState = {
sum: null,
checkEmpty: false,
isVerified: null,
+ fullList: [],
};
export default function userFactor(state = initialState, action) {
@@ -24,6 +25,13 @@ export default function userFactor(state = initialState, action) {
checkEmpty: checkEmpty.length > 0 ? false : true,
error: null,
};
+ case "userFactor/fullList":
+ return {
+ ...state,
+ loading: false,
+ fullList: data,
+ error: null,
+ };
case "userFactor/info":
return { ...state, loading: false, info: data, error: null };
case "userFactor/add":
diff --git a/src/views/Dashboard/layouts/Main/index.js b/src/views/Dashboard/layouts/Main/index.js
index 0a03fd7..7e428c7 100644
--- a/src/views/Dashboard/layouts/Main/index.js
+++ b/src/views/Dashboard/layouts/Main/index.js
@@ -3,6 +3,7 @@ import { connect } from "react-redux";
import { publicApi } from "../../../../redux/actions";
import Orders from "../../../Orders";
+import Order from "../../../Order";
import UserItems from "../Main/UserItems";
import MyBooks from "./MyBooks";
import Ticket from "../../../Contact/layouts/Ticket";
@@ -12,7 +13,8 @@ import Address from "../../../Address";
import Profile from "../../../Auth/Profile";
const views = {
- orders: ,
+ orders: ,
+ order: ,
myBooks: ,
userItems: ,
ticket: (
diff --git a/src/views/Order/index.js b/src/views/Order/index.js
index 15d055c..7b7bdd2 100644
--- a/src/views/Order/index.js
+++ b/src/views/Order/index.js
@@ -19,12 +19,15 @@ const status = {
2: window.t("ارسال شده"),
};
-function OrderDetails({ order, setHeaderOptions, headerOptions }) {
+function OrderDetails({ order, setHeaderOptions, headerOptions, isMobile }) {
useEffect(() => {
- setHeaderOptions(headerOptions);
+ if (isMobile) {
+ setHeaderOptions(headerOptions);
+ }
}, []);
+
return (
-
+
{_.join([window.t("شماره سفارش:"), order.number], " ")}
@@ -149,7 +152,9 @@ function OrderDetails({ order, setHeaderOptions, headerOptions }) {
);
}
-const mapStateToProps = (state) => ({});
+const mapStateToProps = (state) => ({
+ isMobile: state.config.device === "mobile",
+});
const mapDispatchToProps = {
setHeaderOptions: publicApi.setHeaderOptions,
diff --git a/src/views/Orders/components/Order.js b/src/views/Orders/components/Order.js
index a6c8da0..1411bc8 100644
--- a/src/views/Orders/components/Order.js
+++ b/src/views/Orders/components/Order.js
@@ -1,8 +1,10 @@
import React from "react";
import { connect } from "react-redux";
import { Link } from "react-router-dom";
+import moment from "jalali-moment";
+
+//assets
import leftArrowIcon from "../../../assets/icons/dropdown-blue.svg";
-import _ from "lodash";
const colors = {
1: "#FFF700",
@@ -18,107 +20,88 @@ const status = {
2: window.t("ارسال شده"),
};
-function Order({ order, isMobile }) {
+function Order({ order, setDashboardPage, isDashboard }) {
return (
-
+
-
- {_.join([window.t("شماره سفارش:"), order.number], " ")}
-
-
-
- {status[order.status]}
-
-
-
+ {order?.transactionId ? (
+
+ {"شماره سفارش:" + " " + order?.transactionId}
+
+ ) : null}
+ {order?.condition ? (
+
+
+ {status[order?.condition]}
+
+
+
+ ) : null}
- {order.items.length < 2
- ? order?.items?.map((item, index) => (
+ {order.userProducts.length < 2
+ ? order?.userProducts?.map((product, index) => (
))
- : order.items?.slice(0, 1)?.map((item, index) => (
-
- ))}
- {isMobile && order.items.length >= 2 && (
-
- )}
+ : order.userProducts
+ ?.slice(0, 1)
+ ?.map((product, index) => (
+
+ ))}
-
- {_.join([window.t("کد تحویل:"), order.receiveCode], " ")}
-
+ {order?.followCode ? (
+
+ {"کد تحویل:" + " " + order?.followCode}
+
+ ) : null}
-
-
- {_.join([window.t("کد تحویل:"), order.receiveCode], " ")}
-
-
-
- {_.join([window.t("جمع فاکتور:"), order.cost], " ")}
-
+ {"جمع فاکتور:" + " " + order?.payPrice}
+
+ ) : null}
(isDashboard ? setDashboardPage("order") : {})}
>
{window.t("جزئیات سفارش")}
-
- {_.join([window.t("تاریخ سفارش:"), order.date], " ")}
-
+ {order?.payedAt ? (
+
+ {"تاریخ سفارش:" +
+ " " +
+ moment(order?.payedAt)?.format("jYYYY/jMM/jDD")}{" "}
+
+ ) : null}
@@ -126,7 +109,7 @@ function Order({ order, isMobile }) {
}
const mapStateToProps = (state) => ({
- isMobile: state.publicApi.isMobile,
+ isMobile: state.config.device === "mobile",
});
export default connect(mapStateToProps)(Order);
diff --git a/src/views/Orders/index.js b/src/views/Orders/index.js
index 45fc970..269f904 100644
--- a/src/views/Orders/index.js
+++ b/src/views/Orders/index.js
@@ -1,44 +1,63 @@
import React, { useEffect } from "react";
-import Order from "./components/Order";
import { connect } from "react-redux";
-import { publicApi } from "../../redux/actions";
-//assets
-import bookImage from "../../assets/images/book-mini.svg";
+import { publicApi, userFactor, dashboard } from "../../redux/actions";
+import { useNavigate } from "react-router-dom";
-function Orders({ orders = [], headerOptions, setHeaderOptions }) {
-
- React.useEffect(() => {
- setHeaderOptions({
- logo: true,
- hamburgerMenu: true,
- qr: true,
- title: false,
- back: false,
- shown: true,
- menu: false,
- });
- }, []);
+//components
+import Order from "./components/Order";
+import Empty from "../../components/Empty";
+
+function Orders({
+ orders,
+ headerOptions,
+ setHeaderOptions,
+ getOrdersList,
+ isMobile,
+ isDashboard,
+ setDashboardPage,
+}) {
+ const navigation = useNavigate();
- useEffect(() => {
- // alert();
- window.scrollTo(0, 0);
+ React.useEffect(() => {
+ if (isMobile) {
+ setHeaderOptions(headerOptions);
+ }
+ getOrdersList();
}, []);
return (
-
- {orders.map((order, index) => (
-
- ))}
+
+ {orders?.length ? (
+
+ {orders.map((order, index) => (
+
+ ))}
+
+ ) : (
+
navigation("/products")}
+ />
+ )}
);
}
const mapStateToProps = (state) => ({
- isMobile: state.publicApi.isMobile,
+ orders: state.userFactor.fullList,
+ isMobile: state.config.device === "mobile",
});
const mapDispatchToProps = {
setHeaderOptions: publicApi.setHeaderOptions,
+ getOrdersList: userFactor.fullList,
+ setDashboardPage: dashboard.setPage,
};
export default connect(mapStateToProps, mapDispatchToProps)(Orders);