parent
b442d23e50
commit
23464e18e2
6 changed files with 126 additions and 105 deletions
@ -1,44 +1,63 @@ |
|||||||
import React, { useEffect } from "react"; |
import React, { useEffect } from "react"; |
||||||
import Order from "./components/Order"; |
|
||||||
import { connect } from "react-redux"; |
import { connect } from "react-redux"; |
||||||
import { publicApi } from "../../redux/actions"; |
import { publicApi, userFactor, dashboard } from "../../redux/actions"; |
||||||
//assets
|
import { useNavigate } from "react-router-dom"; |
||||||
import bookImage from "../../assets/images/book-mini.svg"; |
|
||||||
|
|
||||||
function Orders({ orders = [], headerOptions, setHeaderOptions }) { |
//components
|
||||||
|
import Order from "./components/Order"; |
||||||
|
import Empty from "../../components/Empty"; |
||||||
|
|
||||||
React.useEffect(() => { |
function Orders({ |
||||||
setHeaderOptions({ |
orders, |
||||||
logo: true, |
headerOptions, |
||||||
hamburgerMenu: true, |
setHeaderOptions, |
||||||
qr: true, |
getOrdersList, |
||||||
title: false, |
isMobile, |
||||||
back: false, |
isDashboard, |
||||||
shown: true, |
setDashboardPage, |
||||||
menu: false, |
}) { |
||||||
}); |
const navigation = useNavigate(); |
||||||
}, []); |
|
||||||
|
|
||||||
useEffect(() => { |
React.useEffect(() => { |
||||||
// alert();
|
if (isMobile) { |
||||||
window.scrollTo(0, 0); |
setHeaderOptions(headerOptions); |
||||||
|
} |
||||||
|
getOrdersList(); |
||||||
}, []); |
}, []); |
||||||
|
|
||||||
return ( |
return ( |
||||||
<div className="flex flex-col px-4"> |
<div className="flex flex-col px-4 flex-1"> |
||||||
{orders.map((order, index) => ( |
{orders?.length ? ( |
||||||
<Order order={order} key={index} /> |
<div className="flex-1 flex flex-wrap lg:justify-center"> |
||||||
))} |
{orders.map((order, index) => ( |
||||||
|
<Order |
||||||
|
order={order} |
||||||
|
key={index} |
||||||
|
setDashboardPage={setDashboardPage} |
||||||
|
isDashboard={isDashboard} |
||||||
|
/> |
||||||
|
))} |
||||||
|
</div> |
||||||
|
) : ( |
||||||
|
<Empty |
||||||
|
text="هیچ محصولی برای شما به ثبت نرسیده است." |
||||||
|
buttonText="ثبت اولین سفارش" |
||||||
|
buttonAction={() => navigation("/products")} |
||||||
|
/> |
||||||
|
)} |
||||||
</div> |
</div> |
||||||
); |
); |
||||||
} |
} |
||||||
|
|
||||||
const mapStateToProps = (state) => ({ |
const mapStateToProps = (state) => ({ |
||||||
isMobile: state.publicApi.isMobile, |
orders: state.userFactor.fullList, |
||||||
|
isMobile: state.config.device === "mobile", |
||||||
}); |
}); |
||||||
|
|
||||||
const mapDispatchToProps = { |
const mapDispatchToProps = { |
||||||
setHeaderOptions: publicApi.setHeaderOptions, |
setHeaderOptions: publicApi.setHeaderOptions, |
||||||
|
getOrdersList: userFactor.fullList, |
||||||
|
setDashboardPage: dashboard.setPage, |
||||||
}; |
}; |
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(Orders); |
export default connect(mapStateToProps, mapDispatchToProps)(Orders); |
||||||
|
Loading…
Reference in new issue