Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facility staff management bug fixes #8952

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,7 @@
"to_be_conducted": "To be conducted",
"total_amount": "Total Amount",
"total_beds": "Total Beds",
"total_staff": "Total Staff",
"total_users": "Total Users",
"transfer_in_progress": "TRANSFER IN PROGRESS",
"transfer_to_receiving_facility": "Transfer to receiving facility",
Expand Down
2 changes: 1 addition & 1 deletion src/common/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export const DOCTOR_SPECIALIZATION: Array<OptionsType> = [
{ id: 16, text: "General Surgeon" },
{ id: 17, text: "Geriatrician" },
{ id: 18, text: "Hematologist" },
{ id: 29, text: "Immunologist" },
{ id: 19, text: "Immunologist" },
{ id: 20, text: "Infectious Disease Specialist" },
{ id: 21, text: "MBBS doctor" },
{ id: 22, text: "Medical Officer" },
Expand Down
36 changes: 20 additions & 16 deletions src/components/Facility/FacilityStaffList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,21 @@ import DoctorsCountCard from "./StaffCountCard";
import { DoctorIcon } from "../TeleIcu/Icons/DoctorIcon";
import CareIcon from "../../CAREUI/icons/CareIcon";
import { useTranslation } from "react-i18next";
import useFilters from "@/common/hooks/useFilters";
import Pagination from "../Common/Pagination";

export const FacilityStaffList = (props: any) => {
const { t } = useTranslation();
const [doctorCapacityModalOpen, setDoctorCapacityModalOpen] = useState(false);
const { qParams, resultsPerPage, updatePage } = useFilters({ limit: 15 });
const [totalDoctors, setTotalDoctors] = useState(0);

const doctorQuery = useQuery(routes.listDoctor, {
const { data: doctorsList, refetch } = useQuery(routes.listDoctor, {
pathParams: { facilityId: props.facilityId },
query: {
limit: resultsPerPage,
offset: (qParams.page - 1) * resultsPerPage,
},
onResponse: ({ res, data }) => {
if (res?.ok && data) {
let totalCount = 0;
Expand All @@ -33,7 +40,7 @@ export const FacilityStaffList = (props: any) => {
});

let doctorList: any = null;
if (!doctorQuery.data || !doctorQuery.data.results.length) {
if (!doctorsList || !doctorsList.results.length) {
doctorList = (
<h5 className="flex w-full items-center justify-center rounded-lg bg-white p-4 text-xl font-bold text-secondary-500 shadow">
{t("no_staff")}
Expand All @@ -50,33 +57,24 @@ export const FacilityStaffList = (props: any) => {
</div>
<div id="facility-doctor-totalcapacity">
<div className="text-sm font-medium text-[#808080]">
Total Staff
{t("total_staff")}
</div>
<h2 className="mt-2 text-xl font-bold">{totalDoctors}</h2>
</div>
</div>
</div>
</div>

{doctorQuery.data.results.map((data: DoctorModal) => {
const removeCurrentDoctorData = (doctorId: number | undefined) => {
if (doctorQuery.data !== undefined) {
doctorQuery.data?.results.filter(
(i: DoctorModal) => i.id !== doctorId,
);
doctorQuery.refetch();
}
};

{doctorsList.results.map((data: DoctorModal) => {
return (
<DoctorsCountCard
facilityId={props.facilityId}
key={`bed_${data.id}`}
handleUpdate={async () => {
doctorQuery.refetch();
refetch();
}}
{...data}
removeDoctor={removeCurrentDoctorData}
removeDoctor={() => refetch()}
/>
);
})}
Expand Down Expand Up @@ -116,11 +114,17 @@ export const FacilityStaffList = (props: any) => {
facilityId={props.facilityId}
handleClose={() => setDoctorCapacityModalOpen(false)}
handleUpdate={async () => {
doctorQuery.refetch();
refetch();
}}
/>
</DialogModal>
)}
<Pagination
cPage={qParams.page}
defaultPerPage={resultsPerPage}
data={{ totalCount: doctorsList?.count ?? 0 }}
onChange={(page) => updatePage(page)}
/>
</section>
);
};
3 changes: 3 additions & 0 deletions src/components/Facility/StaffCapacity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ export const StaffCapacity = (props: DoctorCapacityProps) => {

const specializationsQuery = useQuery(routes.listDoctor, {
pathParams: { facilityId },
query: {
limit: DOCTOR_SPECIALIZATION.length - 1,
},
});

const { loading } = useQuery(routes.getDoctor, {
Expand Down
Loading