parent
b442d23e50
commit
23464e18e2
6 changed files with 126 additions and 105 deletions
@ -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 }) { |
||||
//components
|
||||
import Order from "./components/Order"; |
||||
import Empty from "../../components/Empty"; |
||||
|
||||
React.useEffect(() => { |
||||
setHeaderOptions({ |
||||
logo: true, |
||||
hamburgerMenu: true, |
||||
qr: true, |
||||
title: false, |
||||
back: false, |
||||
shown: true, |
||||
menu: false, |
||||
}); |
||||
}, []); |
||||
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 ( |
||||
<div className="flex flex-col px-4"> |
||||
<div className="flex flex-col px-4 flex-1"> |
||||
{orders?.length ? ( |
||||
<div className="flex-1 flex flex-wrap lg:justify-center"> |
||||
{orders.map((order, index) => ( |
||||
<Order order={order} key={index} /> |
||||
<Order |
||||
order={order} |
||||
key={index} |
||||
setDashboardPage={setDashboardPage} |
||||
isDashboard={isDashboard} |
||||
/> |
||||
))} |
||||
</div> |
||||
) : ( |
||||
<Empty |
||||
text="هیچ محصولی برای شما به ثبت نرسیده است." |
||||
buttonText="ثبت اولین سفارش" |
||||
buttonAction={() => navigation("/products")} |
||||
/> |
||||
)} |
||||
</div> |
||||
); |
||||
} |
||||
|
||||
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); |
||||
|
Loading…
Reference in new issue