Skip to content

Commit

Permalink
Changes on Assigning/Reassigning/Unassigning Volunteer to Patient (#9330
Browse files Browse the repository at this point in the history
)
  • Loading branch information
rajku-dev authored Dec 11, 2024
1 parent 981a281 commit 05d89f4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
7 changes: 5 additions & 2 deletions public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
25 changes: 21 additions & 4 deletions src/components/Patient/PatientHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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"];
};

Expand Down Expand Up @@ -530,7 +541,9 @@ export const PatientHome = (props: {
>
<span className="flex w-full items-center justify-start gap-2">
<CareIcon icon="l-users-alt" className="text-lg" />{" "}
{t("assign_to_volunteer")}
{patientData.assigned_to
? t("update_volunteer")
: t("assign_to_volunteer")}
</span>
</ButtonV2>
</div>
Expand Down Expand Up @@ -713,7 +726,11 @@ export const PatientHome = (props: {
/>
</div>
}
action={t("assign")}
action={
assignedVolunteer || !patientData.assigned_to
? t("assign")
: t("unassign")
}
onConfirm={handleAssignedVolunteer}
/>
</Page>
Expand Down

0 comments on commit 05d89f4

Please sign in to comment.