import React, { useEffect, useState } from 'react'; import { ActivityIndicator, Button, FlatList, Text, View } from 'react-native'; export default App = ({ navigation }) => { const [mocion, setMocion] = useState(null); const [description, setDescription] = useState(null); const [pin, setPIN] = useState(null); const [response, setResponse] = useState(null); // this connects us to the API and fetches the json file with the mociones const getMociones = async () => { try { const response = await fetch(`http://10.0.0.65:5000/send?PIN=${navigation.state.params.Pin}`); // connection to the website const json = await response.json(); setMocion(json.Mocion); setDescription(json.Description); setPIN(json.PIN); } catch (error) { console.error(error); } } useEffect(() => { getMociones(); }, []); // this recieves the value of the button pressed and sends it to the api const sendVotes = (value) => { console.log(value); // testing that we recied the value //sending to the API const PIN = pin; const Token = 'abc123'; const votos = value; const url = `http://10.190.1.140:5000/vote?PIN=${PIN}&Token=${Token}&votos=${votos}`; //connecting to API fetch(url); console.log(response); }; // here we want to display each mocion in a flatlist // it's supposed to be like buttons. Once clicked it would let you vote inside return ( {mocion} {description} {/* container for the look of the buttons */}