diff --git a/public/locale/en.json b/public/locale/en.json index a37d6b4b115..4fb925ac941 100644 --- a/public/locale/en.json +++ b/public/locale/en.json @@ -354,6 +354,7 @@ "asset_type": "Asset Type", "assets": "Assets", "assign": "Assign", + "unassign":"Unassign", "assign_a_volunteer_to": "Assign a volunteer to {{name}}", "assign_bed": "Assign Bed", "assign_to_volunteer": "Assign to a Volunteer", @@ -1483,6 +1484,7 @@ "update_record_for_asset": "Update record for asset", "update_shift_request": "Update Shift Request", "update_status_details": "Update Status/Details", + "update_volunteer": "Reassign Volunteer", "updated": "Updated", "updated_on": "Updated On", "updating": "Updating", @@ -1553,9 +1555,10 @@ "vitals_monitor": "Vitals Monitor", "vitals_present": "Vitals Monitor present", "voice_autofill": "Voice Autofill", - "volunteer_assigned": "Volunteer assigned successfuly", + "volunteer_assigned": "Volunteer assigned successfully", "volunteer_contact": "Volunteer Contact", - "volunteer_unassigned": "Volunteer unassigned successfuly", + "volunteer_update" : "Volunteer updated successfully", + "volunteer_unassigned": "Volunteer unassigned successfully", "ward": "Ward", "warranty_amc_expiry": "Warranty / AMC Expiry", "weekly_working_hours_error": "Average weekly working hours must be a number between 0 and 168", diff --git a/src/components/Patient/PatientHome.tsx b/src/components/Patient/PatientHome.tsx index 8feea3c6d35..b69ae75751e 100644 --- a/src/components/Patient/PatientHome.tsx +++ b/src/components/Patient/PatientHome.tsx @@ -91,6 +91,8 @@ export const PatientHome = (props: { }); const handleAssignedVolunteer = async () => { + const previousVolunteerId = patientData?.assigned_to; + const { res, data } = await request(routes.patchPatient, { pathParams: { id: patientData.id as string, @@ -99,20 +101,29 @@ export const PatientHome = (props: { assigned_to: (assignedVolunteer as UserBareMinimum)?.id || null, }, }); + if (res?.ok && data) { setPatientData(data); - if (!assignedVolunteer) { + + if (!previousVolunteerId && assignedVolunteer) { Notification.Success({ msg: t("volunteer_assigned"), }); - } else { + } else if (previousVolunteerId && assignedVolunteer) { + Notification.Success({ + msg: t("volunteer_update"), + }); + } else if (!assignedVolunteer) { Notification.Success({ msg: t("volunteer_unassigned"), }); } + refetch(); } + setOpenAssignVolunteerDialog(false); + if (errors["assignedVolunteer"]) delete errors["assignedVolunteer"]; }; @@ -530,7 +541,9 @@ export const PatientHome = (props: { > {" "} - {t("assign_to_volunteer")} + {patientData.assigned_to + ? t("update_volunteer") + : t("assign_to_volunteer")} @@ -713,7 +726,11 @@ export const PatientHome = (props: { /> } - action={t("assign")} + action={ + assignedVolunteer || !patientData.assigned_to + ? t("assign") + : t("unassign") + } onConfirm={handleAssignedVolunteer} />