From c9a6133276b24f4a0995ef27e3e3c6d9c41cf537 Mon Sep 17 00:00:00 2001 From: analuizaff Date: Fri, 5 Nov 2021 22:06:22 -0300 Subject: [PATCH 1/3] adding message afther sending pluviometer registration --- src/app/api/Ingestion/sendFormAnswer.js | 1 - .../forms/AssembleIngestionObject.js | 30 ++++--- src/app/navigation/FeedNavigator.js | 2 +- src/app/screens/PluviometerRegisterScreen.js | 84 ++++++++++++------- 4 files changed, 77 insertions(+), 40 deletions(-) diff --git a/src/app/api/Ingestion/sendFormAnswer.js b/src/app/api/Ingestion/sendFormAnswer.js index bd71052..48383a6 100644 --- a/src/app/api/Ingestion/sendFormAnswer.js +++ b/src/app/api/Ingestion/sendFormAnswer.js @@ -9,7 +9,6 @@ async function sendFormAnswer(ingestionObject) { endpoint, JSON.stringify(ingestionObject) ); - return response; } diff --git a/src/app/components/forms/AssembleIngestionObject.js b/src/app/components/forms/AssembleIngestionObject.js index 7b9b512..619e05e 100644 --- a/src/app/components/forms/AssembleIngestionObject.js +++ b/src/app/components/forms/AssembleIngestionObject.js @@ -1,7 +1,6 @@ import moment from "moment"; import sendFormAnswer from "../../api/Ingestion/sendFormAnswer"; - const AssembleIngestionObject = ( { images, description }, user, @@ -17,7 +16,7 @@ const AssembleIngestionObject = ( array_to_json: [ { formcode: code, - formsanswersuserinformer: "admin@wpd.com",//user.id, + formsanswersuserinformer: "admin@wpd.com", //user.id, fieldsanswerslongitude: location["longitude"], fieldsanswerslatitude: location["latitude"], fields: [ @@ -49,7 +48,7 @@ const AssembleIngestionPluviometer = ({ array_to_json: [ { formcode: "PLUVIOMETERS_FORM", - formsanswersuserinformer: "admin@wpd.com",//user.id, + formsanswersuserinformer: "admin@wpd.com", //user.id, fias: [ { fieldsanswersdate: moment(date).format("DD-MM-YYYY"), @@ -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(coordinates); const pluvResgistrationObject = { @@ -72,24 +77,29 @@ const AssembleIngestionPluvRegistration = ( date, time, user, address, coordinat array_to_json: [ { formcode: "PLUVIOMETER_REGISTRATION", - formsanswersuserinformer: "admin@wpd.com",//user.id, + formsanswersuserinformer: "admin@wpd.com", //user.id, fieldsanswerslongitude: coordinates["longitude"], - fieldsanswerslatitude: coordinates["latitude"], + fieldsanswerslatitude: coordinates["latitude"], fields: [ { fieldsanswerseventaddress: address, fieldsanswerseventdate: moment(date).format("DD-MM-YYYY"), 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 { AssembleIngestionObject, AssembleIngestionPluviometer, diff --git a/src/app/navigation/FeedNavigator.js b/src/app/navigation/FeedNavigator.js index 6cc687e..7c1d9e0 100644 --- a/src/app/navigation/FeedNavigator.js +++ b/src/app/navigation/FeedNavigator.js @@ -8,7 +8,7 @@ const FeedNavigator = () => (
{ - AssembleIngestionPluvRegistration( + onSubmit={async () => { + showMessage({ + message: "Aguarde! Estamos enviando a informação.", + duration: 2005, + icon: "warning", + type: "warning", + onPress: () => {}, + }); + const isSent = await AssembleIngestionPluvRegistration( date, time, user, location, 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: () => {}, + }); + + } }} > Cadastro do Pluviômetro + + + Data do cadastro:{" "} + - - Data do cadastro:{" "} - - - - setDate(value)} - onTimeChange={(value) => setTime(value)} - date={date} - time={time} - formTypeFace={"pluviometerRegister"} - /> + + setDate(value)} + onTimeChange={(value) => setTime(value)} + date={date} + time={time} + formTypeFace={"pluviometerRegister"} + /> + - Endereço do pluviômetro*: Date: Fri, 5 Nov 2021 22:21:26 -0300 Subject: [PATCH 2/3] adding the correct app's name to screens --- src/app/screens/Abbout.js | 2 +- src/app/screens/LoginScreen.js | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/app/screens/Abbout.js b/src/app/screens/Abbout.js index 1b65c13..9d27f1c 100644 --- a/src/app/screens/Abbout.js +++ b/src/app/screens/Abbout.js @@ -15,7 +15,7 @@ export default function Abbout(props) { return ( - Waterproofing Data + Dados à Prova d'água diff --git a/src/app/screens/LoginScreen.js b/src/app/screens/LoginScreen.js index 962b988..c315af1 100644 --- a/src/app/screens/LoginScreen.js +++ b/src/app/screens/LoginScreen.js @@ -102,13 +102,7 @@ export default function LoginScreen(props) { } > - + Dados à Prova d'água Date: Fri, 5 Nov 2021 22:32:10 -0300 Subject: [PATCH 3/3] updating pluviometer image at 'SharingDataScreen --- src/app/config/assets.js | 3 +++ src/app/screens/SharingDataScreen.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/app/config/assets.js b/src/app/config/assets.js index 90894a7..6c3bcfc 100644 --- a/src/app/config/assets.js +++ b/src/app/config/assets.js @@ -1,4 +1,6 @@ import Pluviometer from "../assets/pluviometer/pluviometer-logo.svg"; +import PluviometerSharingData from "../assets/pluviometer/pluviometricDataIcon.svg"; + import OfficialPluviometer from "../assets/pluviometer/PluviometroOficial.svg"; import SusceptibilityAreas from "../assets/dataMenu/suceptibilitiesAreas.svg"; import RainIcon from "../assets/rain/rain-icon.svg"; @@ -105,6 +107,7 @@ export default { officialPluviometer: require("../assets/pluviometer/pluviometroOficial.png"), officialPluviometer_pin: PinPluviometerOfficial, PluviometerIcon: Pluviometer, + PluviometricDataIcon: PluviometerSharingData, OfficialPluviometer: OfficialPluviometer, AppLogoTitle: AppLogoTitle, SusceptibilityAreas: SusceptibilityAreas, diff --git a/src/app/screens/SharingDataScreen.js b/src/app/screens/SharingDataScreen.js index 0e97aa3..aa6ae6c 100644 --- a/src/app/screens/SharingDataScreen.js +++ b/src/app/screens/SharingDataScreen.js @@ -65,7 +65,7 @@ function SharingDataScreen({ navigation }) { style={{ marginRight: 24 }} label={"DIÁRIO DO\nPLUVIÔMETRO"} onPress={() => navigation.navigate("PluviometerSharingData", { user: currentUser })} - SvgImage={assets.PluviometerIcon} + SvgImage={assets.PluviometricDataIcon} active={isRegistered} inactiveOnPress={() => setShowLog(true)} />