Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
feat(patients): success alert on new related person
Browse files Browse the repository at this point in the history
  • Loading branch information
oizuldan committed Mar 3, 2020
1 parent 366a43a commit c2c491d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -26,7 +26,7 @@
"react-redux": "~7.2.0",
"react-router": "~5.1.2",
"react-router-dom": "~5.1.2",
"react-scripts": "~3.3.0",
"react-scripts": "~3.4.0",
"redux": "~4.0.5",
"redux-thunk": "~2.3.0",
"typescript": "~3.8.2"
Expand Down
3 changes: 2 additions & 1 deletion src/locales/en-US/translation.json
Expand Up @@ -9,7 +9,8 @@
"newPatient": "New Patient",
"editPatient": "Edit Patient",
"successfullyCreated": "Successfully created patient",
"successfullyUpdated": "Successfully updated patient"
"successfullyUpdated": "Successfully updated patient",
"successfullyAddedRelatedPerson": "Successfully added the new related person"
},
"patient": {
"suffix": "Suffix",
Expand Down
14 changes: 13 additions & 1 deletion src/patients/patient-slice.ts
Expand Up @@ -71,7 +71,11 @@ export const createPatient = (patient: Patient, history: any): AppThunk => async
)
}

export const updatePatient = (patient: Patient, history: any): AppThunk => async (dispatch) => {
export const updatePatient = (
patient: Patient,
history: any,
relatedPerson?: boolean,
): AppThunk => async (dispatch) => {
dispatch(updatePatientStart())
const updatedPatient = await PatientRepository.saveOrUpdate(patient)
dispatch(updatePatientSuccess(updatedPatient))
Expand All @@ -81,6 +85,14 @@ export const updatePatient = (patient: Patient, history: any): AppThunk => async
il8n.t('Success!'),
`${il8n.t('patients.successfullyUpdated')} ${patient.fullName}`,
)
if (relatedPerson) {
Toast(
'success',
il8n.t('Success!'),
`${il8n.t('patients.successfullyAddedRelatedPerson')}`,
'top-left',
)
}
}

export default patientSlice.reducer
2 changes: 1 addition & 1 deletion src/patients/related-persons/RelatedPersonTab.tsx
Expand Up @@ -80,7 +80,7 @@ const RelatedPersonTab = (props: Props) => {
relatedPersons: newRelatedPersons,
}

dispatch(updatePatient(patientToUpdate, history))
dispatch(updatePatient(patientToUpdate, history, true))
closeNewRelatedPersonModal()
}

Expand Down

0 comments on commit c2c491d

Please sign in to comment.