From fd66bd3ab3fd7b056a63fbab205ef87b456807f1 Mon Sep 17 00:00:00 2001 From: Brandon Presley Date: Sat, 20 Aug 2022 16:38:18 +1200 Subject: [PATCH] Remove date related logic This kept displaying the wrong date/time for certain timezones. So i'll just show the actual ISO date we store in the database. Maybe later i'll figure out what was going on here or use a date library (probably not). --- SetForm.tsx | 106 +++++++++++++++++++-------------------------------- SetItem.tsx | 7 +--- package.json | 1 - yarn.lock | 13 ------- 4 files changed, 42 insertions(+), 85 deletions(-) diff --git a/SetForm.tsx b/SetForm.tsx index a69e922..06ed1f9 100644 --- a/SetForm.tsx +++ b/SetForm.tsx @@ -1,9 +1,7 @@ import React, {useRef, useState} from 'react'; -import {ScrollView, StyleSheet} from 'react-native'; -import DateTimePickerModal from 'react-native-modal-datetime-picker'; +import {ScrollView, StyleSheet, Text} from 'react-native'; import {Button, TextInput} from 'react-native-paper'; import Set from './set'; -import {format} from './time'; export default function SetForm({ save, @@ -15,90 +13,66 @@ export default function SetForm({ const [name, setName] = useState(set.name); const [reps, setReps] = useState(set.reps.toString()); const [weight, setWeight] = useState(set.weight.toString()); - const [created, setCreated] = useState(new Date(set.created)); const [unit, setUnit] = useState(set.unit); - const [showDate, setShowDate] = useState(false); const [selection, setSelection] = useState({ start: 0, end: set.reps.toString().length, }); const weightRef = useRef(null); - - const onConfirm = (date: Date) => { - setCreated(date); - setShowDate(false); - }; - const handleSubmit = () => { save({ name, reps: Number(reps), - created: created.toISOString(), + created: set.created, weight: Number(weight), id: set.id, unit, }); }; - const textInputs = ( - <> - - weightRef.current?.focus()} - selection={selection} - onSelectionChange={e => setSelection(e.nativeEvent.selection)} - autoFocus - selectTextOnFocus - blurOnSubmit={false} - /> - - - - ); - return ( <> - {textInputs} - - setShowDate(false)} - date={created} + label="Name" + value={name} + onChangeText={setName} + autoCorrect={false} + selectTextOnFocus /> + weightRef.current?.focus()} + selection={selection} + onSelectionChange={e => setSelection(e.nativeEvent.selection)} + autoFocus + selectTextOnFocus + blurOnSubmit={false} + /> + + + {set.created?.replace('T', ' ')}