diff --git a/MassiveInput.tsx b/MassiveInput.tsx index 92b0d17..4246180 100644 --- a/MassiveInput.tsx +++ b/MassiveInput.tsx @@ -14,7 +14,7 @@ export default function MassiveInput( (null); const repsRef = useRef(null); - const dark = useColorScheme() === 'dark'; const db = useContext(DatabaseContext); - const {toast} = useContext(SnackbarContext); + + useEffect(() => { + if (!set.created) return; + const matches = set.created.match(/\d+/g); + if (!matches) return; + setYear(matches[0]); + setMonth(matches[1]); + setDay(matches[2]); + setHour(matches[3]); + setMinute(matches[4]); + }, [set.created]); useEffect(() => { console.log('SetForm.useEffect:', {uri, name: set.name}); @@ -41,15 +54,10 @@ export default function SetForm({ const handleSubmit = () => { if (!name) return; - if (created && !created.match(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d$/)) - return toast( - 'Created must be of the format YYYY-mm-ddTHH:mm:ss. E.g. 1996-12-24T12:59:40', - 7000, - ); save({ name, reps: Number(reps), - created, + created: `${year}-${month}-${day}T${hour}:${minute}`, weight: Number(weight), id: set.id, unit, @@ -95,14 +103,43 @@ export default function SetForm({ onSubmitEditing={handleSubmit} /> {set.created && ( - + + + + + + + )} {workouts?.map((workout, index) => (