@@ -70,6 +70,7 @@ const UpdateNursingTasks = (props) => {
7070 const [ showWarningNotification , setShowWarningNotification ] = useState ( false ) ;
7171 const [ isInvalidTime , setIsInvalidTime ] = useState ( false ) ;
7272 const [ invalidText , setInvalidText ] = useState ( ) ;
73+ const [ isSavingConfirmation , setIsSavingConfirmation ] = useState ( false ) ;
7374 const intl = useIntl ( ) ;
7475
7576 const invalidTimeText = (
@@ -113,13 +114,16 @@ const UpdateNursingTasks = (props) => {
113114 } ;
114115
115116 const handlePrimaryButtonClick = async ( ) => {
117+ setIsSavingConfirmation ( true ) ;
116118 const administeredTasks = createAdministeredTasksPayload ( ) ;
117119 const response = isPRNMedication
118120 ? await saveEmergencyMedication ( administeredTasks [ 0 ] )
119121 : await saveAdministeredMedication ( administeredTasks ) ;
120- response . status === 200
121- ? saveAdministeredTasks ( administeredTasks [ 0 ] )
122- : null ;
122+ if ( response . status === 200 ) {
123+ saveAdministeredTasks ( administeredTasks [ 0 ] ) ;
124+ } else {
125+ setIsSavingConfirmation ( false ) ;
126+ }
123127 } ;
124128
125129 const createAdministeredTasksPayload = ( ) => {
@@ -734,6 +738,7 @@ const UpdateNursingTasks = (props) => {
734738 />
735739 }
736740 onRequestSubmit = { handlePrimaryButtonClick }
741+ primaryButtonDisabled = { isSavingConfirmation }
737742 >
738743 < hr />
739744 < AdministeredMedicationList
@@ -780,4 +785,4 @@ UpdateNursingTasks.propTypes = {
780785 setShowSuccessNotification : PropTypes . func . isRequired ,
781786 setSuccessMessage : PropTypes . func . isRequired ,
782787} ;
783- export default UpdateNursingTasks ;
788+ export default UpdateNursingTasks ;
0 commit comments