analuizaff
3 years ago
10 changed files with 214 additions and 53 deletions
-
7src/app/api/Ingestion/appIngestion.js
-
16src/app/api/Ingestion/sendFormAnswer.js
-
67src/app/components/forms/AssembleIngestionObject.js
-
7src/app/components/forms/FormsCode.js
-
12src/app/hooks/useFiltering.js
-
37src/app/hooks/useSocketMarkers.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,67 @@ |
|||
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, |
|||
}, |
|||
], |
|||
}, |
|||
], |
|||
}, |
|||
}; |
|||
}; |
|||
export { AssembleIngestionObject, AssembleIngestionPluviometer }; |
@ -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