|
|
@ -9,6 +9,7 @@ import { Svg, Image as ImageSvg } from "react-native-svg"; |
|
|
|
import PluviometerGraphics from "./PluviometerGraphics"; |
|
|
|
import getFieldsAnswers from "../api/RequestFieldsAnswers/getFieldsAnswers"; |
|
|
|
import AssembleModalObject from "./AssembleModalObject"; |
|
|
|
import moment from "moment"; |
|
|
|
|
|
|
|
const chartHeight = screen_height * 0.3; |
|
|
|
|
|
|
@ -170,6 +171,7 @@ function reviews(props) { |
|
|
|
|
|
|
|
function moreInfo(props) { |
|
|
|
const hasData = props.data.values.length > 0; |
|
|
|
|
|
|
|
return ( |
|
|
|
<View |
|
|
|
style={{ |
|
|
@ -179,7 +181,7 @@ function moreInfo(props) { |
|
|
|
> |
|
|
|
{!hasData ? ( |
|
|
|
<Text style={{ ...styles.text, alignSelf: "center" }}> |
|
|
|
Nenhum dado disponível |
|
|
|
Não há dados para este pluviômetro |
|
|
|
</Text> |
|
|
|
) : ( |
|
|
|
<PluviometerGraphics |
|
|
@ -197,6 +199,7 @@ function componentBody(props) { |
|
|
|
const pictures = JSON.parse(props.pictures); |
|
|
|
const date = props.date ? props.date : "implementando..."; |
|
|
|
const address = props.address ? props.address : "Erro ao carregar endereço"; |
|
|
|
const user = props.user ? props.user : "Usuário ativo"; |
|
|
|
|
|
|
|
return ( |
|
|
|
<View style={styles.bodyRow}> |
|
|
@ -204,9 +207,11 @@ function componentBody(props) { |
|
|
|
|
|
|
|
<View style={styles.bodyInfo}> |
|
|
|
{iconTextRow({ name: "map-marker", description: address })} |
|
|
|
{iconTextRow({ name: "calendar", description: date })} |
|
|
|
{iconTextRow({ name: "account", description: "Usuário ativo" })} |
|
|
|
{iconImageRow({ name: "camera", pic: pictures })} |
|
|
|
{!isPluviometer(props.name) && |
|
|
|
iconTextRow({ name: "calendar", description: date })} |
|
|
|
{iconTextRow({ name: "account", description: user })} |
|
|
|
{props.name != "automaticPluviometer" && |
|
|
|
iconImageRow({ name: "camera", pic: pictures })} |
|
|
|
</View> |
|
|
|
</View> |
|
|
|
); |
|
|
@ -228,15 +233,24 @@ function userMessage(marker) { |
|
|
|
} |
|
|
|
|
|
|
|
function isPluviometer(name) { |
|
|
|
return name === "pluviometer" || name === "officialPluviometer"; |
|
|
|
return name === "pluviometer" || name === "automaticPluviometer"; |
|
|
|
} |
|
|
|
|
|
|
|
function MapModal({ showModal, setShowModal, markers }) { |
|
|
|
const [currentMarker, setCurrentMarker] = useState(undefined); |
|
|
|
var timeFilter = null; |
|
|
|
|
|
|
|
const getAnswers = async (id, name) => { |
|
|
|
const result = await getFieldsAnswers.fieldsAnswers(id); |
|
|
|
if (isPluviometer(name)) { |
|
|
|
const initialDate = moment().format("YYYY-MM-DD"); |
|
|
|
const finalDate = moment().subtract(5, "days").format("YYYY-MM-DD"); |
|
|
|
|
|
|
|
timeFilter = finalDate + "/" + initialDate; |
|
|
|
} |
|
|
|
|
|
|
|
const result = await getFieldsAnswers.fieldsAnswers(timeFilter, id); |
|
|
|
if (result.data) { |
|
|
|
console.log(timeFilter); |
|
|
|
setCurrentMarker( |
|
|
|
AssembleModalObject( |
|
|
|
JSON.stringify(result.data.responseData.array_to_json), |
|
|
|