import { faArrowLeft, faCheck } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-native-fontawesome"; import AsyncStorage from "@react-native-async-storage/async-storage"; import { useNavigation, useRoute } from "@react-navigation/native"; import React, { useEffect, useState } from "react"; import { Dimensions, StyleSheet, Text, TouchableOpacity, View, } from "react-native"; import { useToast } from "react-native-toast-notifications"; import Accordion from "../../components/checkout/Accordion"; // import { user } from "../../constants/user"; const width = Dimensions.get("window").width; const AddressSelectionMulti = () => { const navigation = useNavigation(); const [selected, setselected] = useState(0); const route = useRoute(); const { product, shipMethod, payMethod, orderId } = route.params; const [user, setuser] = useState([]); const [shippingAddress, setshippingAddress] = useState([]); const toast = useToast(); useEffect(() => { /* ---------------Check for the user saved email--------------- */ AsyncStorage.getItem("userData") .then((pass) => { const userDataArray = JSON.parse(pass); setuser(userDataArray); const ship = userDataArray[0]?.address.find( (address) => address?.shipping === true ); setshippingAddress(ship); console.log(pass); }) .catch((error) => { console.log(error + "weeewwww"); }); }, []); console.log(shippingAddress); return ( navigation.navigate("CheckOutMultiple", { shipMethod: shipMethod, product, payMethod, orderId: orderId, }) } style={styles.backIcon} > Select Address {user[0]?.address?.map((add, i) => ( setselected(i)} > Recipient: {add.first_name} {add.last_name}, {add.phone} Address: {" "} {add.address_1 + " " + add.address_2 + ", " + add.city + " " + add.province + " "} {add.country === "PH" ? "Philippines" : add.country} {selected === i ? ( ) : null} ))} { toast.show("Successfully Changed Address!", { type: "success", placement: "top", duration: 2000, offset: 30, animationType: "slide-in", }); navigation.navigate("CheckOutMultiple", { shipMethod: selected ? selected : shipMethod, product, payMethod, address: user[0].address[selected], orderId: orderId, }); }} > Confirm ); }; const styles = StyleSheet.create({ container: { backgroundColor: "#fafafa", height: "100%", width: width, }, header: { alignItems: "center", width: "100%", top: 0, paddingLeft: 15, backgroundColor: "#ffffff", 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%", borderRadius: 20, 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", }, listItem: { backgroundColor: "#ffffff", width: "100%", borderWidth: 1, borderColor: "#ececec", padding: 15, flexDirection: "row", justifyContent: "space-between", alignItems: "center", }, listleft: {}, listtop: { flexDirection: "row", paddingBottom: 10, }, listItemText: { fontSize: 16, fontWeight: "600", }, listItemTextPrice: { fontSize: 16, fontWeight: "600", color: "#696969", marginLeft: 10, }, listItemTexteta: { fontSize: 14, marginTop: 5, fontWeight: "500", color: "#818181", marginLeft: 10, }, }); export default AddressSelectionMulti;