You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
108 lines
2.5 KiB
108 lines
2.5 KiB
import React, { useState } from "react"; |
|
import { connect } from "react-redux"; |
|
import { userFactor } from "../../redux/actions"; |
|
|
|
import { |
|
Dimensions, |
|
StyleSheet, |
|
ScrollView, |
|
SafeAreaView, |
|
StatusBar, |
|
Platform, |
|
LayoutAnimation, |
|
} from "react-native"; |
|
|
|
//components |
|
import Order from "./components/Order"; |
|
import Navbar from "../../components/Navbar"; |
|
import Drawer from "../../components/Drawer"; |
|
import Empty from "../../components/Empty"; |
|
|
|
//assets |
|
import b1Image from "./assets/b1.png"; |
|
|
|
const width = Dimensions.get("window").width; |
|
|
|
function OrdersFollowUp({ orders, getList, theme }) { |
|
const [position, setPosition] = useState("100%"); |
|
|
|
React.useEffect(() => { |
|
StatusBar.setBarStyle( |
|
`${theme === "light" ? "dark" : "light"}-content`, |
|
true |
|
); |
|
}, [theme]); |
|
|
|
const setBoxPosition = () => { |
|
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut); |
|
setPosition(position === "100%" ? "0%" : "100%"); |
|
}; |
|
|
|
React.useEffect(() => { |
|
getList(); |
|
}, []); |
|
|
|
return ( |
|
<SafeAreaView |
|
style={{ |
|
paddingTop: Platform.OS === "android" ? StatusBar.currentHeight : 0, |
|
position: "relative", |
|
}} |
|
> |
|
<Navbar |
|
setBoxPosition={setBoxPosition} |
|
headerOptions={{ |
|
logo: false, |
|
menu: false, |
|
hamburgerMenu: false, |
|
title: "سفارشات", |
|
bookmark: false, |
|
qr: false, |
|
back: true, |
|
}} |
|
/> |
|
<Drawer setBoxPosition={setBoxPosition} position={position} /> |
|
{orders?.length ? ( |
|
<ScrollView |
|
contentContainerStyle={styles.contentContainerStyle} |
|
style={styles.container} |
|
> |
|
{orders?.map((order, index) => ( |
|
<Order order={order} key={index} /> |
|
))} |
|
</ScrollView> |
|
) : ( |
|
<Empty |
|
text="هیچ موردی برای شما وجود ندارد." |
|
buttonText={"رفتن به فروشگاه"} |
|
buttonAction={() => navigation.push("Products")} |
|
/> |
|
)} |
|
</SafeAreaView> |
|
); |
|
} |
|
|
|
const styles = StyleSheet.create({ |
|
contentContainerStyle: { |
|
paddingBottom: 100, |
|
alignItems: "flex-end", |
|
}, |
|
container: { |
|
flexDirection: "column", |
|
paddingBottom: 0, |
|
paddingTop: 64, |
|
paddingHorizontal: 16, |
|
}, |
|
}); |
|
|
|
const mapStateToProps = (state) => ({ |
|
orders: state.userFactor.fullList, |
|
theme: state.publicApi.theme, |
|
}); |
|
|
|
const mapDispatchToProps = { |
|
getList: userFactor.fullList, |
|
}; |
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(OrdersFollowUp); |
|
|
|
|