Browse Source

Fixing undefined date and converting its value to string

master
GabrielTrettel 4 years ago
parent
commit
836146eae1
  1. 5
      src/app/database/databaseLoader.js
  2. 3
      src/app/screens/PluviometerSharingDataScreen.js

5
src/app/database/databaseLoader.js

@ -1,6 +1,9 @@
import "../config/globals"; import "../config/globals";
import moment from "moment";
function transaction(db, query, values) { function transaction(db, query, values) {
console.log("inserting values");
db.transaction((tx) => { db.transaction((tx) => {
tx.executeSql( tx.executeSql(
query, query,
@ -42,7 +45,7 @@ function insertPluviometerData({ pluviometer, images, dateTime, location }) {
} }
const values = [ const values = [
dateTime,
moment(dateTime).format("DD/MM/YYYY"),
JSON.stringify(images), JSON.stringify(images),
parseFloat(location["latitude"]), parseFloat(location["latitude"]),
parseFloat(location["longitude"]), parseFloat(location["longitude"]),

3
src/app/screens/PluviometerSharingDataScreen.js

@ -15,6 +15,7 @@ import { showMessage } from "react-native-flash-message";
import { dimensions, scaleDimsFromWidth } from "../config/dimensions"; import { dimensions, scaleDimsFromWidth } from "../config/dimensions";
import FormDatePicker from "../components/forms/FormDatePicker"; import FormDatePicker from "../components/forms/FormDatePicker";
import colors from "../config/colors/"; import colors from "../config/colors/";
import moment from "moment";
const dims = scaleDimsFromWidth(85, 85, 25); const dims = scaleDimsFromWidth(85, 85, 25);
@ -31,7 +32,7 @@ const validationSchema = Yup.object().shape({
function PluviometerSharingDataScreen(props) { function PluviometerSharingDataScreen(props) {
const location = useLocation(); const location = useLocation();
const [dateTime, setDateTime] = useState();
const [dateTime, setDateTime] = useState(moment());
return ( return (
<Screen style={styles.container}> <Screen style={styles.container}>

Loading…
Cancel
Save