Няма описание

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