Skip to main content

usePenaltySync

Source: hooks/commits/usePenaltySync.ts The usePenaltySync hook synchronizes the penalty configuration between the (penalties) route group sub-screens and the useTaskDraftStore.

Sync Direction

The hook operates as a bidirectional bridge: Read direction: When the penalty sub-screen mounts, it reads the current penalty config from useTaskDraftStore to pre-populate the form fields. Write direction: As the user configures penalty settings (photo, email recipient, amount), each change is immediately written back to the draft store’s penalty field.

Penalty Object Structure


Cleanup Behavior

If the user navigates back from the penalty screen without selecting a penalty type, the hook clears the penalty field on the draft store to prevent stale configurations from persisting.