Przeglądaj źródła

connected front end with backend & reformated code

Jasiel Rivera 1 rok temu
rodzic
commit
e5842c80e8
8 zmienionych plików z 493 dodań i 559 usunięć
  1. 29
    70
      Navigation.js
  2. 23
    141
      screens/Analisis.js
  3. 29
    21
      screens/Button.js
  4. 53
    61
      screens/Denuncias.js
  5. 110
    100
      screens/Derechos.js
  6. 140
    102
      screens/Drna.js
  7. 60
    48
      screens/Formulario.js
  8. 49
    16
      screens/Lista.js

+ 29
- 70
Navigation.js Wyświetl plik

@@ -2,91 +2,50 @@ import React from "react";
2 2
 import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
3 3
 import { createNativeStackNavigator } from "@react-navigation/native-stack";
4 4
 import { NavigationContainer } from "@react-navigation/native";
5
-import { Entypo } from '@expo/vector-icons'; 
6
-import { Ionicons } from '@expo/vector-icons'; 
7 5
 
6
+// Import the screens to be used in the navigator
8 7
 import Denuncias from "./screens/Denuncias";
9 8
 import Derechos from "./screens/Derechos";
10 9
 import Analisis from "./screens/Analisis";
11 10
 import Formulario from "./screens/Formulario";
12 11
 import Lista from "./screens/Lista";
13 12
 import Drna from "./screens/Drna";
14
-import { TabBarIOSItem } from "react-native";
15 13
 
16 14
 const StackDenuncias = createNativeStackNavigator();
17 15
 
18 16
 function Stacks() {
19
-    return (
20
-        <StackDenuncias.Navigator
21
-         initialRouteName="DenunciasIni"
22
-        >
23
-           
24
-            <StackDenuncias.Screen
25
-                name="DenunciasIni"
26
-                component={Denuncias}
27
-            />
28
-            <StackDenuncias.Screen
29
-                name="Formulario"
30
-                component={Formulario}
31
-            />
32
-            <StackDenuncias.Screen
33
-                name="Lista"
34
-                component={Lista}
35
-            />
36
-            <StackDenuncias.Screen
37
-                name="Drna"
38
-                component={Drna}
39
-            />
40
-           
41
-        </StackDenuncias.Navigator>
42
-    )
17
+  return (
18
+    <StackDenuncias.Navigator initialRouteName="DenunciasIni">
19
+      <StackDenuncias.Screen name="DenunciasIni" component={Denuncias} />
20
+      <StackDenuncias.Screen name="Formulario" component={Formulario} />
21
+      <StackDenuncias.Screen name="Lista" component={Lista} />
22
+      <StackDenuncias.Screen name="Drna" component={Drna} />
23
+    </StackDenuncias.Navigator>
24
+  );
43 25
 }
44 26
 
45 27
 const Tab = createBottomTabNavigator();
46 28
 
47 29
 function Tabs() {
48
-    return (
49
-        <Tab.Navigator
50
-        initialRouteName="Denuncias">
51
-            <Tab.Screen 
52
-            name="Denuncias" 
53
-            component={Stacks} 
54
-            options={{
55
-                tabBarIcon: ({}) => (
56
-                    <Entypo name="megaphone" size={24} color="black" />
57
-                ),
58
-                headerShown:false
59
-                
60
-            }} 
61
-           
62
-
63
-            />
64
-            <Tab.Screen 
65
-            name="Derechos" 
66
-            component={Derechos} 
67
-            options={{
68
-                tabBarIcon: ({}) => (
69
-                    <Ionicons name="ios-newspaper-outline" size={24} color="black" />
70
-                )
71
-            }}
72
-            />
73
-            <Tab.Screen 
74
-            name="Analisis" 
75
-            component={Analisis} 
76
-            options={{
77
-                tabBarIcon: ({}) => (
78
-                    <Ionicons name="earth" size={24} color="black" />
79
-                )
80
-            }}
81
-            />
82
-        </Tab.Navigator>
83
-    );
30
+  return (
31
+    <Tab.Navigator initialRouteName="Denuncias">
32
+      <Tab.Screen
33
+        name="Denuncias"
34
+        component={Stacks}
35
+        options={{
36
+          headerShown: false,
37
+        }}
38
+      />
39
+      <Tab.Screen name="Derechos" component={Derechos} />
40
+      <Tab.Screen name="Analisis" component={Analisis} />
41
+    </Tab.Navigator>
42
+  );
84 43
 }
85 44
 
86
-export default function Navigation(){
87
-    return (
88
-        <NavigationContainer>
89
-            <Tabs />
90
-        </NavigationContainer>
91
-    );
92
-}
45
+export default function Navigation() {
46
+  return (
47
+    <NavigationContainer>
48
+      <Tabs />
49
+    </NavigationContainer>
50
+  );
51
+}

+ 23
- 141
screens/Analisis.js Wyświetl plik

@@ -1,144 +1,26 @@
1 1
 import React from "react";
2
-import { View, Text, StyleSheet, TouchableOpacity, Linking, Pressable} from "react-native";
3
-import Tools from "./analisis.json";
4
-
5
-// TOOL DESCRIPTIONS
6
-const bodyEJScreen = "EJScreen es..... Presione para ir al enlace."
7
-const bodyCEJST = "CEJST es..... Presione para ir al enlace."
8
-const bodyEJAtlas = "EJAtlas es..... Presione para ir al enlace."
9
-const bodyIPCC = "El ''Intergovernmental Panel on Climate Change'' o IPCC es..... Presione para ir al enlace."
2
+import {
3
+  View,
4
+  Text,
5
+  StyleSheet,
6
+  TouchableOpacity,
7
+  TextInput,
8
+} from "react-native";
10 9
 
11 10
 const Analisis = () => {
12
-    return (
13
-        <View>
14
-
15
-            {/* TAB TITLE CODE*/}
16
-            {/* TAB TITLE */}
17
-            <Text style={styles.Tab}> 
18
-                Enlaces a Herramientas de Análisis Externas
19
-            </Text>
20
-
21
-            {/* FIRST TOOL CODE*/}
22
-            {/* FIRST TOOL TITLE */}
23
-            <View style={styles.Number}>
24
-                <Text style={styles.Number}>
25
-                    1)</Text>
26
-                <Text style={styles.Title} 
27
-                onPress={ ()=> Linking.openURL('https://ejscreen.epa.gov/mapper/') }>
28
-                    Enlace a EJScreen
29
-                </Text>
30
-            </View>
31
-            {/* FIRST TOOL BODY */}
32
-            <View style={styles.Bullet}>
33
-                <Text style={styles.Bullet}>
34
-                    {'\u002D'}
35
-                </Text>
36
-                <Text style={styles.Body}>
37
-                    {bodyEJScreen}
38
-                </Text>
39
-            </View>
40
-
41
-            {/* SECOND TOOL CODE*/}
42
-            {/* SECOND TOOL TITLE */}
43
-            <View style={styles.Number}>
44
-                <Text style={styles.Number}>
45
-                    2)</Text>
46
-                <Text style={styles.Title} 
47
-                onPress={ ()=> Linking.openURL('https://screeningtool.geoplatform.gov/en/#3/33.47/-97.5') }>
48
-                    Enlace a CEJST
49
-                </Text>
50
-            </View>
51
-            {/* SECOND TOOL BODY */}
52
-            <View style={styles.Bullet}>
53
-                <Text style={styles.Bullet}>
54
-                    {'\u002D'}
55
-                </Text>
56
-                <Text style={styles.Body}>
57
-                    {bodyCEJST}
58
-                </Text>
59
-            </View>
60
-
61
-            {/* THIRD TOOL CODE*/}
62
-            {/* THIRD TOOL TITLE */}
63
-            <View style={styles.Number}>
64
-                <Text style={styles.Number}>
65
-                    3)</Text>
66
-                <Text style={styles.Title} 
67
-                onPress={ ()=> Linking.openURL('https://ejatlas.org/') }>
68
-                    Enlace a EJAtlas
69
-                </Text>
70
-            </View>
71
-            {/* THIRD TOOL BODY */}
72
-            <View style={styles.Bullet}>
73
-                <Text style={styles.Bullet}>
74
-                    {'\u002D'}
75
-                </Text>
76
-                <Text style={styles.Body}>
77
-                    {bodyEJAtlas}
78
-                </Text>
79
-            </View>
80
-
81
-            {/* FOURTH TOOL CODE*/}
82
-            {/* FOURTH TOOL TITLE */}
83
-            <View style={styles.Number}>
84
-                <Text style={styles.Number}>
85
-                    4)</Text>
86
-                <Text style={styles.Title} 
87
-                onPress={ ()=> Linking.openURL('https://www.ipcc.ch/') }>
88
-                    Enlace al IPCC
89
-                </Text>
90
-            </View>
91
-            {/* FOURTH TOOL BODY */}
92
-            <View style={styles.Bullet}>
93
-                <Text style={styles.Bullet}>
94
-                    {'\u002D'}
95
-                </Text>
96
-                <Text style={styles.Body}>
97
-                    {bodyIPCC}
98
-                </Text>
99
-            </View>
100
-        
101
-        </View>
102
-    )
103
-}
104
-
105
-const styles = StyleSheet.create({
106
-    Tab: { fontSize: 30,
107
-           textAlign: "center",
108
-           marginTop: "12%",
109
-           marginLeft: "1.4%",
110
-           marginRight: "1.4%"
111
-    },
112
-
113
-    Number: { fontSize: 23,
114
-        textAlign: "left",
115
-        marginLeft: "2.5%",
116
-        marginTop: "5.5%",
117
-        flexDirection: 'row'
118
-    },
119
-
120
-    Title: { fontSize: 23,
121
-                textAlign: "left",
122
-                marginTop: "5.5%", 
123
-                color: "#6495ed",
124
-                flex: 0,
125
-                paddingLeft: 6
126
-    },
127
-
128
-    Body: { fontSize: 18,
129
-                textAlign: "left",
130
-                marginTop: "2%",
131
-                flex: 1, 
132
-                paddingLeft: 5
133
-    }, 
134
-
135
-    Bullet: { fontSize: 18,
136
-              textAlign: "left",
137
-              marginLeft: "6%",
138
-              marginTop: "2%",
139
-              flexDirection: 'row'
140
-    }
141
-  });
142
-
143
-export default Analisis
144
-
11
+  return (
12
+    <View>
13
+      <Text
14
+        style={{
15
+          fontSize: 30,
16
+          textAlign: "center",
17
+          marginTop: "20%",
18
+        }}
19
+      >
20
+        Herramientas de analisis
21
+      </Text>
22
+    </View>
23
+  );
24
+};
25
+
26
+export default Analisis;

+ 29
- 21
screens/Button.js Wyświetl plik

@@ -1,24 +1,32 @@
1 1
 import React from "react";
2
-import { View, Text, StyleSheet, TouchableOpacity,  Linking, Button, Pressable} from "react-native";
2
+import {
3
+  View,
4
+  Text,
5
+  StyleSheet,
6
+  TouchableOpacity,
7
+  Linking,
8
+  Button,
9
+  Pressable,
10
+} from "react-native";
3 11
 
4 12
 const ButtonLay = StyleSheet.create({
5
-      button: {
6
-        width:250,
7
-        alignSelf: 'center',
8
-        alignItems: 'center',
9
-        justifyContent: 'center',
10
-        paddingVertical: 12,
11
-        paddingHorizontal: 32,
12
-        borderRadius: 4,
13
-        elevation: 3,
14
-        backgroundColor: '#009688',
15
-        marginTop: "5%"
16
-      },
17
-      text: {
18
-        fontSize: 16,
19
-        lineHeight: 21,
20
-        fontWeight: 'bold',
21
-        letterSpacing: 0.25,
22
-        color: 'white',
23
-      }
24
-    })
13
+  button: {
14
+    width: 250,
15
+    alignSelf: "center",
16
+    alignItems: "center",
17
+    justifyContent: "center",
18
+    paddingVertical: 12,
19
+    paddingHorizontal: 32,
20
+    borderRadius: 4,
21
+    elevation: 3,
22
+    backgroundColor: "#009688",
23
+    marginTop: "5%",
24
+  },
25
+  text: {
26
+    fontSize: 16,
27
+    lineHeight: 21,
28
+    fontWeight: "bold",
29
+    letterSpacing: 0.25,
30
+    color: "white",
31
+  },
32
+});

+ 53
- 61
screens/Denuncias.js Wyświetl plik

@@ -3,68 +3,60 @@ import { createNativeStackNavigator } from "@react-navigation/native-stack";
3 3
 import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
4 4
 import { NavigationContainer } from "@react-navigation/native";
5 5
 import React from "react";
6
-import { View, Text, StyleSheet, TouchableOpacity} from "react-native";
7
-
6
+import { View, Text, StyleSheet, TouchableOpacity } from "react-native";
8 7
 
9 8
 const Denuncias = () => {
10
-
11
-    const currNav = useNavigation()
12
-
13
-    return (
14
-        <View>
15
-            <Text
16
-                style={{
17
-                    fontSize: 30,
18
-                    textAlign: "center",
19
-                    marginTop: "20%"
20
-                }}
21
-            
22
-            >Llenar formulario y 
23
-            listado de denuncias</Text>
24
-
25
-            <TouchableOpacity
26
-            style={styles.button}
27
-            onPress={() => currNav.navigate("Formulario")}
28
-        
29
-                >
30
-                <Text style={styles.text}> Formularios </Text>
31
-            </TouchableOpacity>
32
-
33
-            
34
-            <TouchableOpacity
35
-            style={styles.button}
36
-            onPress={() => currNav.navigate("Lista")}
37
-            >
38
-                <Text style={styles.text}>Listado</Text>
39
-            </TouchableOpacity>
40
-
41
-
42
-        </View>
43
-
44
-
45
-    )
46
-}
47
-
48
-export default Denuncias
9
+  const currNav = useNavigation();
10
+
11
+  return (
12
+    <View>
13
+      <Text
14
+        style={{
15
+          fontSize: 30,
16
+          textAlign: "center",
17
+          marginTop: "20%",
18
+        }}
19
+      >
20
+        Llenar formulario y listado de denuncias
21
+      </Text>
22
+
23
+      <TouchableOpacity
24
+        style={styles.button}
25
+        onPress={() => currNav.navigate("Formulario")}
26
+      >
27
+        <Text style={styles.text}> Formularios </Text>
28
+      </TouchableOpacity>
29
+
30
+      <TouchableOpacity
31
+        style={styles.button}
32
+        onPress={() => currNav.navigate("Lista")}
33
+      >
34
+        <Text style={styles.text}>Listado</Text>
35
+      </TouchableOpacity>
36
+    </View>
37
+  );
38
+};
39
+
40
+export default Denuncias;
49 41
 
50 42
 const styles = StyleSheet.create({
51
-    button: {
52
-      width:250,
53
-      alignSelf: 'center',
54
-      alignItems: 'center',
55
-      justifyContent: 'center',
56
-      paddingVertical: 12,
57
-      paddingHorizontal: 32,
58
-      borderRadius: 4,
59
-      elevation: 3,
60
-      backgroundColor: '#009688',
61
-      marginTop: "5%"
62
-    },
63
-    text: {
64
-      fontSize: 16,
65
-      lineHeight: 21,
66
-      fontWeight: 'bold',
67
-      letterSpacing: 0.25,
68
-      color: 'white',
69
-    }
70
-  })
43
+  button: {
44
+    width: 250,
45
+    alignSelf: "center",
46
+    alignItems: "center",
47
+    justifyContent: "center",
48
+    paddingVertical: 12,
49
+    paddingHorizontal: 32,
50
+    borderRadius: 4,
51
+    elevation: 3,
52
+    backgroundColor: "#009688",
53
+    marginTop: "5%",
54
+  },
55
+  text: {
56
+    fontSize: 16,
57
+    lineHeight: 21,
58
+    fontWeight: "bold",
59
+    letterSpacing: 0.25,
60
+    color: "white",
61
+  },
62
+});

+ 110
- 100
screens/Derechos.js Wyświetl plik

@@ -1,115 +1,125 @@
1 1
 import React from "react";
2
-import { View, Text, StyleSheet, TouchableOpacity,  Linking, Pressable} from "react-native";
2
+import {
3
+  View,
4
+  Text,
5
+  StyleSheet,
6
+  TouchableOpacity,
7
+  Linking,
8
+  Pressable,
9
+} from "react-native";
3 10
 import { FlatList, TouchableHighlight } from "react-native-gesture-handler";
4
-import {ButtonLay} from "./Button.js";
11
+import { ButtonLay } from "./Button.js";
5 12
 import Leyes from "./leyes.json";
6 13
 import LeyesPR from "./leyesPR.json";
7 14
 import DerechosAmb from "./derechos.json";
8 15
 
9 16
 const Derechos = () => {
10
-    return (
11
-
12
-        <><View>
13
-
14
-            <Text style={styles.container2}>1) Leyes de la Tierra</Text>
15
-            <View>
16
-                {Leyes.map(ley => {
17
-                    return (
18
-                        <><TouchableOpacity style={styles.button}
19
-                        
20
-                        onPress={() => {
21
-                            Linking.openURL(ley.link.toString());
22
-                        }}>
23
-                            <Text style={styles.text}>{ley.title}</Text>
24
-                        </TouchableOpacity></>
25
-                    );
26
-                })}
27
-            </View>
28
-
29
-        </View>
30
-        
17
+  return (
18
+    <>
19
+      <View>
20
+        <Text style={styles.container2}>1) Leyes de la Tierra</Text>
31 21
         <View>
32
-                <Text style={styles.container2}>2) Derechos del activista climatico</Text>
33
-                <View>
34
-                {DerechosAmb.map(der => {
35
-                    return (
36
-                        <><TouchableOpacity style={styles.button}
37
-                        
38
-                        onPress={() => {
39
-                            Linking.openURL(der.link.toString());
40
-                        }}>
41
-                            <Text style={styles.text}>{der.title}</Text>
42
-                        </TouchableOpacity></>
43
-                    );
44
-                })}
45
-            </View>
46
-
47
-
48
-            </View>
49
-            
50
-            
51
-            <View>
52
-                <Text style={styles.container2}>3) Leyes de Puerto Rico</Text>
53
-                <View>
54
-                {LeyesPR.map(ley => {
55
-                    return (
56
-                        <><TouchableOpacity style={styles.button}
57
-                        
58
-                        onPress={() => {
59
-                            Linking.openURL(ley.link.toString());
60
-                        }}>
61
-                            <Text style={styles.text}>{ley.title}</Text>
62
-                        </TouchableOpacity></>
63
-                    );
64
-                })}
65
-            </View>
66
-            </View></>
67
-
22
+          {Leyes.map((ley) => {
23
+            return (
24
+              <>
25
+                <TouchableOpacity
26
+                  style={styles.button}
27
+                  onPress={() => {
28
+                    Linking.openURL(ley.link.toString());
29
+                  }}
30
+                >
31
+                  <Text style={styles.text}>{ley.title}</Text>
32
+                </TouchableOpacity>
33
+              </>
34
+            );
35
+          })}
36
+        </View>
37
+      </View>
68 38
 
39
+      <View>
40
+        <Text style={styles.container2}>
41
+          2) Derechos del activista climatico
42
+        </Text>
43
+        <View>
44
+          {DerechosAmb.map((der) => {
45
+            return (
46
+              <>
47
+                <TouchableOpacity
48
+                  style={styles.button}
49
+                  onPress={() => {
50
+                    Linking.openURL(der.link.toString());
51
+                  }}
52
+                >
53
+                  <Text style={styles.text}>{der.title}</Text>
54
+                </TouchableOpacity>
55
+              </>
56
+            );
57
+          })}
58
+        </View>
59
+      </View>
69 60
 
70
-    );
71
-}
61
+      <View>
62
+        <Text style={styles.container2}>3) Leyes de Puerto Rico</Text>
63
+        <View>
64
+          {LeyesPR.map((ley) => {
65
+            return (
66
+              <>
67
+                <TouchableOpacity
68
+                  style={styles.button}
69
+                  onPress={() => {
70
+                    Linking.openURL(ley.link.toString());
71
+                  }}
72
+                >
73
+                  <Text style={styles.text}>{ley.title}</Text>
74
+                </TouchableOpacity>
75
+              </>
76
+            );
77
+          })}
78
+        </View>
79
+      </View>
80
+    </>
81
+  );
82
+};
72 83
 
73 84
 const styles = StyleSheet.create({
74
-    container: {
75
-        fontSize: 25,
76
-        textAlign: "center",
77
-        marginTop: "10%"
78
-    },
79
-
80
-    container2: {
81
-        fontSize: 25,
82
-        textAlign: "left",
83
-        marginTop: "10%",
84
-        marginLeft: "5%"
85
-    },
85
+  container: {
86
+    fontSize: 25,
87
+    textAlign: "center",
88
+    marginTop: "10%",
89
+  },
86 90
 
87
-    laws: {
88
-        fontSize: 15,
89
-        textAlign: "center",
90
-        marginTop: "5%"
91
-    },
92
-    button: {
93
-        width:320,
94
-        alignSelf: 'center',
95
-        alignItems: 'center',
96
-        justifyContent: 'center',
97
-        paddingVertical: 12,
98
-        paddingHorizontal: 32,
99
-        borderRadius: 4,
100
-        elevation: 3,
101
-        backgroundColor: '#009688',
102
-        marginTop: "2%"
103
-      },
104
-      text: {
105
-        fontSize: 16,
106
-        lineHeight: 21,
107
-        fontWeight: 'bold',
108
-        letterSpacing: 0.25,
109
-        color: 'white',
110
-        textAlign: "center"
111
-      }
112
-})
91
+  container2: {
92
+    fontSize: 25,
93
+    textAlign: "left",
94
+    marginTop: "10%",
95
+    marginLeft: "5%",
96
+  },
113 97
 
114
-export default Derechos
98
+  laws: {
99
+    fontSize: 15,
100
+    textAlign: "center",
101
+    marginTop: "5%",
102
+  },
103
+  button: {
104
+    width: 250,
105
+    alignSelf: "center",
106
+    alignItems: "center",
107
+    justifyContent: "center",
108
+    paddingVertical: 12,
109
+    paddingHorizontal: 32,
110
+    borderRadius: 4,
111
+    elevation: 3,
112
+    backgroundColor: "#009688",
113
+    marginTop: "5%",
114
+  },
115
+  text: {
116
+    fontSize: 16,
117
+    lineHeight: 21,
118
+    fontWeight: "bold",
119
+    letterSpacing: 0.25,
120
+    color: "white",
121
+    textAlign: "center",
122
+  },
123
+});
115 124
 
125
+export default Derechos;

+ 140
- 102
screens/Drna.js Wyświetl plik

@@ -1,120 +1,158 @@
1 1
 import React from "react";
2
-import { View, Text, StyleSheet, TouchableOpacity, TextInput} from "react-native";
3
-import { SelectList } from 'react-native-dropdown-select-list';
4
-
5
-
6
-
2
+import {
3
+  View,
4
+  Text,
5
+  StyleSheet,
6
+  TouchableOpacity,
7
+  TextInput,
8
+} from "react-native";
9
+import { SelectList } from "react-native-dropdown-select-list";
7 10
 
11
+const postData = (URL, data) => {
12
+  fetch(URL, {
13
+    method: "POST",
14
+    headers: {
15
+      Accept: "application/json",
16
+      "Content-Type": "application/json",
17
+    },
18
+    body: JSON.stringify(data),
19
+  })
20
+    .then((response) => response.json())
21
+    .then((responseJson) => {
22
+      console.log(responseJson);
23
+    })
24
+    .catch((error) => {
25
+      console.error(error);
26
+    });
27
+};
8 28
 
9 29
 const Drna = () => {
10
-    const [text, onChangeText] = React.useState(null);
11
-    const [number, onChangeNumber] = React.useState(null);
12
-    const [selected, setSelected] = React.useState("");
13
-    const leyesViolaciones = [
14
-        {key:'1', value:'Descarga de águas contaminadas'},
15
-        {key:'2', value:'Olores objetables-fuertes'},
16
-        {key:'3', value:'Tala y/o poda de árboles'},
17
-        {key:'4', value:'Rellenando un bosque'},
18
-        {key:'5', value:'Rellenando una quebrada'},
19
-        {key:'6', value:'Realizando perforaciones en el suelo'},
20
-        {key:'7', value:'Moviendo con maquinaria tierra de un lugar a otro'},
21
-        {key:'8', value:'Peces y/o otros organismos muertos'},
22
-        {key:'9', value:'Tapando la vegetación'},
23
-        {key:'10', value:'Destrucción de humedal'},
24
-        {key:'11', value:'Construcción sospechosa'},
25
-        {key:'12', value:'Otros (vertederos clandestinos, entre otros)'},
26
-    ];
30
+  const URL = "http://192.168.50.171:5000/complaints/add";
31
+  const [name, onChangeName] = React.useState(null);
32
+  const [email, onChangeEmail] = React.useState(null);
33
+  const [place, onChangePlace] = React.useState(null);
34
+  const [selected, setSelected] = React.useState("");
35
+  const [description, onChangeDescription] = React.useState(null);
36
+  const leyesViolaciones = [
37
+    { key: "1", value: "Descarga de águas contaminadas" },
38
+    { key: "2", value: "Olores objetables-fuertes" },
39
+    { key: "3", value: "Tala y/o poda de árboles" },
40
+    { key: "4", value: "Rellenando un bosque" },
41
+    { key: "5", value: "Rellenando una quebrada" },
42
+    { key: "6", value: "Realizando perforaciones en el suelo" },
43
+    { key: "7", value: "Moviendo con maquinaria tierra de un lugar a otro" },
44
+    { key: "8", value: "Peces y/o otros organismos muertos" },
45
+    { key: "9", value: "Tapando la vegetación" },
46
+    { key: "10", value: "Destrucción de humedal" },
47
+    { key: "11", value: "Construcción sospechosa" },
48
+    { key: "12", value: "Otros (vertederos clandestinos, entre otros)" },
49
+  ];
27 50
 
28
-    return (
29
-        <View>
30
-            <Text
31
-                style={{
32
-                    fontSize: 30,
33
-                    textAlign: "center",
34
-                    marginTop: "20%"
35
-                }}
36
-            
37
-            >Formulario DRNA</Text>
51
+  return (
52
+    <View>
53
+      <Text
54
+        style={{
55
+          fontSize: 30,
56
+          textAlign: "center",
57
+          marginTop: "20%",
58
+        }}
59
+      >
60
+        Formulario DRNA
61
+      </Text>
38 62
 
39
-        <TextInput
40
-            style={styles.input}
41
-            value={text}
42
-            placeholder="Nombre"
43
-            placeholderTextColor={"grey"}
44
-        />
45
-        <TextInput
46
-            style={styles.input}
47
-            value={text}
48
-            placeholder="Email"
49
-            placeholderTextColor={"grey"}
50
-        />
51
-        <TextInput
63
+      <TextInput
64
+        style={styles.input}
65
+        value={name}
66
+        onChangeText={onChangeName}
67
+        placeholder="Nombre"
68
+        placeholderTextColor={"grey"}
69
+      />
70
+      <TextInput
71
+        style={styles.input}
72
+        value={email}
73
+        onChangeText={onChangeEmail}
74
+        placeholder="Email"
75
+        placeholderTextColor={"grey"}
76
+      />
77
+      {/* <TextInput
52 78
             style={styles.input}
53 79
             value={text}
54 80
             placeholder="Fecha"
55 81
             placeholderTextColor={"grey"}
56
-        />
57
-        <SelectList 
82
+        /> */}
83
+      <SelectList
58 84
         boxStyles={styles.input}
59 85
         dropdownStyles={styles.input2}
60 86
         data={leyesViolaciones}
61 87
         setSelected={setSelected}
62 88
         placeholder="Leyes en violacion"
63
-    
64
-        />
65
-        <TextInput
66
-            style={styles.input}
67
-            value={text}
68
-            placeholder="Lugar de los hechos"
69
-            placeholderTextColor={"grey"}
70
-        />
71
-        <TextInput
72
-            style={styles.input2}
73
-            value={text}
74
-            placeholder="Descripcion de los hechos"
75
-            placeholderTextColor={"grey"}
76
-        />
77
-    <TouchableOpacity style={styles.button}>
78
-                <Text style={styles.text}>Someter</Text>
79
-    </TouchableOpacity>
80
-        </View>
81
-    )
82
-}
89
+      />
90
+      <TextInput
91
+        style={styles.input}
92
+        value={place}
93
+        onChangeText={onChangePlace}
94
+        placeholder="Lugar de los hechos"
95
+        placeholderTextColor={"grey"}
96
+      />
97
+      <TextInput
98
+        style={styles.input2}
99
+        value={description}
100
+        placeholder="Descripcion de los hechos"
101
+        onChangeText={onChangeDescription}
102
+        placeholderTextColor={"grey"}
103
+      />
104
+      <TouchableOpacity
105
+        style={styles.button}
106
+        onPress={() =>
107
+          postData(URL, {
108
+            name: name,
109
+            email: email,
110
+            place: place,
111
+            complaint_type: selected.valueOf(),
112
+            complaint_description: description,
113
+          })
114
+        }
115
+      >
116
+        <Text style={styles.text}>Someter</Text>
117
+      </TouchableOpacity>
118
+    </View>
119
+  );
120
+};
83 121
 
84
-export default Drna
122
+export default Drna;
85 123
 
86 124
 const styles = StyleSheet.create({
87
-    input: {
88
-      height: 40,
89
-      margin: 12,
90
-      borderWidth: 0.5,
91
-      padding: 10,
92
-      borderRadius:10
93
-    },
94
-    input2: {
95
-        height: 100,
96
-        margin: 12,
97
-        borderWidth: 0.5,
98
-        padding: 15,
99
-        borderRadius:10
100
-      },
101
-      button: {
102
-        width:250,
103
-        alignSelf: 'center',
104
-        alignItems: 'center',
105
-        justifyContent: 'center',
106
-        paddingVertical: 12,
107
-        paddingHorizontal: 32,
108
-        borderRadius: 4,
109
-        elevation: 3,
110
-        backgroundColor: '#009688',
111
-        marginTop: "5%"
112
-      },
113
-      text: {
114
-        fontSize: 16,
115
-        lineHeight: 21,
116
-        fontWeight: 'bold',
117
-        letterSpacing: 0.25,
118
-        color: 'white',
119
-      }
120
-  });
125
+  input: {
126
+    height: 40,
127
+    margin: 12,
128
+    borderWidth: 0.5,
129
+    padding: 10,
130
+    borderRadius: 10,
131
+  },
132
+  input2: {
133
+    height: 100,
134
+    margin: 12,
135
+    borderWidth: 0.5,
136
+    padding: 15,
137
+    borderRadius: 10,
138
+  },
139
+  button: {
140
+    width: 250,
141
+    alignSelf: "center",
142
+    alignItems: "center",
143
+    justifyContent: "center",
144
+    paddingVertical: 12,
145
+    paddingHorizontal: 32,
146
+    borderRadius: 4,
147
+    elevation: 3,
148
+    backgroundColor: "#009688",
149
+    marginTop: "5%",
150
+  },
151
+  text: {
152
+    fontSize: 16,
153
+    lineHeight: 21,
154
+    fontWeight: "bold",
155
+    letterSpacing: 0.25,
156
+    color: "white",
157
+  },
158
+});

+ 60
- 48
screens/Formulario.js Wyświetl plik

@@ -3,56 +3,68 @@ import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
3 3
 import { NavigationContainer } from "@react-navigation/native";
4 4
 import { useNavigation } from "@react-navigation/native";
5 5
 import React from "react";
6
-import { View, Text, StyleSheet, TouchableOpacity, Linking} from "react-native";
7
-
6
+import {
7
+  View,
8
+  Text,
9
+  StyleSheet,
10
+  TouchableOpacity,
11
+  Linking,
12
+} from "react-native";
8 13
 
9 14
 const Formulario = () => {
10
-    const currNav = useNavigation()
11
-    return (
12
-        <View>
13
-            <Text
14
-                style={{
15
-                    fontSize: 30,
16
-                    textAlign: "center",
17
-                    marginTop: "20%"
18
-                }}
19
-            
20
-            >Llenar formulario EPA y DRNA</Text>
21
-    
22
-            <TouchableOpacity style={styles.button}
23
-            onPress={() => currNav.navigate("Drna")}>
24
-                    <Text style={styles.text}>Formulario DRNA</Text>
25
-            </TouchableOpacity>
26
-            <TouchableOpacity style={styles.button}
27
-            onPress={() => {
28
-                            Linking.openURL("https://echo.epa.gov/denuncie-violaciones-ambientales");
29
-                        }}>
30
-                <Text style={styles.text}>Formulario EPA</Text>
31
-            </TouchableOpacity>
32
-        </View>
33
-    )
34
-}
15
+  const currNav = useNavigation();
16
+  return (
17
+    <View>
18
+      <Text
19
+        style={{
20
+          fontSize: 30,
21
+          textAlign: "center",
22
+          marginTop: "20%",
23
+        }}
24
+      >
25
+        Llenar formulario EPA y DRNA
26
+      </Text>
27
+
28
+      <TouchableOpacity
29
+        style={styles.button}
30
+        onPress={() => currNav.navigate("Drna")}
31
+      >
32
+        <Text style={styles.text}>Formulario DRNA</Text>
33
+      </TouchableOpacity>
34
+      <TouchableOpacity
35
+        style={styles.button}
36
+        onPress={() => {
37
+          Linking.openURL(
38
+            "https://echo.epa.gov/denuncie-violaciones-ambientales"
39
+          );
40
+        }}
41
+      >
42
+        <Text style={styles.text}>Formulario EPA</Text>
43
+      </TouchableOpacity>
44
+    </View>
45
+  );
46
+};
35 47
 
36
-export default Formulario
48
+export default Formulario;
37 49
 
38 50
 const styles = StyleSheet.create({
39
-    button: {
40
-      width:250,
41
-      alignSelf: 'center',
42
-      alignItems: 'center',
43
-      justifyContent: 'center',
44
-      paddingVertical: 12,
45
-      paddingHorizontal: 32,
46
-      borderRadius: 4,
47
-      elevation: 3,
48
-      backgroundColor: '#009688',
49
-      marginTop: "5%"
50
-    },
51
-    text: {
52
-      fontSize: 16,
53
-      lineHeight: 21,
54
-      fontWeight: 'bold',
55
-      letterSpacing: 0.25,
56
-      color: 'white',
57
-    }
58
-  })
51
+  button: {
52
+    width: 250,
53
+    alignSelf: "center",
54
+    alignItems: "center",
55
+    justifyContent: "center",
56
+    paddingVertical: 12,
57
+    paddingHorizontal: 32,
58
+    borderRadius: 4,
59
+    elevation: 3,
60
+    backgroundColor: "#009688",
61
+    marginTop: "5%",
62
+  },
63
+  text: {
64
+    fontSize: 16,
65
+    lineHeight: 21,
66
+    fontWeight: "bold",
67
+    letterSpacing: 0.25,
68
+    color: "white",
69
+  },
70
+});

+ 49
- 16
screens/Lista.js Wyświetl plik

@@ -1,19 +1,52 @@
1
-import React from "react";
2
-import { View, Text, StyleSheet, TouchableOpacity} from "react-native";
1
+import React, { useEffect, useState } from "react";
2
+import {
3
+  ActivityIndicator,
4
+  FlatList,
5
+  View,
6
+  Text,
7
+  StyleSheet,
8
+  TouchableOpacity,
9
+} from "react-native";
3 10
 
4 11
 const Lista = () => {
5
-    return (
6
-        <View>
7
-            <Text
8
-                style={{
9
-                    fontSize: 30,
10
-                    textAlign: "center",
11
-                    marginTop: "20%"
12
-                }}
13
-            
14
-            >Listado de denuncias</Text>
15
-        </View>
16
-    )
17
-}
12
+  const [isLoading, setLoading] = useState(true);
13
+  const [data, setData] = useState([]);
18 14
 
19
-export default Lista
15
+  const getComplaints = async () => {
16
+    try {
17
+      const response = await fetch("http://192.168.50.171:5000/complaints/all");
18
+      const json = await response.json();
19
+      setData(json.Complaints);
20
+    } catch (error) {
21
+      console.error(error);
22
+    } finally {
23
+      setLoading(false);
24
+    }
25
+  };
26
+
27
+  useEffect(() => {
28
+    getComplaints();
29
+  }, []);
30
+
31
+  return (
32
+    <View style={{ flex: 1, padding: 24 }}>
33
+      {isLoading ? (
34
+        <ActivityIndicator />
35
+      ) : (
36
+        <FlatList
37
+          data={data}
38
+          keyExtractor={({ id }, index) => id}
39
+          renderItem={({ item }) => (
40
+            <Text style={{ padding: 8 }}>
41
+              ID:{item.id}, Tipo de denuncia: {item.complaint_type}, Hecha por:{" "}
42
+              {item.name}, en el lugar: {item.place}, descripcion del problema:{" "}
43
+              {item.complaint_description}
44
+            </Text>
45
+          )}
46
+        />
47
+      )}
48
+    </View>
49
+  );
50
+};
51
+
52
+export default Lista;