GideonNeedleman / 5x5

0 stars 0 forks source link

Structure submission data into correct shape #24

Closed GideonNeedleman closed 10 months ago

GideonNeedleman commented 10 months ago

Submitted data is not formatted into discrete sets to be logged. Instead it's an object with a sequence of individual metrics as values with exercise and set ids as property names.

Need to reformat this into an array of set objects. Each set object should be something like: { timestamp, exerciseId, weight, reps }

Or more generally: { timestamp, exerciseId, metric1, metric2, metric3, ... }

GideonNeedleman commented 10 months ago

Wait a second... could I have used React Hook Form useForm() on the DoSet level instead of the DoWorkout level? Would this help me structure the submission data?

Hmm, I don't think so. But maybe I can do

const form = useForm({
    defaultValues: getDefaultValues(workout),
  });
  const { register, control, handleSubmit } = form;

in the GlobalContext, so then I don't need to do props drilling with the register method