Browse Source

disabling users from sending pluviometer form information when there is no registered pluviometer station

master
analuizaff 3 years ago
parent
commit
369fc06628
  1. 14
      src/app/screens/SharingDataScreen.js

14
src/app/screens/SharingDataScreen.js

@ -11,16 +11,24 @@ import colors from "../config/colors";
function SharingDataScreen({ navigation }) { function SharingDataScreen({ navigation }) {
const authContext = useContext(AuthContext); const authContext = useContext(AuthContext);
const [showLog, setShowLog] = useState(false); const [showLog, setShowLog] = useState(false);
const [showLogPluv, setShowLogPluv] = useState(false);
const isRegistered = authContext.user?.username != null; const isRegistered = authContext.user?.username != null;
const pluviometer = authContext.user?.pluviometer;
console.log(pluviometer)
const pluviometer = authContext.user?.pluviometer ? true : false;
console.log(authContext.user?.pluviometer);
const currentUser = authContext.user; const currentUser = authContext.user;
return ( return (
<View style={styles.container}> <View style={styles.container}>
<ConfirmationModal
show={showLogPluv}
description="Para enviar uma informação pluviométrica cadastre um pluviômetro"
confirmationLabel="OK"
onConfirm={() => etShowLogPluv(false)}//{setShowLogPluv(false), navigation.navigate("Perfil")}}
onDecline={() => setShowLogPluv(false)}
/>
<ConfirmationModal <ConfirmationModal
show={showLog} show={showLog}
description="Para enviar uma informação faça o login ou cadastre-se" description="Para enviar uma informação faça o login ou cadastre-se"
@ -71,7 +79,7 @@ function SharingDataScreen({ navigation }) {
onPress={() => navigation.navigate("PluviometerSharingData", { user: currentUser })} onPress={() => navigation.navigate("PluviometerSharingData", { user: currentUser })}
SvgImage={assets.PluviometricDataIcon} SvgImage={assets.PluviometricDataIcon}
active={isRegistered && pluviometer} active={isRegistered && pluviometer}
inactiveOnPress={() => setShowLog(true)}
inactiveOnPress={() => {setShowLog(!isRegistered), setShowLogPluv(!pluviometer && isRegistered)}}
/> />
<SvgLabeledButton <SvgLabeledButton

Loading…
Cancel
Save