Orlando04 пре 2 година
родитељ
комит
5e21ea6d02

+ 0
- 5
MocionesIUPI/screens/HomeScreen.js Прегледај датотеку

@@ -4,9 +4,6 @@ import { StyleSheet, View, Text, Button } from 'react-native';
4 4
 import { globalStyles } from "../styles/global";
5 5
 
6 6
 export default App = ({ navigation }) => {
7
-    const [isLoading, setLoading] = useState(true);
8
-    const [Description, setDescription] = useState([]); // this is looking for 'Description' and it's content
9
-    const [Mocion, setMocion] = useState([]); // this is looking for 'Mocion' and it's content
10 7
     const [PIN, setPIN] = useState([]); // this is looking for 'PIN' and it's content
11 8
   
12 9
     // this connects us to the API and fetches the json file with the mociones
@@ -16,8 +13,6 @@ export default App = ({ navigation }) => {
16 13
         const json = await response.json();
17 14
   
18 15
         // setting the content of each category 
19
-        setMocion(json.Mocion); 
20
-        setDescription(json.Description);
21 16
         setPIN(json.PIN);
22 17
   
23 18
       } catch (error) {

+ 20
- 1
MocionesIUPI/screens/MocionScreen.js Прегледај датотеку

@@ -7,7 +7,26 @@ export default App = () => {
7 7
   const [isLoading, setLoading] = useState(true);
8 8
   const [Description, setDescription] = useState([]); // this is looking for 'Description' and it's content
9 9
   const [Mocion, setMocion] = useState([]); // this is looking for 'Mocion' and it's content
10
-  const [PIN, setPIN] = useState([]); // this is looking for 'PIN' and it's content
10
+  
11
+      // this connects us to the API and fetches the json file with the mociones
12
+      const getMociones = async () => {
13
+        try {
14
+         const response = await fetch('http://10.190.1.140:5000/send?PIN=121071'); // connection to the website 
15
+         const json = await response.json();
16
+   
17
+         // setting the content of each category 
18
+         setMocion(json.Mocion); 
19
+         setDescription(json.Description);
20
+       } catch (error) {
21
+         console.error(error);
22
+       } finally {
23
+         setLoading(false); // once found the loading icon will be replaced with the content of the json
24
+       }
25
+     }
26
+
27
+     useEffect(() => {
28
+      getMociones();
29
+    }, []);
11 30
 
12 31
 
13 32
   // this is for displaying the mocion on the screen

+ 1
- 1
MocionesIUPI/screens/PincodeScreen.js Прегледај датотеку

@@ -9,7 +9,7 @@ export default class App extends React.Component {
9 9
     
10 10
     pressHandler = () => {
11 11
     {/*Dentro del parentesis va el path al screen para redirigir*/}
12
-      this.props.navigation.navigate('test')
12
+      this.props.navigation.navigate('Mocion')
13 13
     }
14 14
 
15 15
     state = {