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
- 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.
Summary of What Needs to be Done
The
confirmSaveRoutinefunction inRoutineBuilder.jsxdoes 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
frontend/src/pages/RoutineBuilder.jsx:const [isSaving, setIsSaving] = useState(false)confirmSaveRoutine, setsetIsSaving(true)at the start andsetIsSaving(false)in both thetryblock and thefinallyblockdisabled={isSaving}and render a spinner whenisSavingis truealert()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
tmdeveloper007account.