Skip to content

Save schedules to the routine draft - #85

Merged
rd-code-23 merged 2 commits into
feature/routine-schedule-shared-timefrom
feature/save-routine-schedules
Aug 30, 2026
Merged

rd-code-23 merged 2 commits into
feature/routine-schedule-shared-timefrom
feature/save-routine-schedules

Conversation

@rd-code-23

Copy link
Copy Markdown
Owner

Summary

Connects the schedule modal to the shared React Hook Form routine draft so confirmed schedules survive navigation and can later be submitted with the complete routine.

Behavior

  • adds schedules to RoutineDraftFormValues
  • reuses createRoutineScheduleInputSchema from the shared contracts package
  • enables Save Schedule when at least one day is selected
  • saves selected days and times into RHF
  • converts browser HH:mm values to the API contract HH:mm:ss format
  • renders confirmed schedule cards in the routine editor
  • reloads confirmed values whenever the modal opens
  • discards modal-only edits when Cancel is selected
  • clears schedules along with the rest of the draft when Clear is selected

State ownership

The reducer remains a temporary editing buffer for the open modal. RHF owns only schedules that the user has confirmed with Save Schedule. This separation means Cancel can discard edits without corrupting the saved routine draft.

React Hook Form details

useWatch subscribes to the schedules field through RHF control, which is RHF reference to this specific form instance. When setValue replaces schedules, watched components rerender with the confirmed values. shouldDirty marks the routine as changed and shouldValidate runs the shared Zod resolver immediately.

Tests

  • saves selected schedules and displays formatted cards
  • restores saved schedules when reopening the modal
  • discards unsaved changes on Cancel
  • verifies Clear resets schedules and validation state
  • all 46 web tests pass

Dependency

This PR is stacked on PR #84, which adds the schedule reducer and shared-time behavior. Once #84 merges, this PR can be rebased or retargeted to main.

@rd-code-23
rd-code-23 merged commit 6f49f1e into feature/routine-schedule-shared-time Aug 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant