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