Obanana_test/app/components/profile/Card.jsx

66 lines
1.8 KiB
JavaScript

import { faAngleRight } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-native-fontawesome";
import AsyncStorage from "@react-native-async-storage/async-storage";
import { useNavigation } from "@react-navigation/native";
import React from "react";
import { Linking } from "react-native";
import { StyleSheet, Text, TouchableOpacity, View } from "react-native";
const Card = ({ cart }) => {
const navigation = useNavigation();
const navigate = () => {
if (
cart.nav === "MyPurchases" ||
cart.nav === "MyWallet" ||
cart.nav === "MyFavorites" ||
cart.nav === "ViewHistory" ||
cart.nav === "AccountSettings"
) {
AsyncStorage.getItem("AccessToken")
.then((pass) => {
console.log(pass);
pass === null
? navigation.navigate("Login")
: navigation.navigate(cart.nav);
})
.catch((error) => {
console.log(error + "weeewwww");
});
} else if (cart.nav === "Privacy") {
Linking.openURL("https://www.obanana.com/privacy-policy.php");
} else {
navigation.navigate(cart.nav, { isrefresh: false });
}
};
return (
<View style={styles.container}>
<TouchableOpacity style={styles.subContent} onPress={() => navigate()}>
{cart.icon}
<Text style={styles.subContentText}>{cart.label}</Text>
</TouchableOpacity>
</View>
);
};
const styles = StyleSheet.create({
container: {
width: 120,
justifyContent: "center",
alignItems: "center",
backgroundColor: "#fff",
},
subContent: {
borderRadius: 10,
width: "80%",
height: 140,
margin: "auto",
alignItems: "center",
paddingTop: 30,
},
subContentText: {
marginTop: 15,
color: "#777777",
textAlign: "center",
},
});
export default Card;