import React, { useState, createContext } from "react" export const MapDataContext = createContext(); // 1/3(Ana): Preciso melhorar esse código const MapDataProvider = ({ children }) => { const [layers, setLayers] = useState({ values: [ { id: 1, name: 'Chuva', isSelected: true, }, { id: 2, name: 'Ponto de alagamento', isSelected: true, }, { id: 3, name: 'Pluviômetro artesanal', isSelected: true, }, { id: 4, name: 'Pluviômetro oficial', isSelected: false }, { id: 5, name: 'Água no rio', isSelected: true, }, { id: 6, name: 'Área de inundação', isSelected: false, }, ] }); //chuva const [rain, setRain] = useState(true); //Ponto de alagamento const [flood, setFlood] = useState(true); //Pluviometro artesanal const [pluviometer, setPluviometer] = useState(true); //Água no rio const [river, setRiver] = useState(true); //Pluviometro oficial const [officialPluviometer, setOfficialPluviometer] = useState(false); //Área de inundação const [floodAreas, setFloodAreas] = useState(false); //1/3: harcoding const setChanges = (data) => { layers.values = data; setRain(layers.values[0].isSelected); setFlood(layers.values[1].isSelected); setPluviometer(layers.values[2].isSelected); //setOfficialPluviometer(layers.values[3].isSelected); setRiver(layers.values[4].isSelected); //setFloodAreas(layers.values[5].isSelected); } return ( {children} ) } export default MapDataProvider;