From 6d9381378fa35c597ab0344f4986c5299465e0fc Mon Sep 17 00:00:00 2001 From: analuizaff Date: Fri, 17 Sep 2021 18:35:23 -0300 Subject: [PATCH] preparing structure to add registered pluviometers to the API --- .../forms/AssembleIngestionObject.js | 31 ++++++++++++++++++- src/app/screens/PluviometerRegisterScreen.js | 3 +- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/app/components/forms/AssembleIngestionObject.js b/src/app/components/forms/AssembleIngestionObject.js index d0d33a1..dbc6a54 100644 --- a/src/app/components/forms/AssembleIngestionObject.js +++ b/src/app/components/forms/AssembleIngestionObject.js @@ -64,4 +64,33 @@ const AssembleIngestionPluviometer = ({ }, }; }; -export { AssembleIngestionObject, AssembleIngestionPluviometer }; + +const AssembleIngestionPluvRegistration = ({date, time, user}) => { + const pluvResgistrationObject = { + responseData: { + array_to_json: [ + { + formcode: "PLUVIOMETER_REGISTRATION", + formsanswersuserinformer: "admin@wpd.com", //user + fieldsanswerslongitude: -46.5637, //location["longitude"], + fieldsanswerslatitude: -23.6230,//location["latitude"], + fields: [ + { + fieldsanswerseventaddress: "Rua Rio de Janeiros, 81",//address + fieldsanswerseventdate: moment(date).format("DD-MM-YYYY"), + fieldsanswerseventtime: moment(time).format("HH:mm"), + fieldsanswersinstitutename: "E. E. Vagner", + fieldsanswerrinstitutetype: "Escola", + }, + ], + }, + ], + }, + }; + const a = sendFormAnswer(ingestionObject); +}; +export { + AssembleIngestionObject, + AssembleIngestionPluviometer, + AssembleIngestionPluvRegistration, +}; diff --git a/src/app/screens/PluviometerRegisterScreen.js b/src/app/screens/PluviometerRegisterScreen.js index 4b725de..6e8f33a 100644 --- a/src/app/screens/PluviometerRegisterScreen.js +++ b/src/app/screens/PluviometerRegisterScreen.js @@ -11,6 +11,7 @@ import { TouchableOpacity } from "react-native-gesture-handler"; import { FontAwesome5 } from "@expo/vector-icons"; import { AuthContext } from "../auth/context"; import { Shadow } from "react-native-shadow-2"; +import { AssembleIngestionPluvRegistration } from "../components/forms/AssembleIngestionObject"; const dims = scaleDimsFromWidth(85, 85, 25); @@ -101,7 +102,7 @@ function PluviometerRegisterScreen(props) { duration: 1950, icon: "warning", type: "warning", - onPress: () => {}, + onPress: () => {AssembleIngestionPluvRegistration(date, time, user)}, }); }} >