diff --git a/src/app/database/databaseLoader.js b/src/app/database/databaseLoader.js index 2338962..06d03c6 100644 --- a/src/app/database/databaseLoader.js +++ b/src/app/database/databaseLoader.js @@ -55,8 +55,8 @@ function insertPluviometerData({ pluviometer, images, dateTime, location }) { transaction(global.userDataBase, query, values); } -function insertRainData({ images, rain, location }) { - const query = `INSERT INTO RainLevel(RainIdx, Images, Latitude, Longitude) VALUES(?, ?, ?, ?);`; +function insertRainData({ images, description, rain, location }) { + const query = `INSERT INTO RainLevel(RainIdx, Description, Images, Latitude, Longitude) VALUES(?, ?, ?, ?, ?);`; if (location === undefined) { console.debug("undefined location"); @@ -65,6 +65,7 @@ function insertRainData({ images, rain, location }) { const values = [ parseInt(rain), + description, JSON.stringify(images), parseFloat(location["latitude"]), parseFloat(location["longitude"]), @@ -75,8 +76,8 @@ function insertRainData({ images, rain, location }) { transaction(global.userDataBase, query, values); } -function insertRiverData({ images, riverScale, location }) { - const query = `INSERT INTO RiverLevel(RiverIdx, Images, Latitude, Longitude) VALUES(?, ?, ?, ?);`; +function insertRiverData({ images, description, riverScale, location }) { + const query = `INSERT INTO RiverLevel(RiverIdx, Description, Images, Latitude, Longitude) VALUES(?, ?, ?, ?, ?);`; if (location === undefined) { console.debug("undefined location"); @@ -85,6 +86,7 @@ function insertRiverData({ images, riverScale, location }) { const values = [ parseInt(riverScale), + description, JSON.stringify(images), parseFloat(location["latitude"]), parseFloat(location["longitude"]), diff --git a/src/app/database/db.js b/src/app/database/db.js index 03d2394..7d66d50 100644 --- a/src/app/database/db.js +++ b/src/app/database/db.js @@ -1,7 +1,7 @@ // FIXME: Refactor to our database ERM already combined const init_queries = [ - `CREATE TABLE IF NOT EXISTS FloodZones ( + `CREATE TABLE IF NOT EXISTS FloodZones ( Id integer PRIMARY KEY autoincrement, Description text, Images text, @@ -9,7 +9,7 @@ const init_queries = [ Longitude real NOT NULL, Passable INTERGER NOT NULL );`, - `CREATE TABLE IF NOT EXISTS Pluviometer ( + `CREATE TABLE IF NOT EXISTS Pluviometer ( Id integer PRIMARY KEY autoincrement, Date text NOT NULL, Images text, @@ -17,15 +17,17 @@ const init_queries = [ Longitude real NOT NULL, Precipitation real NOT NULL );`, - `CREATE TABLE IF NOT EXISTS RainLevel ( + `CREATE TABLE IF NOT EXISTS RainLevel ( Id integer PRIMARY KEY autoincrement, + Description text, RainIdx INTEGER NOT NULL, Images text, Latitude real NOT NULL, Longitude real NOT NULL );`, - `CREATE TABLE IF NOT EXISTS RiverLevel ( + `CREATE TABLE IF NOT EXISTS RiverLevel ( Id integer PRIMARY KEY autoincrement, + Description text, RiverIdx INTEGER NOT NULL, Images text, Latitude real NOT NULL, diff --git a/src/app/hooks/selectFromDB.js b/src/app/hooks/selectFromDB.js index 2c4ce71..1cb65ba 100644 --- a/src/app/hooks/selectFromDB.js +++ b/src/app/hooks/selectFromDB.js @@ -89,19 +89,19 @@ function parseRiverLevel(row) { if (!is_valid(row["Id"], "river")) { return null; } - + console.log(JSON.stringify(row)); displacement += offset; - const riverLevel = ["Baixo", "Rio normal", "Alto", "Transbordando"]; + const riverLevel = ["baixo", "normal", "alto", "transbordando"]; const riverIdx = row["RiverIdx"]; return { ID: ++ID, - title: "Nível do rio", + title: "Rio" + riverLevel[riverIdx], coordinate: { latitude: row["Latitude"], longitude: row["Longitude"] + displacement, }, image: custom_assets.riverLevel[riverIdx], - description: riverLevel[riverIdx], + description: row["Description"], }; } diff --git a/src/app/screens/RiverFloodSharingDataScreen.js b/src/app/screens/RiverFloodSharingDataScreen.js index 3aee8a2..3db2023 100644 --- a/src/app/screens/RiverFloodSharingDataScreen.js +++ b/src/app/screens/RiverFloodSharingDataScreen.js @@ -2,7 +2,12 @@ import React, { useState } from "react"; import { StyleSheet, View } from "react-native"; import * as Yup from "yup"; -import { Form, FormPicker as Picker, SubmitButton } from "../components/forms"; +import { + Form, + FormPicker as Picker, + SubmitButton, + FormField, +} from "../components/forms"; import Screen from "../components/Screen"; import FormImagePicker from "../components/forms/FormImagePicker"; import useLocation from "../hooks/useLocation"; @@ -17,6 +22,7 @@ import { scaleDimsFromWidth, dimensions } from "../config/dimensions"; const validationSchema = Yup.object().shape({ images: Yup.array(), + description: Yup.string().label("Description"), }); const borderWidth = 4; @@ -46,6 +52,7 @@ function RiverFloodSharingDataScreen(props) {
{ if (riverScale == -1) { @@ -126,7 +133,13 @@ function RiverFloodSharingDataScreen(props) { )} - +