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