Obanana_test/app/pages/checkout/Paymentoption.jsx

186 lines
4.5 KiB
React
Raw Permalink Normal View History

2023-09-26 14:33:01 +08:00
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";
2024-02-12 08:58:57 +08:00
import { useToast } from "react-native-toast-notifications";
2023-09-26 14:33:01 +08:00
import Accordion from "../../components/checkout/Accordion";
const width = Dimensions.get("window").width;
const Paymentoption = () => {
const navigation = useNavigation();
2024-02-12 08:58:57 +08:00
const [selected, setselected] = useState("Obananapay");
const [orderIdC, setorderIdC] = useState("Visa");
const toast = useToast();
2023-09-26 14:33:01 +08:00
const route = useRoute();
2024-02-12 08:58:57 +08:00
const { product, shipMethod, payMethod, address, orderId } = route.params;
console.log("paymentmethod " + product);
2023-09-26 14:33:01 +08:00
const paymentMethods = [
{
2024-02-12 08:58:57 +08:00
methodName: "Obananapay",
// methodID: "visa123",
2023-09-26 14:33:01 +08:00
},
{
2024-02-12 08:58:57 +08:00
methodName: "Cash On Delivery",
// methodID: "visa123",
2023-09-26 14:33:01 +08:00
},
2024-02-12 08:58:57 +08:00
// {
// type: "Obanana",
// methods: [
// {
// methodName: "Obananapay",
// // methodID: "visa123",
// },
// ],
// },
// {
// type: "Digital Wallet",
// methods: [
// {
// methodName: "PayPal",
// methodID: "paypal789",
// },
// {
// methodName: "Apple Pay",
// methodID: "applepay987",
// },
// ],
// },
// {
// type: "Bank Transfer",
// methods: [
// {
// methodName: "Chase Bank",
// methodID: "chase789",
// },
// ],
// },
2023-09-26 14:33:01 +08:00
// 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,
2024-02-12 08:58:57 +08:00
product: product,
payMethod: payMethod,
address: address,
orderId: orderId ? orderId : null,
2023-09-26 14:33:01 +08:00
})
}
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}
2024-02-12 08:58:57 +08:00
onPress={() => {
toast.show("Successfully Changed Payment Method!", {
type: "success",
placement: "top",
duration: 2000,
offset: 30,
animationType: "slide-in",
});
2023-09-26 14:33:01 +08:00
navigation.navigate("CheckOut", {
shipMethod: shipMethod,
2024-02-12 08:58:57 +08:00
product: product,
2023-09-26 14:33:01 +08:00
payMethod: selected ? selected : payMethod,
2024-02-12 08:58:57 +08:00
address: address,
orderId: orderId,
});
}}
2023-09-26 14:33:01 +08:00
>
<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,
2024-02-12 08:58:57 +08:00
borderRadius: 20,
2023-09-26 14:33:01 +08:00
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;