Browse Source

adding message afther sending pluviometer registration

master
analuizaff 3 years ago
parent
commit
c9a6133276
  1. 1
      src/app/api/Ingestion/sendFormAnswer.js
  2. 22
      src/app/components/forms/AssembleIngestionObject.js
  3. 2
      src/app/navigation/FeedNavigator.js
  4. 36
      src/app/screens/PluviometerRegisterScreen.js

1
src/app/api/Ingestion/sendFormAnswer.js

@ -9,7 +9,6 @@ async function sendFormAnswer(ingestionObject) {
endpoint, endpoint,
JSON.stringify(ingestionObject) JSON.stringify(ingestionObject)
); );
return response; return response;
} }

22
src/app/components/forms/AssembleIngestionObject.js

@ -1,7 +1,6 @@
import moment from "moment"; import moment from "moment";
import sendFormAnswer from "../../api/Ingestion/sendFormAnswer"; import sendFormAnswer from "../../api/Ingestion/sendFormAnswer";
const AssembleIngestionObject = ( const AssembleIngestionObject = (
{ images, description }, { images, description },
user, user,
@ -64,7 +63,13 @@ const AssembleIngestionPluviometer = ({
}; };
}; };
const AssembleIngestionPluvRegistration = ( date, time, user, address, coordinates ) => {
async function AssembleIngestionPluvRegistration(
date,
time,
user,
address,
coordinates
) {
console.log(user); console.log(user);
console.log(coordinates); console.log(coordinates);
const pluvResgistrationObject = { const pluvResgistrationObject = {
@ -80,16 +85,21 @@ const AssembleIngestionPluvRegistration = ( date, time, user, address, coordinat
fieldsanswerseventaddress: address, fieldsanswerseventaddress: address,
fieldsanswerseventdate: moment(date).format("DD-MM-YYYY"), fieldsanswerseventdate: moment(date).format("DD-MM-YYYY"),
fieldsanswerseventtime: moment(time).format("HH:mm"), fieldsanswerseventtime: moment(time).format("HH:mm"),
fieldsanswersinstitutename: user.institutionName ? user.institutionName : null,
fieldsanswerrinstitutetype: user.institutionType ? user.institutionType : null
fieldsanswersinstitutename: user.institutionName
? user.institutionName
: null,
fieldsanswerrinstitutetype: user.institutionType
? user.institutionType
: null,
}, },
], ],
}, },
], ],
}, },
}; };
const a = sendFormAnswer(pluvResgistrationObject);
};
const a = await sendFormAnswer(pluvResgistrationObject);
return a;
}
export { export {
AssembleIngestionObject, AssembleIngestionObject,
AssembleIngestionPluviometer, AssembleIngestionPluviometer,

2
src/app/navigation/FeedNavigator.js

@ -8,7 +8,7 @@ const FeedNavigator = () => (
<Stack.Navigator> <Stack.Navigator>
<Stack.Screen name="Map" component={MapFeedScreen} <Stack.Screen name="Map" component={MapFeedScreen}
options={{ options={{
title: "Pega Chuva",
title: "Dados à Prova d'água",
headerStyle: { headerStyle: {
backgroundColor: "white", backgroundColor: "white",
}, },

36
src/app/screens/PluviometerRegisterScreen.js

@ -102,19 +102,47 @@ function PluviometerRegisterScreen(props) {
<View> <View>
<Form <Form
initialValues={{}} initialValues={{}}
onSubmit={() => {
AssembleIngestionPluvRegistration(
onSubmit={async () => {
showMessage({
message: "Aguarde! Estamos enviando a informação.",
duration: 2005,
icon: "warning",
type: "warning",
onPress: () => {},
});
const isSent = await AssembleIngestionPluvRegistration(
date, date,
time, time,
user, user,
location, location,
coordinates coordinates
); );
if (isSent.ok) {
showMessage({
message: "Pluviômetro cadastrado!",
duration: 1950,
icon: "success",
type: "success",
onPress: () => {},
});
props.navigation.navigate("Home");
}
else{
showMessage({
message: "Erro ao cadastrar pluviômetro. Por favor, tente mais tarde!",
duration: 1950,
icon: "danger",
type: "danger",
onPress: () => {},
});
}
}} }}
> >
<View padding={16}> <View padding={16}>
<Text style={styles.title}>Cadastro do Pluviômetro</Text> <Text style={styles.title}>Cadastro do Pluviômetro</Text>
<View>
<Text <Text
style={{ style={{
marginTop: 24, marginTop: 24,
@ -141,7 +169,7 @@ function PluviometerRegisterScreen(props) {
formTypeFace={"pluviometerRegister"} formTypeFace={"pluviometerRegister"}
/> />
</View> </View>
</View>
<Text style={styles.label}>Endereço do pluviômetro*: </Text> <Text style={styles.label}>Endereço do pluviômetro*: </Text>
<LocationPicker <LocationPicker
navigation={props.navigation} navigation={props.navigation}

Loading…
Cancel
Save