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.
 
 
 
 
 

155 lines
3.7 KiB

import {
View,
SafeAreaView,
ScrollView,
StyleSheet,
StatusBar,
Platform,
Dimensions,
} from "react-native";
import React, { useEffect } from "react";
import { connect } from "react-redux";
import { userFactor, userAddress } from "../../redux/actions";
import { asyncAwesomeAlert } from "../../utils/AsyncWrappers";
//components
import Navbar from "../../components/Navbar";
import TransportMethod from "./TransportMethod";
import TransportDate from "./TransportDate";
// import PaymentMethod from "./PaymentMethod";
import Address from "./Address";
import CustomPressable from "../../components/Pressable";
//style
import tw from "tailwind-rn";
import Colors from "../../constants/Colors";
const { height } = Dimensions.get("window");
const DeliveryForm = ({
list,
form,
getList,
getFactorInfo,
userId,
payFactor,
factorInfo,
theme,
}) => {
useEffect(() => {
getFactorInfo({ userId });
getList();
}, []);
React.useEffect(() => {
StatusBar.setBarStyle(
`${theme === "light" ? "dark" : "light"}-content`,
true
);
}, [theme]);
return (
<SafeAreaView
style={{
paddingTop: Platform.OS === "android" ? StatusBar.currentHeight : 0,
position: "relative",
paddingHorizontal: 16,
flex: 1,
}}
>
<Navbar
headerOptions={{
logo: false,
menu: false,
hamburgerMenu: false,
title: "",
bookmark: false,
qr: false,
back: true,
}}
/>
<ScrollView
showsVerticalScrollIndicator={false}
contentContainerStyle={styles.contentContainerStyle}
style={styles.container}
>
<View style={tw("w-full flex pb-4")}>
<View style={tw("w-full flex flex-row")}>
<Address addresses={list} />
</View>
<View style={tw("w-full flex flex-row mt-5")}>
<TransportMethod />
</View>
{factorInfo.transportId === 2 ? (
<View style={tw("w-full flex flex-row mt-5 mb-5")}>
<TransportDate transportDate={form.transportDate} />
</View>
) : null}
</View>
</ScrollView>
<View style={tw("w-full pt-4")}>
<CustomPressable
title={"پرداخت"}
backgroundColor={Colors.theme1.greenCF}
color={"white"}
border={{ color: "#196EC0", width: 0 }}
width={"100%"}
onPress={() =>
factorInfo.transportId && factorInfo.userAddressId
? payFactor({ userId })
: asyncAwesomeAlert("خطا", "آدرس یا نحوه ارسال را وارد کنید", {
showCancelButton: false,
confirmText: "باشه",
})
}
/>
</View>
</SafeAreaView>
);
};
const styles = StyleSheet.create({
contentContainerStyle: {
paddingBottom: 100,
},
container: {
paddingVertical: 5,
},
});
const mapStateToProps = (state) => ({
factorInfo: state.userFactor.info,
userId: state.user.status?.id,
list: state.userAddress.list,
theme: state.publicApi.theme,
});
const mapDispatchToProps = {
getFactorInfo: userFactor.info,
getList: userAddress.list,
payFactor: userFactor.payment,
};
export default connect(mapStateToProps, mapDispatchToProps)(DeliveryForm);
DeliveryForm.defaultProps = {
form: {
transportDate: {
day: new Date(),
times: [
{
time: "ساعت 9 تا 12",
status: "completed",
},
{
time: "ساعت 12 تا 15",
status: "free",
},
{
time: "ساعت 15 تا 18",
status: "free",
},
],
},
},
};