Skip to content

fix : add isSaving loading state to routine save to prevent double-submit #1895

Description

@tmdeveloper007

Summary of What Needs to be Done

The confirmSaveRoutine function in RoutineBuilder.jsx does not use a loading state. When a user clicks "Save" rapidly, it can trigger multiple API requests, potentially creating duplicate routines.

Changes that Need to be Made

  1. In frontend/src/pages/RoutineBuilder.jsx:
    • Add a new state: const [isSaving, setIsSaving] = useState(false)
    • In confirmSaveRoutine, set setIsSaving(true) at the start and setIsSaving(false) in both the try block and the finally block
    • In the save modal's confirm button, add disabled={isSaving} and render a spinner when isSaving is true
    • Replace the alert() call on success with a toast notification (use the existing toast mechanism)

Impact that it would Provide

Prevents duplicate routine submissions caused by double-clicks or rapid button presses. Also provides better user feedback during the save operation.

Note: Please assign this issue to the tmdeveloper007 account.

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendIssues related to server-side, database logic or APIsfrontendIssues related to UI/UX

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions