Browse Source

restricting user action until api returns a response for PLUVIOVEMETER_REGISTRATION

master
analuizaff 3 years ago
parent
commit
7a67b85cbd
  1. 8
      src/app/hooks/usePluviometricStation.js
  2. 3
      src/app/screens/AccountScreen.js
  3. 2
      src/app/screens/PluviometerRegisterScreen.js

8
src/app/hooks/usePluviometricStation.js

@ -7,7 +7,7 @@ async function getPluvStation_data(id) {
if (result.data) { if (result.data) {
return result; return result;
} }
return null;
return undefined;
} }
function assemblePluvStationObject(pluvData) { function assemblePluvStationObject(pluvData) {
@ -64,14 +64,10 @@ async function getPluviometerStation(userId, setPluviometerStation) {
socketObject.onerror = (e) => { socketObject.onerror = (e) => {
console.log(e.message); console.log(e.message);
setPluviometerStation(null);
setPluviometerStation(undefined);
}; };
socketObject.close(); socketObject.close();
socketObject.onclose = () => {
console.log("FECHOU");
};
} }
export default getPluviometerStation; export default getPluviometerStation;

3
src/app/screens/AccountScreen.js

@ -102,10 +102,11 @@ function AccountScreen(props) {
return true return true
} }
const profileItems = [ const profileItems = [
{ {
icon: "account", icon: "account",
show: isRegistered,
show: user.pluviometer != undefined,
IconProvider: MaterialCommunityIcons, IconProvider: MaterialCommunityIcons,
title: user.pluviometer? "Dados do pluviômetro" : "Cadastrar pluviômetro", title: user.pluviometer? "Dados do pluviômetro" : "Cadastrar pluviômetro",
onPress: () => { onPress: () => {

2
src/app/screens/PluviometerRegisterScreen.js

@ -224,7 +224,7 @@ function PluviometerRegisterScreen(props) {
}} }}
> >
<View style={{ flex: 0.05 }}> <View style={{ flex: 0.05 }}>
<Text style={styles.title}>Cadastro do Pluviômetro</Text>
<Text style={styles.title}>{user.pluviometer? "Dados do Pluviômetro" : "Cadastro do Pluviômetro"}</Text>
</View> </View>
<View style={{ flex: 0.95, justifyContent: "space-between" }}> <View style={{ flex: 0.95, justifyContent: "space-between" }}>
<View style={{ flex: 0.19 }}> <View style={{ flex: 0.19 }}>

Loading…
Cancel
Save