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.
138 lines
3.6 KiB
138 lines
3.6 KiB
import { |
|
View, |
|
Text, |
|
SafeAreaView, |
|
ScrollView, |
|
StyleSheet, |
|
StatusBar, |
|
Platform, |
|
Dimensions, |
|
Appearance, |
|
} from "react-native"; |
|
import React, { useEffect } from "react"; |
|
import { connect } from "react-redux"; |
|
import { userFactor, userAddress } from "../../redux/actions"; |
|
import { useNavigation } from "@react-navigation/native"; |
|
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"; |
|
import fontSize from "../../constants/fontSize"; |
|
|
|
const DeliveryForm = ({ list, form, getList, getFactorInfo, userId, payFactor, factorInfo }) => { |
|
const colorScheme = Appearance.getColorScheme(); |
|
const navigation = useNavigation(); |
|
|
|
useEffect(() => { |
|
getFactorInfo({ userId }); |
|
getList(); |
|
}, []); |
|
|
|
return ( |
|
<SafeAreaView |
|
style={{ |
|
paddingTop: Platform.OS === "android" ? StatusBar.currentHeight : 0, |
|
position: "relative", |
|
}} |
|
> |
|
<Navbar |
|
headerOptions={{ |
|
logo: false, |
|
menu: false, |
|
hamburgerMenu: false, |
|
title: "", |
|
bookmark: false, |
|
qr: false, |
|
back: true, |
|
}} |
|
/> |
|
<ScrollView |
|
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> |
|
<View style={tw("w-full flex flex-row mt-5 mb-5")}> |
|
<TransportDate transportDate={form.transportDate} /> |
|
</View> |
|
<CustomPressable |
|
title={"ادامه فرایند خرید"} |
|
backgroundColor={Colors.theme1[colorScheme].greenCF} |
|
color={"white"} |
|
border={{ color: "#196EC0", width: 0 }} |
|
width={"100%"} |
|
onPress={() => |
|
factorInfo.transportId && factorInfo.userAddressId |
|
? payFactor({userId}) |
|
: asyncAwesomeAlert("خطا", "آدرس یا نحوه ارسال را وارد کنید", { |
|
showCancelButton: false, |
|
}) |
|
} |
|
/> |
|
</View> |
|
</ScrollView> |
|
</SafeAreaView> |
|
); |
|
}; |
|
|
|
const styles = StyleSheet.create({ |
|
contentContainerStyle: { |
|
paddingBottom: 100, |
|
}, |
|
container: { |
|
backgroundColor: "white", |
|
flexDirection: "column", |
|
paddingVertical: 5, |
|
paddingHorizontal: 16, |
|
}, |
|
}); |
|
|
|
const mapStateToProps = (state) => ({ |
|
factorInfo: state.userFactor.info, |
|
userId: state.user.status?.id, |
|
list: state.userAddress.list, |
|
}); |
|
|
|
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", |
|
}, |
|
], |
|
}, |
|
}, |
|
};
|
|
|