Browse Source
requesting formsfieldsanswers on marker click - yet not working for pluviometer
master
requesting formsfieldsanswers on marker click - yet not working for pluviometer
master
analuizaff
3 years ago
6 changed files with 114 additions and 27 deletions
-
7src/app/api/RequestFieldsAnswers/getFieldsAnswers.js
-
86src/app/components/AssembleModalObject.js
-
19src/app/components/MapModal.js
-
1src/app/components/map/OpenStreetMap.js
-
4src/app/hooks/useFormsAswers.js
-
24src/app/hooks/useSocketMarkers.js
@ -0,0 +1,7 @@ |
|||||
|
import apiClient from "../client"; |
||||
|
|
||||
|
const endpoint = "/hot/fieldsanswers?&faid="; |
||||
|
|
||||
|
const fieldsAnswers = (id) => apiClient.get(endpoint+id); |
||||
|
|
||||
|
export default { fieldsAnswers }; |
@ -0,0 +1,86 @@ |
|||||
|
import moment from 'moment'; |
||||
|
import React from 'react' |
||||
|
import { View, Text } from 'react-native' |
||||
|
|
||||
|
function getLogo(name, situation) { |
||||
|
if (name == "automaticPluviometer") { |
||||
|
return custom_assets.officialPluviometer; |
||||
|
} |
||||
|
|
||||
|
if (name == "pluviometer") { |
||||
|
return custom_assets.pluviometer; |
||||
|
} |
||||
|
|
||||
|
if (name == "rain") { |
||||
|
if (situation == "sem chuva") { |
||||
|
return custom_assets.rainLevel[0]; |
||||
|
} else if (situation == "chuva fraca") { |
||||
|
return custom_assets.rainLevel[1]; |
||||
|
} else if (situation == "chuva moderada") { |
||||
|
return custom_assets.rainLevel[2]; |
||||
|
} else if (situation == "chuva forte") { |
||||
|
return custom_assets.rainLevel[3]; |
||||
|
} else { |
||||
|
return custom_assets.rainLevel[3]; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (name == "riverFlood") { |
||||
|
if (situation == "baixo") { |
||||
|
return custom_assets.riverLevel[0]; |
||||
|
} else if (situation == "normal") { |
||||
|
return custom_assets.riverLevel[1]; |
||||
|
} else if (situation == "alto") { |
||||
|
return custom_assets.riverLevel[2]; |
||||
|
} else if (situation == "inundar") { |
||||
|
return custom_assets.riverLevel[3]; |
||||
|
} |
||||
|
return custom_assets.riverLevel[0]; |
||||
|
} |
||||
|
if (name == "floodZones") { |
||||
|
return custom_assets.floodZones; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
const AssembleModalObject = (response, name) => { |
||||
|
const r = JSON.parse(response); |
||||
|
|
||||
|
var situation = null; |
||||
|
var address = null; |
||||
|
var date = null; |
||||
|
var time = null; |
||||
|
var comments = null; |
||||
|
var pictures = null; |
||||
|
|
||||
|
if (r[0].array_to_json) { |
||||
|
r[0].array_to_json.forEach(function (f) { |
||||
|
if (f.fieldname == "situation") { |
||||
|
situation = f.fieldsanswersvalue; |
||||
|
} |
||||
|
if (f.fieldname == "eventaddress") { |
||||
|
address = f.fieldsanswersvalue; |
||||
|
} |
||||
|
if (f.fieldname == "eventdate") { |
||||
|
date = f.fieldsanswersvalue; |
||||
|
} |
||||
|
if (f.fieldname == "eventtime") { |
||||
|
time = f.fieldsanswersvalue; |
||||
|
} |
||||
|
if (f.fieldname == "comments") { |
||||
|
comments = f.fieldsanswersvalue; |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
return { |
||||
|
"name": name, |
||||
|
"title": situation, |
||||
|
"address": address, |
||||
|
"date": date + " | " + time, |
||||
|
"description": comments, |
||||
|
"logo": getLogo(), |
||||
|
"pictures": pictures, |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
export default AssembleModalObject |
Write
Preview
Loading…
Cancel
Save
Reference in new issue