168 lines
3.8 KiB
React
168 lines
3.8 KiB
React
|
import { faArrowLeft } from "@fortawesome/free-solid-svg-icons";
|
||
|
import { FontAwesomeIcon } from "@fortawesome/react-native-fontawesome";
|
||
|
import { useNavigation, useRoute } from "@react-navigation/native";
|
||
|
import React from "react";
|
||
|
import { useState } from "react";
|
||
|
import {
|
||
|
Dimensions,
|
||
|
StyleSheet,
|
||
|
Text,
|
||
|
TouchableOpacity,
|
||
|
View,
|
||
|
} from "react-native";
|
||
|
import Accordion from "../../components/checkout/Accordion";
|
||
|
const width = Dimensions.get("window").width;
|
||
|
|
||
|
const Paymentoption = () => {
|
||
|
const navigation = useNavigation();
|
||
|
const [selected, setselected] = useState("Visa");
|
||
|
const [selectedFinal, setselectedFinal] = useState("Visa");
|
||
|
|
||
|
const route = useRoute();
|
||
|
const { product, shipMethod, payMethod, address } = route.params;
|
||
|
const paymentMethods = [
|
||
|
{
|
||
|
type: "Credit Card",
|
||
|
methods: [
|
||
|
{
|
||
|
methodName: "Visa",
|
||
|
methodID: "visa123",
|
||
|
},
|
||
|
{
|
||
|
methodName: "MasterCard",
|
||
|
methodID: "mastercard456",
|
||
|
},
|
||
|
],
|
||
|
},
|
||
|
{
|
||
|
type: "Digital Wallet",
|
||
|
methods: [
|
||
|
{
|
||
|
methodName: "PayPal",
|
||
|
methodID: "paypal789",
|
||
|
},
|
||
|
{
|
||
|
methodName: "Apple Pay",
|
||
|
methodID: "applepay987",
|
||
|
},
|
||
|
],
|
||
|
},
|
||
|
{
|
||
|
type: "Bank Transfer",
|
||
|
methods: [
|
||
|
{
|
||
|
methodName: "Chase Bank",
|
||
|
methodID: "chase789",
|
||
|
},
|
||
|
],
|
||
|
},
|
||
|
// Add more payment method types and methods as needed
|
||
|
];
|
||
|
return (
|
||
|
<View style={styles.container}>
|
||
|
<View style={styles.header}>
|
||
|
<TouchableOpacity
|
||
|
onPress={() =>
|
||
|
navigation.navigate("CheckOut", {
|
||
|
shipMethod: shipMethod,
|
||
|
product,
|
||
|
payMethod: payMethod,
|
||
|
address,
|
||
|
})
|
||
|
}
|
||
|
style={styles.backIcon}
|
||
|
>
|
||
|
<FontAwesomeIcon icon={faArrowLeft} color={"#d4c600"} size={25} />
|
||
|
</TouchableOpacity>
|
||
|
<Text style={styles.headerText}>Payment Options</Text>
|
||
|
</View>
|
||
|
<View style={styles.wrapper}>
|
||
|
<Accordion
|
||
|
sections={paymentMethods}
|
||
|
sel={selected}
|
||
|
selected={setselected}
|
||
|
/>
|
||
|
</View>
|
||
|
<View style={styles.footer}>
|
||
|
<TouchableOpacity
|
||
|
style={styles.footerBtn}
|
||
|
onPress={() =>
|
||
|
navigation.navigate("CheckOut", {
|
||
|
shipMethod: shipMethod,
|
||
|
product,
|
||
|
payMethod: selected ? selected : payMethod,
|
||
|
address,
|
||
|
})
|
||
|
}
|
||
|
>
|
||
|
<Text style={styles.footerBtnText}>Confirm</Text>
|
||
|
</TouchableOpacity>
|
||
|
</View>
|
||
|
</View>
|
||
|
);
|
||
|
};
|
||
|
const styles = StyleSheet.create({
|
||
|
container: {
|
||
|
backgroundColor: "#fff",
|
||
|
height: "100%",
|
||
|
width: width,
|
||
|
},
|
||
|
header: {
|
||
|
alignItems: "center",
|
||
|
width: "100%",
|
||
|
top: 0,
|
||
|
paddingLeft: 15,
|
||
|
|
||
|
flexDirection: "row",
|
||
|
borderColor: "#ddd",
|
||
|
paddingBottom: 15,
|
||
|
borderBottomWidth: 1,
|
||
|
},
|
||
|
headerText: {
|
||
|
fontSize: 16,
|
||
|
fontWeight: "600",
|
||
|
marginLeft: 25,
|
||
|
},
|
||
|
headerWrap: {
|
||
|
justifyContent: "center",
|
||
|
alignItems: "center",
|
||
|
width: "100%",
|
||
|
height: "100%",
|
||
|
// flexDirection: "row",
|
||
|
},
|
||
|
footer: {
|
||
|
position: "absolute",
|
||
|
bottom: 0,
|
||
|
width: "100%",
|
||
|
justifyContent: "center",
|
||
|
alignItems: "center",
|
||
|
paddingVertical: 10,
|
||
|
},
|
||
|
footerBtn: {
|
||
|
backgroundColor: "#ff5e00",
|
||
|
width: "90%",
|
||
|
paddingVertical: 10,
|
||
|
justifyContent: "center",
|
||
|
alignItems: "center",
|
||
|
},
|
||
|
footerBtnText: {
|
||
|
color: "#fff",
|
||
|
fontSize: 16,
|
||
|
},
|
||
|
wrapper: {
|
||
|
// height: "85%",
|
||
|
paddingTop: 25,
|
||
|
width: "100%",
|
||
|
// justifyContent: "center",
|
||
|
alignItems: "center",
|
||
|
height: "100%",
|
||
|
},
|
||
|
content: {
|
||
|
width: "100%",
|
||
|
justifyContent: "center",
|
||
|
alignItems: "center",
|
||
|
},
|
||
|
});
|
||
|
|
||
|
export default Paymentoption;
|