forked from cemaden-educacao/WPD-MobileApp
GabrielTrettel
3 years ago
11 changed files with 245 additions and 54 deletions
-
7src/app/api/Ingestion/appIngestion.js
-
16src/app/api/Ingestion/sendFormAnswer.js
-
96src/app/components/forms/AssembleIngestionObject.js
-
7src/app/components/forms/FormsCode.js
-
12src/app/hooks/useFiltering.js
-
73src/app/hooks/useSocketMarkers.js
-
3src/app/screens/PluviometerRegisterScreen.js
-
7src/app/screens/PluviometerSharingDataScreen.js
-
24src/app/screens/RainSharingDataScreen.js
-
30src/app/screens/RiverFloodSharingDataScreen.js
-
24src/app/screens/SharingFloodZonesScreen.js
@ -0,0 +1,7 @@ |
|||||
|
import { create } from "apisauce"; |
||||
|
|
||||
|
const appIngestion = create({ |
||||
|
baseURL: "https://wpdappingestion.azurewebsites.net", |
||||
|
}); |
||||
|
|
||||
|
export default appIngestion; |
@ -0,0 +1,16 @@ |
|||||
|
import appIngestion from "./appIngestion"; |
||||
|
|
||||
|
const endpoint = "/api/wpdAppIngestion?"; |
||||
|
|
||||
|
async function sendFormAnswer(ingestionObject) { |
||||
|
console.log(JSON.stringify(ingestionObject)); |
||||
|
|
||||
|
const response = await appIngestion.post( |
||||
|
endpoint, |
||||
|
JSON.stringify(ingestionObject) |
||||
|
); |
||||
|
|
||||
|
return response; |
||||
|
} |
||||
|
|
||||
|
export default sendFormAnswer; |
@ -0,0 +1,96 @@ |
|||||
|
import moment from "moment"; |
||||
|
import React from "react"; |
||||
|
import sendFormAnswer from "../../api/Ingestion/sendFormAnswer"; |
||||
|
|
||||
|
const AssembleIngestionObject = ({ |
||||
|
images, |
||||
|
description, |
||||
|
situation, |
||||
|
code, |
||||
|
location, |
||||
|
date, |
||||
|
time, |
||||
|
address, |
||||
|
}) => { |
||||
|
const ingestionObject = { |
||||
|
responseData: { |
||||
|
array_to_json: [ |
||||
|
{ |
||||
|
formcode: code, |
||||
|
formsanswersuserinformer: "admin@wpd.com", |
||||
|
fieldsanswerslongitude: location["longitude"], |
||||
|
fieldsanswerslatitude: location["latitude"], |
||||
|
fields: [ |
||||
|
{ |
||||
|
fieldsanswerssituation: situation ? situation : "CHUVA FRACA", |
||||
|
fieldsanswerseventaddress: address, |
||||
|
fieldsanswerseventdate: moment(date).format("DD-MM-YYYY"), |
||||
|
fieldsanswerseventtime: moment(time).format("HH:mm"), |
||||
|
fieldsanswercomment: description |
||||
|
? description |
||||
|
: "descrição do evento", |
||||
|
}, |
||||
|
], |
||||
|
}, |
||||
|
], |
||||
|
}, |
||||
|
}; |
||||
|
|
||||
|
const a = sendFormAnswer(ingestionObject); |
||||
|
}; |
||||
|
const AssembleIngestionPluviometer = ({ |
||||
|
pluviometer, |
||||
|
description, |
||||
|
images, |
||||
|
date, |
||||
|
time, |
||||
|
}) => { |
||||
|
const pluviometerObject = { |
||||
|
responseData: { |
||||
|
array_to_json: [ |
||||
|
{ |
||||
|
formcode: "PLUVIOMETERS_FORM", |
||||
|
formsanswersuserinformer: "admin@wpd.com", |
||||
|
fias: [ |
||||
|
{ |
||||
|
fieldsanswersdate: moment(date).format("DD-MM-YYYY"), |
||||
|
fieldsanswersrainamount: pluviometer, |
||||
|
fieldsanswerseventtime: moment(time).format("HH:mm"), |
||||
|
fielsanswercomment: description, |
||||
|
}, |
||||
|
], |
||||
|
}, |
||||
|
], |
||||
|
}, |
||||
|
}; |
||||
|
}; |
||||
|
|
||||
|
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, |
||||
|
}; |
@ -0,0 +1,7 @@ |
|||||
|
export const formcode = { |
||||
|
rain: "RAIN_FORM", |
||||
|
river: "RIVERFLOOD_FORM", |
||||
|
floodzones: "FLOODZONES_FORM", |
||||
|
pluviometer: "PLUVIOMETER_FORM", |
||||
|
pluviometerRegistration: "PLUVIOMETER_REGISTRATION", |
||||
|
}; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue