import { faAngleRight, faArrowLeft } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-native-fontawesome"; import { useNavigation, useRoute } from "@react-navigation/native"; import React, { useEffect, useState } from "react"; import { View, Text, StyleSheet, TouchableOpacity, TextInput, Image, } from "react-native"; const CheckOut = () => { //NOTE !!!! must pass the update product details to the shipping option and payment method page!!!! to prevent error const [message, setmessage] = useState(""); const [shippingMethod, setshippingMethod] = useState( "select shipping method" ); const [paymentMethod, setpaymentMethod] = useState("select shipping method"); const [recipientDetails, setrecipientDetails] = useState([]); const navigation = useNavigation(); const route = useRoute(); const { product, shipMethod, payMethod, address } = route.params; useEffect(() => { setshippingMethod(shipMethod ?? "select shipping method"); }, [shipMethod]); useEffect(() => { setpaymentMethod(payMethod ?? "select payment method"); }, [payMethod]); useEffect(() => { setrecipientDetails(address ?? null); }, [address]); return ( navigation.navigate("Home")} style={styles.backIcon} > CheckOut {product.shopId} {product.name} {product.price ? ( <> ₱{product.price} {product.promo ? ( {" "} {product.price - product.price * 0.3}{" "} (-{product.promo}%) ) : null} ) : ( No price )} 2 qty navigation.navigate("AddressSelection", { product, shipMethod: shippingMethod, payMethod: paymentMethod, address: recipientDetails, }) } > DELIVERY ADDRESS {recipientDetails !== null ? `${recipientDetails.recipient}, ${recipientDetails.number} ${recipientDetails.address}` : "select address"} navigation.navigate("ShippingOption", { product, shipMethod: shippingMethod, payMethod: paymentMethod, address: recipientDetails, }) } > SHIPPING OPTION {shippingMethod} MESSAGE setmessage()} value={message} numberOfLines={2} placeholder="write a message" /> ORDER TOTAL ₱{product.price} navigation.navigate("Paymentoption", { product, shipMethod: shippingMethod, payMethod: paymentMethod, address: recipientDetails, }) } > PAYMENT OPTION {paymentMethod} PAYMENT DETAILS Merchandise Sub Total: ₱{product.price} Shipping: ₱50 Total: ₱{product.price + 50} navigation.navigate("Home")} > Order Now ); }; const styles = StyleSheet.create({ container: { backgroundColor: "#fff", height: "100%", }, header: { alignItems: "center", width: "100%", top: 0, paddingLeft: 15, flexDirection: "row", borderColor: "#ddd", paddingBottom: 15, borderBottomWidth: 1, }, headerText: { fontSize: 16, fontWeight: "600", marginLeft: 25, }, add: { width: "50%", }, input: { width: "60%", }, wallet: { // width: '50%' }, 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%", width: "100%", height: "100%", }, content: { width: "100%", justifyContent: "center", alignItems: "center", }, subContent: { width: "98%", justifyContent: "space-between", flexDirection: "row", alignItems: "center", padding: 10, // height: 60, borderColor: "#f0f0f0dd", borderWidth: 1, }, subContent1: { width: "98%", justifyContent: "center", // flexDirection: "row", // alignItems: "center", padding: 15, // height: 60, borderColor: "#f0f0f0dd", borderWidth: 1, }, subContent2: { width: "98%", justifyContent: "space-between", flexDirection: "row", // alignItems: "center", padding: 10, // height: 60, borderColor: "#f0f0f0dd", // borderWidth: 1, }, subContentText: { fontWeight: "600", color: "#494949", }, subContentText2: { width: "90%", flexDirection: "row", justifyContent: "space-between", // backgroundColor: "#b8141433", }, subContentTexthead: { fontWeight: "600", color: "#000000", }, addText: { color: "#5f5f5f", textAlign:'left' }, imgWrap: { padding: 10, }, card: { height: 80, flexDirection: "row", // justifyContent: "center", alignItems: "center", borderColor: "#f0f0f0dd", borderWidth: 1, padding: 10, marginTop: 10, }, payCon: { width: "80%", }, priceCon: { flexDirection: "row", paddingVertical: 10, }, rateCon:{ width:'75%', flexDirection: "row", justifyContent:'space-between', alignItems: "center", }, qty:{ fontSize: 14, color: "#5f5f5f", }, textPrice: { fontSize: 14, fontWeight: "600", textTransform: "capitalize", color: "#ffaa00", }, textPricePromo: { fontSize: 14, fontWeight: "600", textTransform: "capitalize", textDecorationLine: "line-through", color: "#ffaa00", }, details: { // width: "50%", }, text: { fontSize: 14, fontWeight:'500', width:'75%' }, }); export default CheckOut;