import React, { useContext, useState } from "react";
import { Text, Image, View, StyleSheet, ScrollView } from "react-native";
import Screen from "../components/Screen";
import { AuthContext } from "../auth/context";
import authStorage from "../auth/storage";
import { TouchableOpacity } from "react-native-gesture-handler";
import assets from "../config/assets";
import { MaterialCommunityIcons, FontAwesome } from "@expo/vector-icons";
import colors from "../config/colors";
import ConfirmationModal from "../components/ConfirmationModal";
function UserHeader({ name, fone }) {
return (
{name}
{fone}
);
}
function ProfileItensList({ icon, IconProvider, title, onPress }) {
return (
{title}
);
}
function AccountScreen(props) {
const { user, setUser } = useContext(AuthContext);
const [showLog, setShowLog] = useState(false);
console.log(user);
const logout = () => {
setUser(null);
authStorage.removeToken();
};
const activationActions = () => {
if (user?.providerActivationKey)
props.navigation.navigate("ActivateInstitutionShowCode");
else
props.navigation.navigate("ActivateInstitutionCode");
};
const showActivation = () => {
if (user.role === "ROLE_CLIENT")
return !user.active
else
return true
}
const profileItems = [
{
icon: "account",
show: true,
IconProvider: MaterialCommunityIcons,
title: "Cadastrar pluviômetro",
onPress: () => {
props.navigation.navigate("PluviometerRegister");
},
},
{
icon: "institution",
show: showActivation(),
IconProvider: FontAwesome,
title: "ATIVAR INSTITUIÇÃO",
onPress: () => {
activationActions();
},
},
{
icon: "information-outline",
show: true,
IconProvider: MaterialCommunityIcons,
title: "SOBRE O PROJETO",
onPress: () => {
props.navigation.navigate("Abbout");
},
},
{
icon: "logout",
show: true,
IconProvider: MaterialCommunityIcons,
title: "sair",
onPress: () => {
setShowLog(true);
},
},
// {
// icon: "trash-can",
// IconProvider: MaterialCommunityIcons,
// title: "DESATIVAR CONTA",
// onPress: () => {
// console.log("7");
// },
// },
];
return (
{profileItems.map(
({ icon, IconProvider, title, onPress, show }) =>
show && (
)
)}
setShowLog(false)}
/>
);
}
const styles = StyleSheet.create({
text: {
fontSize: 16,
},
});
export default AccountScreen;