|
|
@ -9,7 +9,6 @@ import { MaterialCommunityIcons, FontAwesome } from "@expo/vector-icons"; |
|
|
|
import colors from "../config/colors"; |
|
|
|
import ConfirmationModal from "../components/ConfirmationModal"; |
|
|
|
|
|
|
|
|
|
|
|
function UserHeader({ name, fone }) { |
|
|
|
return ( |
|
|
|
<View style={{ flexDirection: "row", alignItems: "center" }}> |
|
|
@ -74,16 +73,32 @@ function ProfileItensList({ icon, IconProvider, title, onPress }) { |
|
|
|
|
|
|
|
function AccountScreen(props) { |
|
|
|
const { user, setUser } = useContext(AuthContext); |
|
|
|
const [ showLog, setShowLog ] = useState(false); |
|
|
|
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: () => { |
|
|
@ -92,14 +107,16 @@ function AccountScreen(props) { |
|
|
|
}, |
|
|
|
{ |
|
|
|
icon: "institution", |
|
|
|
show: showActivation(), |
|
|
|
IconProvider: FontAwesome, |
|
|
|
title: "ATIVAR INSTITUIÇÃO", |
|
|
|
onPress: () => { |
|
|
|
props.navigation.navigate("ActivateInstitutionCode"); |
|
|
|
activationActions(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
icon: "information-outline", |
|
|
|
show: true, |
|
|
|
IconProvider: MaterialCommunityIcons, |
|
|
|
title: "SOBRE O PROJETO", |
|
|
|
onPress: () => { |
|
|
@ -108,10 +125,11 @@ function AccountScreen(props) { |
|
|
|
}, |
|
|
|
{ |
|
|
|
icon: "logout", |
|
|
|
show: true, |
|
|
|
IconProvider: MaterialCommunityIcons, |
|
|
|
title: "sair", |
|
|
|
onPress: () => { |
|
|
|
setShowLog(true) |
|
|
|
setShowLog(true); |
|
|
|
}, |
|
|
|
}, |
|
|
|
// {
|
|
|
@ -135,7 +153,9 @@ function AccountScreen(props) { |
|
|
|
<UserHeader name={user.nickname} fone={user.username} image={"1"} /> |
|
|
|
|
|
|
|
<View style={{ marginTop: 24 }}> |
|
|
|
{profileItems.map(({ icon, IconProvider, title, onPress }) => ( |
|
|
|
{profileItems.map( |
|
|
|
({ icon, IconProvider, title, onPress, show }) => |
|
|
|
show && ( |
|
|
|
<View key={title}> |
|
|
|
<ProfileItensList |
|
|
|
icon={icon} |
|
|
@ -144,7 +164,8 @@ function AccountScreen(props) { |
|
|
|
onPress={onPress} |
|
|
|
/> |
|
|
|
</View> |
|
|
|
))} |
|
|
|
) |
|
|
|
)} |
|
|
|
</View> |
|
|
|
<ConfirmationModal |
|
|
|
show={showLog} |
|
|
|