From 207137ecf17cfa09f8cee6526b49b2ae889879ca Mon Sep 17 00:00:00 2001 From: SilverD3 Date: Thu, 3 Oct 2024 11:29:32 +0100 Subject: [PATCH] fix:eslint warings - unused imports, exhaustive deps, ... --- src/components/Private.js | 3 +- .../accessories/admin/diseases/Diseases.tsx | 13 ++--- .../suppliers/editSupplier/EditSupplier.tsx | 2 +- .../suppliers/supplierForm/SupplierForm.tsx | 2 - .../accessories/admin/types/TypesAdmin.tsx | 10 ++-- .../admission/PatientAdmission.tsx | 6 +-- .../accessories/appHeader/AppHeader.tsx | 2 +- src/components/accessories/appHeader/types.ts | 1 - .../autocompleteField/AutocompleteField.tsx | 12 +---- .../accessories/billTable/BillTable.tsx | 2 +- .../accessories/billrecords/BillRecords.tsx | 4 +- .../accessories/billsRecap/BillsRecap.tsx | 18 +++---- .../CurrentAdmissionForm.tsx | 14 +++--- .../currentAdmissionForm/consts.ts | 2 +- .../dashboard/admissions/useData.ts | 11 +---- .../dashboard/card/DashboardCard.tsx | 8 +++- .../filter/DashboardFilter.tsx | 7 ++- .../filter/usePeriodOptions.ts | 8 ++-- .../dashboard/discharges/useData.ts | 11 +---- .../layouts/container/GridLayoutContainer.tsx | 2 +- .../accessories/dashboard/opds/useData.ts | 5 +- .../dateRangeField/DateRangeField.tsx | 4 -- .../accessories/dateRangeField/types.ts | 5 +- .../discharge/PatientDischarge.tsx | 2 +- .../discharge/dischargeForm/DischargeForm.tsx | 3 +- .../accessories/feedback/OHFeedback.tsx | 2 +- .../accessories/hospitalInfo/HospitalInfo.tsx | 2 +- .../accessories/laboratory/Exams.tsx | 22 ++++++--- .../laboratory/examForm/ExamForm.tsx | 22 ++------- .../examRequestForm/ExamRequestForm.tsx | 11 ++--- .../laboratory/filter/ExamFilterForm.tsx | 4 +- .../accessories/laboratory/filter/types.ts | 1 - src/components/accessories/opds/Opds.tsx | 4 +- .../accessories/opds/filter/OpdFilterForm.tsx | 32 ++++++------- .../accessories/opds/filter/styles.scss | 5 +- src/components/accessories/opds/types.ts | 1 - .../PatientAutocomplete.tsx | 2 +- .../patientBooking/PatientBooking.tsx | 2 +- .../patientExams/ExamForm/ExamForm.tsx | 26 ++-------- .../accessories/patientExams/PatientExams.tsx | 13 ++--- .../examRowTable/ExamRowTable.tsx | 2 + .../PatientExamRequestsTable.tsx | 9 +--- .../patientExamsTable/PatientExamsTable.tsx | 18 ------- .../accessories/patientExams/types.ts | 2 +- .../patientExtraData/patientExtraData.tsx | 1 + .../patientNewBill/PatientNewBill.tsx | 29 +++++------ .../patientNewBill/hooks/full_bill.hooks.ts | 42 ++++++++-------- .../patientNewBill/hooks/item.hooks.ts | 6 +-- .../hooks/pending_bill.hooks.ts | 3 +- .../patientNewBill/hooks/price.hooks.ts | 15 +++--- .../itemPicker/BillItemPicker.tsx | 37 +++++++------- .../patientNewBill/itemPicker/hooks.ts | 28 +++++------ .../patientOPDForm/PatientOPDForm.tsx | 9 ++-- .../patientOperation/PatientOperation.tsx | 1 + .../accessories/patientOperation/consts.ts | 1 - .../operationForm/OperationRowForm.tsx | 5 +- .../patientPicker/PatientPicker.tsx | 2 +- .../PatientTherapyTable.tsx | 4 -- .../therapyForm/TherapyForm.tsx | 4 +- .../patientTherapy/therapyForm/types.ts | 2 +- .../patientTriage/PatientTriage.tsx | 6 +-- .../patientTriageForm/PatientTriageForm.tsx | 2 +- .../patientTriageTable/PatientTriageTable.tsx | 4 -- .../accessories/patientVisit/patientVisit.tsx | 8 +--- .../paymentsTable/PaymentsTable.tsx | 2 +- .../profilePicture/ProfilePicture.tsx | 8 ++-- .../accessories/profilePicture/utils.ts | 3 +- src/components/accessories/table/Table.tsx | 1 + .../accessories/table/filter/FilterButton.tsx | 1 + .../accessories/tabs/RouterTabs.tsx | 2 +- .../tabs/hooks/useFilterPermission.ts | 2 +- .../EditPatientActivity.tsx | 11 ++--- .../laboratoryActivity/LaboratoryActivity.tsx | 2 +- .../newPatientActivity/NewPatientActivity.tsx | 4 +- .../activities/newPatientActivity/types.ts | 1 - .../InPatientDashboardMenu.tsx | 3 +- .../OutPatientDashboardMenu.tsx | 5 +- .../PatientSearchItem.tsx | 2 +- .../activities/searchPatientActivity/types.ts | 2 +- .../authUtils/getAuthenticationFromSession.ts | 2 +- .../admissions/useAdmByAdmTypeData.ts | 5 +- .../admissions/useAdmByWardData.ts | 5 +- .../discharges/useDisByAgeTypeData.ts | 5 +- .../discharges/useDisByDisTypeData.ts | 5 +- .../discharges/useDisBySexData.ts | 5 +- .../discharges/useDisByWardData.ts | 5 +- src/libraries/formDataHandling/functions.ts | 14 +++--- src/libraries/hooks/api/useAdmissions.ts | 2 +- src/libraries/hooks/api/useDischarges.ts | 2 +- src/mockServer/fixtures/examRequestDTO.js | 48 +++++++++++++++++++ src/mockServer/routes/labExamRequest.js | 19 ++++++++ src/mockServer/server.js | 46 +++++++++--------- src/routes/MainRouter.tsx | 2 +- src/styles/index.scss | 2 +- 94 files changed, 343 insertions(+), 419 deletions(-) create mode 100644 src/mockServer/fixtures/examRequestDTO.js create mode 100644 src/mockServer/routes/labExamRequest.js diff --git a/src/components/Private.js b/src/components/Private.js index db8471287..49aa091bb 100644 --- a/src/components/Private.js +++ b/src/components/Private.js @@ -1,12 +1,11 @@ import React from "react"; -import { Navigate, Outlet, useLocation } from "react-router-dom"; +import { Navigate, Outlet } from "react-router-dom"; import { PATHS } from "../consts"; import { isAuthenticated } from "../libraries/authUtils/isAuthenticated"; import { useAuthentication } from "../libraries/authUtils/useAuthentication"; export const Private = () => { useAuthentication(); - const { pathname } = useLocation(); return isAuthenticated() ? : ; }; diff --git a/src/components/accessories/admin/diseases/Diseases.tsx b/src/components/accessories/admin/diseases/Diseases.tsx index b4343deba..f50fff46e 100644 --- a/src/components/accessories/admin/diseases/Diseases.tsx +++ b/src/components/accessories/admin/diseases/Diseases.tsx @@ -37,14 +37,11 @@ export const Diseases = () => { }); }; - const handleViewChange = useCallback( - (event: any, value: any) => { - if (!isEmpty(value)) { - setView(value); - } - }, - [view] - ); + const handleViewChange = useCallback((event: any, value: any) => { + if (!isEmpty(value)) { + setView(value); + } + }, []); const predicate = useCallback( (disease: DiseaseDTO) => { diff --git a/src/components/accessories/admin/suppliers/editSupplier/EditSupplier.tsx b/src/components/accessories/admin/suppliers/editSupplier/EditSupplier.tsx index 4f40afb3e..40f67bf29 100644 --- a/src/components/accessories/admin/suppliers/editSupplier/EditSupplier.tsx +++ b/src/components/accessories/admin/suppliers/editSupplier/EditSupplier.tsx @@ -24,7 +24,7 @@ export const EditSupplier = () => { if (state?.supId !== Number(id)) { navigate(PATHS.admin_suppliers); } - }, [id, state]); + }, [id, navigate, state]); return ( = ({ fields, onSubmit, diff --git a/src/components/accessories/admin/types/TypesAdmin.tsx b/src/components/accessories/admin/types/TypesAdmin.tsx index 1b439a9cf..fc1c40d32 100644 --- a/src/components/accessories/admin/types/TypesAdmin.tsx +++ b/src/components/accessories/admin/types/TypesAdmin.tsx @@ -1,6 +1,6 @@ import { useAppSelector } from "libraries/hooks/redux"; import { sortBy } from "lodash"; -import React, { useEffect, useState } from "react"; +import React, { useEffect, useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; import { Outlet, useLocation, useNavigate } from "react-router"; import { PATHS } from "../../../../consts"; @@ -16,7 +16,11 @@ const TypesAdmin = () => { const { t } = useTranslation(); const location = useLocation(); const navigate = useNavigate(); - const defaultTypeOption: TypeOption = { label: "", value: "" }; + const defaultTypeOption: TypeOption = useMemo( + () => ({ label: "", value: "" }), + [] + ); + const [selectedOption, setSelectedOption] = useState(defaultTypeOption); const mode = useAppSelector((state) => state.types.config.mode); @@ -57,7 +61,7 @@ const TypesAdmin = () => { setSelectedOption(defaultTypeOption); } } - }, [location]); + }, [defaultTypeOption, location, typeOptions]); const handleTypeChange = (value: string) => { if (value?.length > 0) { diff --git a/src/components/accessories/admission/PatientAdmission.tsx b/src/components/accessories/admission/PatientAdmission.tsx index 3c36cedc0..63d193c86 100644 --- a/src/components/accessories/admission/PatientAdmission.tsx +++ b/src/components/accessories/admission/PatientAdmission.tsx @@ -83,7 +83,7 @@ const PatientAdmission: FC = () => { if (patientCode && creationMode) { dispatch(getLastOpd(parseInt(id!!))); } - }, [dispatch, patientCode, creationMode]); + }, [dispatch, patientCode, creationMode, id]); const fields = useFields(admissionToEdit, lastOpd?.disease); @@ -157,7 +157,7 @@ const PatientAdmission: FC = () => { dispatch(getPatient(id!!)); dispatch(getCurrentAdmission(parseInt(id!!))); } - }, [createStatus, updateStatus]); + }, [createStatus, dispatch, id, updateStatus]); const resetFormCallback = () => { setCreationMode(true); @@ -173,7 +173,7 @@ const PatientAdmission: FC = () => { return () => { dispatch(getCurrentAdmissionReset()); }; - }, [dispatch]); + }, [dispatch, id]); const onEdit = (row: AdmissionDTO) => { setAdmissionToEdit(row); diff --git a/src/components/accessories/appHeader/AppHeader.tsx b/src/components/accessories/appHeader/AppHeader.tsx index 4b3472d52..b253dec66 100644 --- a/src/components/accessories/appHeader/AppHeader.tsx +++ b/src/components/accessories/appHeader/AppHeader.tsx @@ -35,7 +35,7 @@ const AppHeader: FunctionComponent = ({ breadcrumbMap }) => { ); useEffect(() => { dispatch(getHospital()); - }, [dispatch, getHospital]); + }, [dispatch]); const hospital = useAppSelector( (state) => state.hospital.getHospital.data diff --git a/src/components/accessories/appHeader/types.ts b/src/components/accessories/appHeader/types.ts index 055367823..3e69449eb 100644 --- a/src/components/accessories/appHeader/types.ts +++ b/src/components/accessories/appHeader/types.ts @@ -1,5 +1,4 @@ import { TUserCredentials } from "../../../state/main/types"; -import { TAPIResponseStatus } from "../../../state/types"; export type TBreadcrumbMap = Record; diff --git a/src/components/accessories/autocompleteField/AutocompleteField.tsx b/src/components/accessories/autocompleteField/AutocompleteField.tsx index 10c34b728..95459a7da 100644 --- a/src/components/accessories/autocompleteField/AutocompleteField.tsx +++ b/src/components/accessories/autocompleteField/AutocompleteField.tsx @@ -11,7 +11,6 @@ import _ from "lodash"; import React, { ChangeEvent, FC, - Fragment, useCallback, useEffect, useState, @@ -76,6 +75,7 @@ const AutocompleteField: FC = ({ } }; + // eslint-disable-next-line react-hooks/exhaustive-deps const debounceUpdate = useCallback( debounce((value: any) => { setValue(value); @@ -111,16 +111,6 @@ const AutocompleteField: FC = ({ return option.label; }; - const isSelected = (option: DefaultOptionType, v: DefaultOptionType) => { - return option.value === v.value; - }; - - const rendOption = (props: any, option: DefaultOptionType | string) => { - return ( - {typeof option === "string" ? option : option.label} - ); - }; - const filter = createFilterOptions({ limit: options_limit, }); diff --git a/src/components/accessories/billTable/BillTable.tsx b/src/components/accessories/billTable/BillTable.tsx index cf9f52aa9..30b37c00f 100644 --- a/src/components/accessories/billTable/BillTable.tsx +++ b/src/components/accessories/billTable/BillTable.tsx @@ -91,7 +91,7 @@ export const BillTable: FC = ({ fields }) => { dispatch(searchBills(filter)); break; } - }, [filter]); + }, [dispatch, filter]); const { setFieldValue, handleBlur } = formik; diff --git a/src/components/accessories/billrecords/BillRecords.tsx b/src/components/accessories/billrecords/BillRecords.tsx index 35ccee08f..52804c3b6 100644 --- a/src/components/accessories/billrecords/BillRecords.tsx +++ b/src/components/accessories/billrecords/BillRecords.tsx @@ -67,7 +67,7 @@ const BillRecords = () => { dispatch(deleteBillReset()); dispatch(payBillReset()); dispatch(closeBillReset()); - }, []); + }, [dispatch]); useEffect(() => { if (patient && patient.code) { @@ -275,7 +275,7 @@ const BillRecords = () => { }} handleSecondaryButtonClick={() => ({})} /> - + ); }; diff --git a/src/components/accessories/billsRecap/BillsRecap.tsx b/src/components/accessories/billsRecap/BillsRecap.tsx index 34db36a43..955b50e2a 100644 --- a/src/components/accessories/billsRecap/BillsRecap.tsx +++ b/src/components/accessories/billsRecap/BillsRecap.tsx @@ -12,14 +12,7 @@ import { } from "chart.js"; import { useAppDispatch, useAppSelector } from "libraries/hooks/redux"; import moment from "moment"; -import React, { - FC, - useCallback, - useEffect, - useMemo, - useRef, - useState, -} from "react"; +import React, { FC, useCallback, useEffect, useMemo, useState } from "react"; import { Bar, Doughnut, Line, Pie } from "react-chartjs-2"; import { useTranslation } from "react-i18next"; import { getBillsByYear, searchBills } from "../../../state/bills"; @@ -98,6 +91,7 @@ export const BillsRecap: FC = () => { useEffect(() => { dispatch(searchBills(filter as TFilterValues)); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [dispatch]); useEffect(() => { @@ -188,7 +182,7 @@ export const BillsRecap: FC = () => { ], }; }, - [summaryCurrentYear] + [summaryCurrentYear, t] ); const paymentsVariationsData = useMemo(() => { @@ -206,7 +200,7 @@ export const BillsRecap: FC = () => { { label: t("bill.payments"), data: - labels.length != 0 + labels.length !== 0 ? labels.map( (item) => summaryCurrentYear.paymentsByMonthsOfYear[item] ?? 0 ) @@ -217,7 +211,7 @@ export const BillsRecap: FC = () => { { label: t("bill.debts"), data: - labels.length != 0 + labels.length !== 0 ? labels.map( (item) => summaryCurrentYear.debtsByMonthsOfYear[item] ?? 0 ) @@ -227,6 +221,7 @@ export const BillsRecap: FC = () => { }, ], }; + // eslint-disable-next-line react-hooks/exhaustive-deps }, [summaryCurrentYear]); const getOptionsFromYears = (years: number[]) => { @@ -237,7 +232,6 @@ export const BillsRecap: FC = () => { }; }); }; - const infoBoxRef = useRef(null); return (
diff --git a/src/components/accessories/currentAdmission/currentAdmissionForm/CurrentAdmissionForm.tsx b/src/components/accessories/currentAdmission/currentAdmissionForm/CurrentAdmissionForm.tsx index f5eb3f185..a1570fefe 100644 --- a/src/components/accessories/currentAdmission/currentAdmissionForm/CurrentAdmissionForm.tsx +++ b/src/components/accessories/currentAdmission/currentAdmissionForm/CurrentAdmissionForm.tsx @@ -13,17 +13,15 @@ import { AdmissionTypeDTO, DiseaseDTO, DiseaseTypeDTO, - WardDTO + WardDTO, } from "../../../../generated"; import { differenceInDays, formatAllFieldValues, - getFromFields + getFromFields, } from "../../../../libraries/formDataHandling/functions"; import { updateAdmissionReset } from "../../../../state/admissions"; -import { - getPatient -} from "../../../../state/patients"; +import { getPatient } from "../../../../state/patients"; import { IState } from "../../../../types"; import AutocompleteField from "../../autocompleteField/AutocompleteField"; import Button from "../../button/Button"; @@ -130,9 +128,9 @@ export const CurrentAdmissionForm: FunctionComponent = ({ } onDiscard(); } - }, [dispatch, activityTransitionState]); + }, [dispatch, activityTransitionState, patient, onDiscard]); - const { setFieldValue, resetForm, handleBlur } = formik; + const { setFieldValue, handleBlur } = formik; const isValid = (fieldName: string): boolean => { return has(formik.touched, fieldName) && has(formik.errors, fieldName); @@ -154,7 +152,7 @@ export const CurrentAdmissionForm: FunctionComponent = ({ ).toString(); setFieldValue("bedDays", days); }, - [setFieldValue] + [formik, setFieldValue] ); const onBlurCallback = useCallback( diff --git a/src/components/accessories/currentAdmission/currentAdmissionForm/consts.ts b/src/components/accessories/currentAdmission/currentAdmissionForm/consts.ts index 4763bff7f..61ac129d2 100644 --- a/src/components/accessories/currentAdmission/currentAdmissionForm/consts.ts +++ b/src/components/accessories/currentAdmission/currentAdmissionForm/consts.ts @@ -1,4 +1,4 @@ -import { AdmissionDTO, PatientDTO } from "../../../../generated"; +import { AdmissionDTO } from "../../../../generated"; import { parseDate } from "../../../../libraries/formDataHandling/functions"; import { TFields } from "../../../../libraries/formDataHandling/types"; import { TCurrentAdmissionFieldName } from "./types"; diff --git a/src/components/accessories/dashboard/admissions/useData.ts b/src/components/accessories/dashboard/admissions/useData.ts index 792781e45..d51204d29 100644 --- a/src/components/accessories/dashboard/admissions/useData.ts +++ b/src/components/accessories/dashboard/admissions/useData.ts @@ -1,15 +1,6 @@ -import { useMemo, useState } from "react"; -import { useTranslation } from "react-i18next"; import { useAppSelector } from "libraries/hooks/redux"; -import { - AdmissionDTO, - WardDTO, - AdmissionTypeDTO, - AgeTypeDTO, -} from "../../../../generated"; +import { useTranslation } from "react-i18next"; import { colorGen } from "../../../../libraries/uiUtils/colorGenerator"; -import { TAPIResponseStatus } from "../../../../state/types"; -import { IState } from "../../../../types"; export const useData = () => { const { t } = useTranslation(); diff --git a/src/components/accessories/dashboard/card/DashboardCard.tsx b/src/components/accessories/dashboard/card/DashboardCard.tsx index 9f494f3df..0f0d253a7 100644 --- a/src/components/accessories/dashboard/card/DashboardCard.tsx +++ b/src/components/accessories/dashboard/card/DashboardCard.tsx @@ -38,16 +38,20 @@ export const DashboardCard: React.FC = ({ if (sizeChangeHandler && cardBodyRef.current) { resizeObserver.observe(cardBodyRef.current); } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [cardBodyRef]); // Remove the observer on component unmount useEffect(() => { + const currentRef = cardBodyRef.current; + return () => { - if (sizeChangeHandler && cardBodyRef.current) { - resizeObserver.unobserve(cardBodyRef.current); + if (sizeChangeHandler && currentRef) { + resizeObserver.unobserve(currentRef); resizeObserver.disconnect(); } }; + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); const getTitle = () => { diff --git a/src/components/accessories/dashboard/dashboardContent/filter/DashboardFilter.tsx b/src/components/accessories/dashboard/dashboardContent/filter/DashboardFilter.tsx index e115b0ed6..d96a929ae 100644 --- a/src/components/accessories/dashboard/dashboardContent/filter/DashboardFilter.tsx +++ b/src/components/accessories/dashboard/dashboardContent/filter/DashboardFilter.tsx @@ -27,6 +27,7 @@ export const DashboardFilter: FC = ({ onPeriodChange }) => { useEffect(() => { onPeriodChange([range[0], range[1]]); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [range]); const handleViewChange = useCallback( @@ -36,6 +37,7 @@ export const DashboardFilter: FC = ({ onPeriodChange }) => { setSelection("current"); } }, + // eslint-disable-next-line react-hooks/exhaustive-deps [view] ); @@ -45,7 +47,7 @@ export const DashboardFilter: FC = ({ onPeriodChange }) => { setSelection(value as TPeriodType); } }, - [selection] + [setSelection] ); const onIconClickHandler = useCallback( @@ -66,6 +68,7 @@ export const DashboardFilter: FC = ({ onPeriodChange }) => { setSelection("custom"); setOpen(false); }, + // eslint-disable-next-line react-hooks/exhaustive-deps [dateRange] ); @@ -78,7 +81,7 @@ export const DashboardFilter: FC = ({ onPeriodChange }) => { setSelection("custom"); setOpen(false); }, - [dateRange] + [setDateRange, setSelection, setView] ); return ( diff --git a/src/components/accessories/dashboard/dashboardContent/filter/usePeriodOptions.ts b/src/components/accessories/dashboard/dashboardContent/filter/usePeriodOptions.ts index 7551d4fd2..cd3213cc9 100644 --- a/src/components/accessories/dashboard/dashboardContent/filter/usePeriodOptions.ts +++ b/src/components/accessories/dashboard/dashboardContent/filter/usePeriodOptions.ts @@ -1,8 +1,8 @@ +import { DateRange } from "@mui/lab/DateRangePicker"; import moment from "moment"; -import { useState, useMemo } from "react"; -import { TViewType, TPeriodType } from "./types"; +import { useMemo, useState } from "react"; import { getCachedPeriod } from "./consts"; -import { DateRange } from "@mui/lab/DateRangePicker"; +import { TPeriodType, TViewType } from "./types"; export const usePeriodOptions = () => { const cachedPeriod = getCachedPeriod(); @@ -64,7 +64,7 @@ export const usePeriodOptions = () => { return `${moment(range[0]).format("yyyy-MM-DD")} - ${moment( range[1] ).format("yyyy-MM-DD")}`; - }, [dateRange, view, selection]); + }, [range]); return { view, diff --git a/src/components/accessories/dashboard/discharges/useData.ts b/src/components/accessories/dashboard/discharges/useData.ts index 1f14144cf..d00b32448 100644 --- a/src/components/accessories/dashboard/discharges/useData.ts +++ b/src/components/accessories/dashboard/discharges/useData.ts @@ -1,15 +1,6 @@ -import { useMemo, useState } from "react"; -import { useTranslation } from "react-i18next"; import { useAppSelector } from "libraries/hooks/redux"; -import { - AdmissionDTO, - WardDTO, - AdmissionTypeDTO, - AgeTypeDTO, -} from "../../../../generated"; +import { useTranslation } from "react-i18next"; import { colorGen } from "../../../../libraries/uiUtils/colorGenerator"; -import { TAPIResponseStatus } from "../../../../state/types"; -import { IState } from "../../../../types"; export const useData = () => { const { t } = useTranslation(); diff --git a/src/components/accessories/dashboard/layouts/container/GridLayoutContainer.tsx b/src/components/accessories/dashboard/layouts/container/GridLayoutContainer.tsx index 30a73664d..e6a93685a 100644 --- a/src/components/accessories/dashboard/layouts/container/GridLayoutContainer.tsx +++ b/src/components/accessories/dashboard/layouts/container/GridLayoutContainer.tsx @@ -71,7 +71,7 @@ const GridLayoutContainer: FC = () => { useEffect(() => { dispatch(getLayouts(userCredentials?.username!)); setMounted(true); - }, []); + }, [dispatch, userCredentials]); const onRetry = () => { dispatch(getLayouts(userCredentials?.username!)); diff --git a/src/components/accessories/dashboard/opds/useData.ts b/src/components/accessories/dashboard/opds/useData.ts index 1e62f63e7..ca9997e1d 100644 --- a/src/components/accessories/dashboard/opds/useData.ts +++ b/src/components/accessories/dashboard/opds/useData.ts @@ -1,8 +1,5 @@ -import { useTranslation } from "react-i18next"; import { useAppSelector } from "libraries/hooks/redux"; -import { AgeTypeDTO, OpdDTO } from "../../../../generated"; -import { TAPIResponseStatus } from "../../../../state/types"; -import { IState } from "../../../../types"; +import { useTranslation } from "react-i18next"; export const useData = () => { const { t } = useTranslation(); diff --git a/src/components/accessories/dateRangeField/DateRangeField.tsx b/src/components/accessories/dateRangeField/DateRangeField.tsx index 2b3b0beae..c88753606 100644 --- a/src/components/accessories/dateRangeField/DateRangeField.tsx +++ b/src/components/accessories/dateRangeField/DateRangeField.tsx @@ -15,10 +15,6 @@ const DateRangeField: FunctionComponent = ({ }) => { const { t } = useTranslation(); - const onChangeHandler = (value: any) => { - onChange(value); - }; - const validationSchema = object({ from: string() .required(t("common.required")) diff --git a/src/components/accessories/dateRangeField/types.ts b/src/components/accessories/dateRangeField/types.ts index a8130e4b8..a916d6f51 100644 --- a/src/components/accessories/dateRangeField/types.ts +++ b/src/components/accessories/dateRangeField/types.ts @@ -1,8 +1,7 @@ -import { DatePicker } from "@mui/x-date-pickers"; -import { ComponentType } from "react"; -import { FIELD_VALIDATION } from "../../../types"; import { DateRange } from "@mui/lab/DateRangePicker"; import { TextFieldProps } from "@mui/material"; +import { ComponentType } from "react"; +import { FIELD_VALIDATION } from "../../../types"; export interface IProps { fieldName?: string; diff --git a/src/components/accessories/discharge/PatientDischarge.tsx b/src/components/accessories/discharge/PatientDischarge.tsx index 2b6ce049a..3387c3b71 100644 --- a/src/components/accessories/discharge/PatientDischarge.tsx +++ b/src/components/accessories/discharge/PatientDischarge.tsx @@ -94,7 +94,7 @@ const PatientDischarge: FC = () => { setShouldResetForm(true); setActivityTransitionState("IDLE"); } - }, [dispatch, activityTransitionState]); + }, [dispatch, activityTransitionState, patient]); const resetFormCallback = () => { setShouldResetForm(false); diff --git a/src/components/accessories/discharge/dischargeForm/DischargeForm.tsx b/src/components/accessories/discharge/dischargeForm/DischargeForm.tsx index 410a5718b..437a662c6 100644 --- a/src/components/accessories/discharge/dischargeForm/DischargeForm.tsx +++ b/src/components/accessories/discharge/dischargeForm/DischargeForm.tsx @@ -152,6 +152,7 @@ const DischargeForm: FC = ({ ).toString(); setFieldValue("bedDays", days); }, + // eslint-disable-next-line react-hooks/exhaustive-deps [setFieldValue, admission] ); @@ -172,7 +173,7 @@ const DischargeForm: FC = ({ setFieldValue(fieldName, value); formik.setFieldTouched(fieldName, false); }, - [setFieldValue, handleBlur] + [handleBlur, setFieldValue, formik] ); const [openResetConfirmation, setOpenResetConfirmation] = useState(false); diff --git a/src/components/accessories/feedback/OHFeedback.tsx b/src/components/accessories/feedback/OHFeedback.tsx index d96a69912..1b32eab44 100644 --- a/src/components/accessories/feedback/OHFeedback.tsx +++ b/src/components/accessories/feedback/OHFeedback.tsx @@ -37,7 +37,7 @@ const OHFeedback: FC = () => { ); return (
- + diff --git a/src/components/accessories/hospitalInfo/HospitalInfo.tsx b/src/components/accessories/hospitalInfo/HospitalInfo.tsx index 4afd42d2e..d1d9b9448 100644 --- a/src/components/accessories/hospitalInfo/HospitalInfo.tsx +++ b/src/components/accessories/hospitalInfo/HospitalInfo.tsx @@ -12,7 +12,7 @@ export const HospitalInfo: FC = () => { const { t } = useTranslation(); useEffect(() => { dispatch(getHospital()); - }, [dispatch, getHospital]); + }, [dispatch]); const hospital = useAppSelector( (state) => state.hospital.getHospital.data diff --git a/src/components/accessories/laboratory/Exams.tsx b/src/components/accessories/laboratory/Exams.tsx index 94049ee00..2ebac108d 100644 --- a/src/components/accessories/laboratory/Exams.tsx +++ b/src/components/accessories/laboratory/Exams.tsx @@ -1,6 +1,13 @@ import { CircularProgress } from "@mui/material"; import { useAppDispatch, useAppSelector } from "libraries/hooks/redux"; -import React, { FC, Fragment, useEffect, useMemo, useRef, useState } from "react"; +import React, { + FC, + Fragment, + useEffect, + useMemo, + useRef, + useState, +} from "react"; import { useTranslation } from "react-i18next"; import { Route, Routes, useLocation, useNavigate } from "react-router"; import checkIcon from "../../../assets/check-icon.png"; @@ -78,11 +85,11 @@ export const Exams: FC = () => { return () => { dispatch(deleteLabReset()); }; - }, []); + }, [dispatch, fields]); useEffect(() => { dispatch(searchLabs({ ...filter, paged: true })); - }, [filter]); + }, [dispatch, filter]); useEffect(() => { const refresh = ( @@ -91,7 +98,7 @@ export const Exams: FC = () => { if (refresh) { dispatch(searchLabs({ ...filter, paged: true })); } - }, [location]); + }, [dispatch, filter, location]); const onSubmit = (values: TFilterValues) => { setFilter({ ...values, page: 0, size: filter.size }); @@ -123,12 +130,12 @@ export const Exams: FC = () => { }; const onDelete = (code: number | undefined) => { - setDeletedObjCode(`${code}` ?? ""); + setDeletedObjCode(code === undefined ? "" : `${code}`); dispatch(deleteLab(code)); }; const onCancel = (code: number | undefined) => { - setCanceledObjCode(`${code}` ?? ""); + setCanceledObjCode(code === undefined ? "" : `${code}`); dispatch(cancelLab(code)); }; const onPageChange = (e: any, page: number) => handlePageChange(e, page - 1); @@ -157,7 +164,7 @@ export const Exams: FC = () => { if (changeStatus === "SUCCESS") { dispatch(searchLabs({ ...filter, paged: true })); } - }, [changeStatus]); + }, [changeStatus, dispatch, filter]); /** * I commented the following lignes because they were causing issue with filter. @@ -258,6 +265,7 @@ export const Exams: FC = () => { )} ); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [status, fields, data, filter, dispatch, labStore, showStatusChangeModal]); return ( diff --git a/src/components/accessories/laboratory/examForm/ExamForm.tsx b/src/components/accessories/laboratory/examForm/ExamForm.tsx index d37b1f8ea..d00570ba2 100644 --- a/src/components/accessories/laboratory/examForm/ExamForm.tsx +++ b/src/components/accessories/laboratory/examForm/ExamForm.tsx @@ -81,7 +81,7 @@ const ExamForm: FC = ({ setShouldResetForm(true); handleReset(); } - }, [dispatch, activityTransitionState]); + }, [dispatch, activityTransitionState, handleReset]); const patient = useAppSelector( (state: IState) => state.patients.selectedPatient.data @@ -135,13 +135,13 @@ const ExamForm: FC = ({ } }; - const resetFormCallback = () => { + const resetFormCallback = useCallback(() => { setShouldResetForm(false); dispatch(createLabReset()); dispatch(updateLabReset()); setActivityTransitionState("IDLE"); scrollToElement(null); - }; + }, [dispatch]); const rowTableHeaders: Array<{ label: string; @@ -192,19 +192,6 @@ const ExamForm: FC = ({ } else return []; }; - const materialsOptionsSelector = (materials: string[] | undefined) => { - if (materials) { - return materials.map((item) => { - let label = item ? t(item) : ""; - return { - value: item ?? "", - label: - (label.length > 30 && label.slice(0, 30) + "...") || (label ?? ""), - }; - }); - } else return []; - }; - const examList = useAppSelector((state: IState) => state.exams.examList.data); const examRowOptionsSelector = (state: IState) => { @@ -243,8 +230,9 @@ const ExamForm: FC = ({ setFieldValue(fieldName, value); formik.setFieldTouched(fieldName); }, - [setFieldValue] + [formik, setFieldValue] ); + useEffect(() => { if (initialValues["exam"] !== "") { setCurrentExamCode(initialValues["exam"]); diff --git a/src/components/accessories/laboratory/examRequestForm/ExamRequestForm.tsx b/src/components/accessories/laboratory/examRequestForm/ExamRequestForm.tsx index 8a2053e86..eb587d753 100644 --- a/src/components/accessories/laboratory/examRequestForm/ExamRequestForm.tsx +++ b/src/components/accessories/laboratory/examRequestForm/ExamRequestForm.tsx @@ -40,7 +40,6 @@ const ExamRequestForm: FC = ({ const dispatch = useAppDispatch(); const [patientData, setPatientData] = useState({} as PatientDTO); const exams = useAppSelector((state: IState) => state.exams.examList.data); - const [currentExamCode, setCurrentExamCode] = useState(""); const infoBoxRef = useRef(null); const selectedPatient = useAppSelector( (state: IState) => state.patients.selectedPatient.data @@ -91,7 +90,7 @@ const ExamRequestForm: FC = ({ dispatch(createLabRequestReset()); setShouldResetForm(true); } - }, [dispatch, activityTransitionState]); + }, [dispatch, activityTransitionState, handleSuccess]); const onClose = () => { if (handleSuccess) handleSuccess(true); @@ -135,11 +134,11 @@ const ExamRequestForm: FC = ({ }, }); - const resetFormCallback = () => { + const resetFormCallback = useCallback(() => { setShouldResetForm(false); dispatch(createLabRequestReset()); setActivityTransitionState("IDLE"); - }; + }, [dispatch]); const { setFieldValue, handleBlur, resetForm } = formik; @@ -147,7 +146,6 @@ const ExamRequestForm: FC = ({ if (shouldResetForm) { resetForm(); resetFormCallback(); - setCurrentExamCode(""); } }, [shouldResetForm, resetForm, resetFormCallback]); @@ -170,9 +168,6 @@ const ExamRequestForm: FC = ({ handleBlur(e); if (typeof value === "string") { setFieldValue(fieldName, value); - if (fieldName === "exam") { - setCurrentExamCode(value); - } } else { setFieldValue(fieldName, value?.code ?? ""); setPatientData(value as PatientDTO); diff --git a/src/components/accessories/laboratory/filter/ExamFilterForm.tsx b/src/components/accessories/laboratory/filter/ExamFilterForm.tsx index d94a6e07e..a69272151 100644 --- a/src/components/accessories/laboratory/filter/ExamFilterForm.tsx +++ b/src/components/accessories/laboratory/filter/ExamFilterForm.tsx @@ -204,7 +204,7 @@ export const ExamFilterForm: FC = ({ setFieldValue("dateTo", end); } }, - [formik] + [formik, setFieldValue] ); const isValid = (fieldName: string): boolean => { @@ -235,7 +235,7 @@ export const ExamFilterForm: FC = ({ : setFieldValue(fieldName, value?.code ?? ""); } }, - [setFieldValue, handleBlur] + [handleBlur, examStatusOptions, setFieldValue] ); return ( diff --git a/src/components/accessories/laboratory/filter/types.ts b/src/components/accessories/laboratory/filter/types.ts index 4c76a464f..790467cb9 100644 --- a/src/components/accessories/laboratory/filter/types.ts +++ b/src/components/accessories/laboratory/filter/types.ts @@ -1,4 +1,3 @@ -import { LaboratoryDTOStatusEnum } from "../../../../generated"; import { TFields } from "../../../../libraries/formDataHandling/types"; export interface IExamFilterProps { diff --git a/src/components/accessories/opds/Opds.tsx b/src/components/accessories/opds/Opds.tsx index 03ece738b..5c1a3e686 100644 --- a/src/components/accessories/opds/Opds.tsx +++ b/src/components/accessories/opds/Opds.tsx @@ -27,7 +27,7 @@ export const Opds: FC = () => { useEffect(() => { dispatch(searchOpds({ ...filter, paged: false })); - }, [filter]); + }, [dispatch, filter]); useEffect(() => { setFilter((previous) => ({ ...previous, page: page })); @@ -49,7 +49,7 @@ export const Opds: FC = () => { dispatch(getDiseasesOpd()); dispatch(getDiseaseTypes()); dispatch(getWards()); - }, []); + }, [dispatch]); return ( diff --git a/src/components/accessories/opds/filter/OpdFilterForm.tsx b/src/components/accessories/opds/filter/OpdFilterForm.tsx index d661608e5..74aec53ec 100644 --- a/src/components/accessories/opds/filter/OpdFilterForm.tsx +++ b/src/components/accessories/opds/filter/OpdFilterForm.tsx @@ -162,7 +162,7 @@ export const OpdFilterForm: FC = ({ }); const initialValues = getFromFields(fields, "value"); - const [filter, setFilter] = useState(initialValues as TFilterValues); + const formik = useFormik({ initialValues, validationSchema, @@ -173,7 +173,6 @@ export const OpdFilterForm: FC = ({ values ) as TFilterValues; onSubmit(formattedValues); - setFilter(formattedValues); }, }); @@ -259,7 +258,7 @@ export const OpdFilterForm: FC = ({ setFieldValue("dateTo", end); } }, - [formik] + [formik, setFieldValue] ); const isValid = (fieldName: string): boolean => { @@ -300,7 +299,7 @@ export const OpdFilterForm: FC = ({ formik.setFieldValue("diseaseCode", ""); } }, - [setFieldValue, handleBlur] + [handleBlur, setFieldValue, formik] ); const newPatientOptions = [ @@ -351,7 +350,7 @@ export const OpdFilterForm: FC = ({ {t("opd.general")}
-
+
= ({ options={newPatientOptions} />
+ +
+ +
= ({ options={diseaseOptions} />
-
- -
diff --git a/src/components/accessories/opds/filter/styles.scss b/src/components/accessories/opds/filter/styles.scss index db5414a6f..23a4798f5 100644 --- a/src/components/accessories/opds/filter/styles.scss +++ b/src/components/accessories/opds/filter/styles.scss @@ -40,7 +40,7 @@ justify-content: space-between; .filterOpdForm__item { - margin-right: 5px; + margin-right: 2px; align-items: center; width: 100%; .dateField, @@ -60,6 +60,9 @@ .fullWidth { width: 100%; } + .halfWidth { + width: 49%; + } } } .filterForm__buttonSet { diff --git a/src/components/accessories/opds/types.ts b/src/components/accessories/opds/types.ts index 46ba4d31c..e69de29bb 100644 --- a/src/components/accessories/opds/types.ts +++ b/src/components/accessories/opds/types.ts @@ -1 +0,0 @@ -import { TFields } from "../../../libraries/formDataHandling/types"; diff --git a/src/components/accessories/patientAutocomplete/PatientAutocomplete.tsx b/src/components/accessories/patientAutocomplete/PatientAutocomplete.tsx index 1feb68575..3dcea7982 100644 --- a/src/components/accessories/patientAutocomplete/PatientAutocomplete.tsx +++ b/src/components/accessories/patientAutocomplete/PatientAutocomplete.tsx @@ -38,7 +38,7 @@ const PatientAutocomplete: FC = ({ onBlur, ...props }) => { firstName: inputValue, } as TValues) ); - }, [inputValue]); + }, [dispatch, inputValue]); const handleOnInputChange = (event: any, value: string) => { if (value === "") setValue(undefined); diff --git a/src/components/accessories/patientBooking/PatientBooking.tsx b/src/components/accessories/patientBooking/PatientBooking.tsx index 444afe3fe..e2ccbd62e 100644 --- a/src/components/accessories/patientBooking/PatientBooking.tsx +++ b/src/components/accessories/patientBooking/PatientBooking.tsx @@ -15,7 +15,7 @@ const PatientBooking = () => { const [bookingTransitionState, setActivityTransitionState] = useState("IDLE"); - const { isLoading, hasSucceeded, hasFailed } = useAppSelector((state) => ({ + const { isLoading, hasFailed } = useAppSelector((state) => ({ isLoading: false, hasSucceeded: true, hasFailed: false, diff --git a/src/components/accessories/patientExams/ExamForm/ExamForm.tsx b/src/components/accessories/patientExams/ExamForm/ExamForm.tsx index 40b8715aa..ae93c8991 100644 --- a/src/components/accessories/patientExams/ExamForm/ExamForm.tsx +++ b/src/components/accessories/patientExams/ExamForm/ExamForm.tsx @@ -106,27 +106,6 @@ const ExamForm: FC = ({ examRowOptionsSelector(state) ); - const materialsLoading = useAppSelector( - (state: IState) => state.laboratories.materials.status === "LOADING" - ); - - const materialsOptionsSelector = (materials: string[] | undefined) => { - if (materials) { - return materials.map((item) => { - let label = item ? t(item) : ""; - return { - value: item ?? "", - label: - (label.length > 30 && label.slice(0, 30) + "...") || (label ?? ""), - }; - }); - } else return []; - }; - - const materialsList = useAppSelector( - (state: IState) => state.laboratories.materials.data - ); - const formik = useFormik({ initialValues, validationSchema, @@ -148,8 +127,9 @@ const ExamForm: FC = ({ setFieldValue(fieldName, value); formik.setFieldTouched(fieldName); }, - [setFieldValue] + [formik, setFieldValue] ); + useEffect(() => { if (initialValues["exam"] !== "") { setCurrentExamCode(initialValues["exam"]); @@ -157,7 +137,7 @@ const ExamForm: FC = ({ if (labToEdit) { formik.setFieldValue("result", labToEdit.result); } - }, [initialValues]); + }, [formik, initialValues, labToEdit]); useEffect(() => { if (currentExamCode) { diff --git a/src/components/accessories/patientExams/PatientExams.tsx b/src/components/accessories/patientExams/PatientExams.tsx index f72c82961..3a2a967dd 100644 --- a/src/components/accessories/patientExams/PatientExams.tsx +++ b/src/components/accessories/patientExams/PatientExams.tsx @@ -101,12 +101,9 @@ const PatientExams: FC = () => { ) as string; const exams = useAppSelector((state: IState) => state.exams.examList.data); - const onSuccess = useCallback( - (shoudlReset: boolean) => { - setShouldUpdateRequestsTable(shoudlReset); - }, - [dispatch] - ); + const onSuccess = useCallback((shoudlReset: boolean) => { + setShouldUpdateRequestsTable(shoudlReset); + }, []); const onSubmit = (lab: LaboratoryDTO, rows: string[]) => { setShouldResetForm(false); @@ -153,12 +150,12 @@ const PatientExams: FC = () => { scrollToElement(null); }; const onDelete = (code: number | undefined) => { - setDeletedObjCode(`${code}` ?? ""); + setDeletedObjCode(code === undefined ? "" : `${code}`); dispatch(deleteLab(code)); }; const onCancel = (code: number | undefined) => { - setCanceledObjCode(`${code}` ?? ""); + setCanceledObjCode(code === undefined ? "" : `${code}`); dispatch(cancelLab(code)); }; diff --git a/src/components/accessories/patientExams/examRowTable/ExamRowTable.tsx b/src/components/accessories/patientExams/examRowTable/ExamRowTable.tsx index 71aa63d11..ada2220e2 100644 --- a/src/components/accessories/patientExams/examRowTable/ExamRowTable.tsx +++ b/src/components/accessories/patientExams/examRowTable/ExamRowTable.tsx @@ -33,10 +33,12 @@ const ExamRowTable: FC = ({ debounceUpdate(value); }; + // eslint-disable-next-line react-hooks/exhaustive-deps const debounceUpdate = useCallback( debounce((value: string) => onBlur(value), 100), [] ); + return ( = ({ handleCancel, }) => { const { t } = useTranslation(); - const canUpdate = usePermission("laboratories.update"); const canCancel = usePermission("laboratories.delete"); const infoBoxRef = useRef(null); @@ -53,7 +52,7 @@ const PatientExamRequestsTable: FunctionComponent = ({ useEffect(() => { if (shouldUpdateTable || patientCode) dispatch(getLabsRequestByPatientId(patientCode)); - }, [patientCode, shouldUpdateTable]); + }, [dispatch, patientCode, shouldUpdateTable]); const formatDataToDisplay = (data: LaboratoryDTO[]) => { return data.map((item) => { @@ -78,12 +77,6 @@ const PatientExamRequestsTable: FunctionComponent = ({ t("common.somethingwrong") ) as string; - const onEdit = (row: any) => { - if (handleEdit) { - handleEdit(data?.find((item) => item.code === row.code)); - } - }; - const onCancel = (row: any) => { if (handleCancel) { handleCancel(row.code); diff --git a/src/components/accessories/patientExams/patientExamsTable/PatientExamsTable.tsx b/src/components/accessories/patientExams/patientExamsTable/PatientExamsTable.tsx index b6b85b018..a1c75f29f 100644 --- a/src/components/accessories/patientExams/patientExamsTable/PatientExamsTable.tsx +++ b/src/components/accessories/patientExams/patientExamsTable/PatientExamsTable.tsx @@ -4,7 +4,6 @@ import React, { FunctionComponent, useEffect, useRef } from "react"; import { useTranslation } from "react-i18next"; import { LabWithRowsDTO } from "../../../../generated"; import { renderDateTime } from "../../../../libraries/formatUtils/dataFormatting"; -import { usePermission } from "../../../../libraries/permissionUtils/usePermission"; import { getLabsByPatientId } from "../../../../state/laboratories"; import InfoBox from "../../infoBox/InfoBox"; import { statusLabel } from "../../laboratory/table/ExamTable"; @@ -22,8 +21,6 @@ const PatientExamsTable: FunctionComponent = ({ handleDelete, }) => { const { t } = useTranslation(); - const canUpdate = usePermission("exams.update"); - const canDelete = usePermission("exams.delete"); const infoBoxRef = useRef(null); const header = ["date", "exam", "status"]; @@ -91,21 +88,6 @@ const PatientExamsTable: FunctionComponent = ({ t("common.somethingwrong") ) as string; - const labData = useAppSelector( - (state) => state.laboratories.labsByPatientId.data - ); - - const onEdit = (row: any) => { - handleEdit( - labData?.find((item) => item.laboratoryDTO?.code === row.code) - ?.laboratoryDTO - ); - }; - - const onDelete = (row: any) => { - handleDelete(row.code); - }; - return (
{t("lab.previousentries")}
diff --git a/src/components/accessories/patientExams/types.ts b/src/components/accessories/patientExams/types.ts index 2e8d3f55c..fc0b19794 100644 --- a/src/components/accessories/patientExams/types.ts +++ b/src/components/accessories/patientExams/types.ts @@ -1,4 +1,4 @@ -import { MedicalDTO, PatientDTO, TherapyRowDTO } from "../../../generated"; +import { TherapyRowDTO } from "../../../generated"; export interface IStateProps { isLoading: boolean; diff --git a/src/components/accessories/patientExtraData/patientExtraData.tsx b/src/components/accessories/patientExtraData/patientExtraData.tsx index e88f95940..33a00ea1c 100644 --- a/src/components/accessories/patientExtraData/patientExtraData.tsx +++ b/src/components/accessories/patientExtraData/patientExtraData.tsx @@ -75,6 +75,7 @@ export const PatientExtraData: FunctionComponent = ({ formik.resetForm(); setActivityTransitionState("IDLE"); } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [dispatch, activityTransitionState]); const discardChanges = () => { diff --git a/src/components/accessories/patientNewBill/PatientNewBill.tsx b/src/components/accessories/patientNewBill/PatientNewBill.tsx index a60852f2e..1e7738675 100644 --- a/src/components/accessories/patientNewBill/PatientNewBill.tsx +++ b/src/components/accessories/patientNewBill/PatientNewBill.tsx @@ -34,10 +34,8 @@ const PatientNewBill: FC = () => { const [openPayment, setOpenPayment] = useState(true); const { - fullBill, bill, billItems, - billPayments, itemsRowData, billTotal, paymentTotal, @@ -46,19 +44,15 @@ const PatientNewBill: FC = () => { status, saveBill, setItemToEdit, - handleBillEdit, handleAddItem, handleEditItem, handleAddPayment, handleDeleteItem, - handleDeletePayment, } = useFullBill(); const { showItemPicker, showPaymentDialog, - openSaveDialog, - handleSaveDialog, handleItemPicker, handlePaymentDialog, } = useDialogStatus(); @@ -81,10 +75,13 @@ const PatientNewBill: FC = () => { const resetItemFormCallback = () => {}; - const handleTableEdit = useCallback((row: any) => { - setItemToEdit(row); - handleItemPicker(); - }, []); + const handleTableEdit = useCallback( + (row: any) => { + setItemToEdit(row); + handleItemPicker(); + }, + [handleItemPicker, setItemToEdit] + ); const handlePayment = (values: Record) => { handleAddPayment(values); @@ -102,7 +99,7 @@ const PatientNewBill: FC = () => { if (status === "SUCCESS") { navigate(`/details/${patient.code ?? ""}/billsrecord`); } - }, [status]); + }, [navigate, patient.code, status]); const classes = useStyles(); @@ -110,7 +107,7 @@ const PatientNewBill: FC = () => { <>
- {billItems.length != 0 && ( + {billItems.length !== 0 && (
setOpenPayment(!openPayment)}> @@ -130,11 +127,11 @@ const PatientNewBill: FC = () => { )}
- {billTotal == 0 && ( + {billTotal === 0 && ( {t("bill.clicktoadditem")} )}
- {billItems.length != 0 && ( + {billItems.length !== 0 && ( {
- {billTotal == 0 && ( + {billTotal === 0 && (
{t("bill.nopendingbill")}
@@ -169,7 +166,7 @@ const PatientNewBill: FC = () => {
)}
- + { const { patient } = useSelectedPatient(); const user = useCurrentUser(); - const { data: pendings, status: pendingStatus } = usePendingBills( - patient.code ?? 0 - ); + const { data: pendings } = usePendingBills(patient.code ?? 0); const creationMode = useMemo(() => !(pendings?.length > 0), [pendings]); const status = useAppSelector((state: IState) => @@ -78,16 +75,16 @@ export const useFullBill = () => { creationMode ? dispatch(newBill(fullBill)) : dispatch(updateBill({ id: bill.id ?? 0, fullBillDTO: fullBill })); - }, [fullBill, creationMode, dispatch]); + }, [creationMode, dispatch, fullBill, bill]); const { prices } = useItemPrices(pendings[0]?.bill?.listId); const itemsRowData = useMemo(() => { return billItems.map((item) => { const priceDTO = prices.find( - (e) => (e.id ?? 0).toString() == item.priceId || e.item == item.itemId + (e) => (e.id ?? 0).toString() === item.priceId || e.item === item.itemId ); const groupLabel = Object.entries(ItemGroups).find( - (e) => e[1].id == priceDTO?.group + (e) => e[1].id === priceDTO?.group ); return { id: item.id, @@ -100,12 +97,13 @@ export const useFullBill = () => { itemAmount: item.itemAmount, }; }); - }, [billItems]); + }, [billItems, prices, t]); const handleBillEdit = useCallback( (billDTO: BillDTO) => setBill({ ...billDTO }), - [bill] + [] ); + const handleAddPayment = useCallback( (values: Record) => setBillPayments([ @@ -118,19 +116,19 @@ export const useFullBill = () => { user: user as any, }, ]), - [billPayments] + [bill, billPayments, user] ); const handleAddItem = useCallback( (itemDTO: BillItemsDTO) => { itemDTO.billId = bill.id; setBillItems([...billItems, itemDTO]); }, - [billItems] + [bill, billItems] ); const handleEditItem = useCallback( (itemDTO: BillItemsDTO) => { const items = billItems.map((item) => - item.id == itemDTO.id ? itemDTO : item + item.id === itemDTO.id ? itemDTO : item ); setBillItems([...items]); setItemToEdit(undefined); @@ -139,14 +137,14 @@ export const useFullBill = () => { ); const handleDeletePayment = useCallback( (paymentDTO: BillPaymentsDTO) => { - let payments = billPayments.filter((value) => value.id != paymentDTO.id); + let payments = billPayments.filter((value) => value.id !== paymentDTO.id); setBillPayments([...payments]); }, [billPayments] ); const handleDeleteItem = useCallback( (item: any) => { - let items = billItems.filter((value) => value.id != item.id); + let items = billItems.filter((value) => value.id !== item.id); setBillItems([...items]); }, [billItems] @@ -155,17 +153,19 @@ export const useFullBill = () => { setFullBill(() => { return { ...fullBill, billDTO: bill }; }); - }, [bill]); + }, [bill, fullBill]); + useEffect(() => { setFullBill(() => { return { ...fullBill, billItemsDTO: billItems }; }); - }, [billItems]); + }, [billItems, fullBill]); + useEffect(() => { setFullBill(() => { return { ...fullBill, billPaymentsDTO: billPayments }; }); - }, [billPayments]); + }, [billPayments, fullBill]); useEffect(() => { if (!creationMode) { @@ -174,7 +174,7 @@ export const useFullBill = () => { setBillItems([...(fullBill.billItems ?? [])]); setBillPayments([...(fullBill.billPayments ?? [])]); } - }, [creationMode, patient]); + }, [creationMode, patient, pendings]); const billTotal = useMemo(() => { return billItems @@ -194,13 +194,13 @@ export const useFullBill = () => { amount: billTotal, balance: billTotal - paymentTotal, })); - }, [billTotal, paymentTotal]); + }, [bill, billTotal, paymentTotal]); useEffect(() => { if (status === "SUCCESS") { creationMode ? dispatch(newBillReset()) : dispatch(updateBillReset()); } - }, [status]); + }, [creationMode, dispatch, status]); return { fullBill, diff --git a/src/components/accessories/patientNewBill/hooks/item.hooks.ts b/src/components/accessories/patientNewBill/hooks/item.hooks.ts index da7df2289..deaca3f91 100644 --- a/src/components/accessories/patientNewBill/hooks/item.hooks.ts +++ b/src/components/accessories/patientNewBill/hooks/item.hooks.ts @@ -1,10 +1,8 @@ -import { argv } from "process"; -import { useEffect } from "react"; import { useAppDispatch, useAppSelector } from "libraries/hooks/redux"; -import { MedicalDTO, ExamDTO, OperationDTO } from "../../../../generated"; +import { useEffect } from "react"; +import { OperationDTO } from "../../../../generated"; import { getExams } from "../../../../state/exams"; import { getMedicals } from "../../../../state/medicals"; -import { IState } from "../../../../types"; export const useItems = () => { const dispatch = useAppDispatch(); diff --git a/src/components/accessories/patientNewBill/hooks/pending_bill.hooks.ts b/src/components/accessories/patientNewBill/hooks/pending_bill.hooks.ts index 98195584d..a89d233a6 100644 --- a/src/components/accessories/patientNewBill/hooks/pending_bill.hooks.ts +++ b/src/components/accessories/patientNewBill/hooks/pending_bill.hooks.ts @@ -1,6 +1,5 @@ -import { useEffect } from "react"; import { useAppDispatch, useAppSelector } from "libraries/hooks/redux"; -import { FullBillDTO } from "../../../../generated"; +import { useEffect } from "react"; import { getPendingBills } from "../../../../state/bills"; import { IState } from "../../../../types"; diff --git a/src/components/accessories/patientNewBill/hooks/price.hooks.ts b/src/components/accessories/patientNewBill/hooks/price.hooks.ts index 43f0c5a66..55889a106 100644 --- a/src/components/accessories/patientNewBill/hooks/price.hooks.ts +++ b/src/components/accessories/patientNewBill/hooks/price.hooks.ts @@ -1,7 +1,5 @@ -import { useEffect, useMemo, useState } from "react"; import { useAppDispatch, useAppSelector } from "libraries/hooks/redux"; -import { PriceDTO } from "../../../../generated/models/PriceDTO"; -import { PriceListDTO } from "../../../../generated/models/PriceListDTO"; +import { useEffect, useMemo } from "react"; import { getPriceLists } from "../../../../state/prices"; import { IState } from "../../../../types"; import { ItemGroups } from "../consts"; @@ -20,17 +18,18 @@ export const usePriceLists = () => { }; export const useItemPrices = (idList?: number) => { - const dispatch = useAppDispatch(); const listId = useMemo(() => idList ?? 0, [idList]); const prices = useAppSelector((state: IState) => - (state.prices.getPrices?.data ?? []).filter((e) => e.list?.id == listId) + (state.prices.getPrices?.data ?? []).filter((e) => e.list?.id === listId) ); const examsOptionsSelector = (state: IState) => { return state.prices.getPrices.data ? state.prices.getPrices.data - .filter((e) => e.group == ItemGroups.exam.id && e.list?.id == listId) + .filter( + (e) => e.group === ItemGroups.exam.id && e.list?.id === listId + ) .map((item) => { return { value: item.item ?? "", @@ -44,7 +43,7 @@ export const useItemPrices = (idList?: number) => { return state.prices.getPrices.data ? state.prices.getPrices.data .filter( - (e) => e.group == ItemGroups.medical.id && e.list?.id == listId + (e) => e.group === ItemGroups.medical.id && e.list?.id === listId ) .map((item) => { return { @@ -59,7 +58,7 @@ export const useItemPrices = (idList?: number) => { return state.prices.getPrices.data ? state.prices.getPrices.data .filter( - (e) => e.group == ItemGroups.surgery.id && e.list?.id == listId + (e) => e.group === ItemGroups.surgery.id && e.list?.id === listId ) .map((item) => { return { diff --git a/src/components/accessories/patientNewBill/itemPicker/BillItemPicker.tsx b/src/components/accessories/patientNewBill/itemPicker/BillItemPicker.tsx index a49196c31..8cd574c07 100644 --- a/src/components/accessories/patientNewBill/itemPicker/BillItemPicker.tsx +++ b/src/components/accessories/patientNewBill/itemPicker/BillItemPicker.tsx @@ -37,19 +37,19 @@ const BillItemPickerForm: FC = ({ const handleFormSubmit = useCallback( (values: Record) => { const id = - itemToEdit == undefined + itemToEdit === undefined ? (items.map((e) => e.id).sort()[items.length - 1] ?? 0) + 1 : itemToEdit?.id; let item: any = { id: id }; item.itemQuantity = values?.itemQuantity; - if (itemType == ItemGroups.other.id) { + if (itemType === ItemGroups.other.id) { item.itemAmount = values?.itemAmount; item.itemDescription = values?.itemDescription; onSubmit(item, itemToEdit === undefined ? true : false); return; } let priceDTO: PriceDTO | undefined = prices.find( - (e) => e?.item == values?.itemId + (e) => e?.item === values?.itemId ); if (priceDTO) { @@ -61,7 +61,7 @@ const BillItemPickerForm: FC = ({ onSubmit(item, itemToEdit === undefined ? true : false); } }, - [itemType] + [itemToEdit, itemType, items, onSubmit, prices] ); const { @@ -75,21 +75,18 @@ const BillItemPickerForm: FC = ({ values, } = useItemFormik(fields, itemType, items, itemToEdit, handleFormSubmit); - const handleItemTypeChange = useCallback( - (e: any, value: string) => { - setItemType(value); - }, - [itemType] - ); + const handleItemTypeChange = useCallback((e: any, value: string) => { + setItemType(value); + }, []); const options = useMemo(() => { return ( - (itemType == ItemGroups.medical.id && medicalsOptions) || - (itemType == ItemGroups.exam.id && examsOptions) || - (itemType == ItemGroups.surgery.id && surgeriesOptions) || + (itemType === ItemGroups.medical.id && medicalsOptions) || + (itemType === ItemGroups.exam.id && examsOptions) || + (itemType === ItemGroups.surgery.id && surgeriesOptions) || [] ); - }, [itemType]); + }, [examsOptions, itemType, medicalsOptions, surgeriesOptions]); return (
= ({ > } label={t("bill.medical")} labelPlacement="top" /> } label={t("bill.exam")} labelPlacement="top" /> } label={t("bill.surgery")} labelPlacement="top" /> } label={t("bill.other")} labelPlacement="top" @@ -138,7 +135,7 @@ const BillItemPickerForm: FC = ({
- {itemType != ItemGroups.other.id && ( + {itemType !== ItemGroups.other.id && ( = ({ isLoading={false} /> )} - {itemType == ItemGroups.other.id && ( + {itemType === ItemGroups.other.id && ( <> { - if (itemType == ItemGroups.other.id) { + if (itemType === ItemGroups.other.id) { return object({ itemAmount: number() .required(t("common.required")) @@ -35,10 +35,10 @@ export const useItemFormik = ( test: (value) => { const item = items.find( (e) => - e.itemDescription?.toLocaleLowerCase() == - value?.toLocaleLowerCase() + e.itemDescription?.toLocaleLowerCase() === + (value as string)?.toLocaleLowerCase() ); - return item == null || itemToEdit != undefined; + return item == null || itemToEdit !== undefined; }, }) .required(t("common.required")), @@ -49,8 +49,8 @@ export const useItemFormik = ( name: "item", message: t("bill.itemalreadypresent"), test: (value) => { - const item = items.find((e) => e.itemId == value); - return item == null || itemToEdit != undefined; + const item = items.find((e) => e.itemId === value); + return item == null || itemToEdit !== undefined; }, }), itemQuantity: number() @@ -58,15 +58,16 @@ export const useItemFormik = ( name: "quantity", message: t("common.lessthan", { value: "1" }), test: (value) => { - if (itemType == ItemGroups.medical.id) return true; + if (itemType === ItemGroups.medical.id) return true; return value > 1 ? false : true; }, }) .min(1, t("common.greaterthan", { value: "1" })), }); - }, [itemType]); + }, [itemToEdit, itemType, items, t]); + const initialValues = useMemo(() => { - if (itemToEdit != undefined) { + if (itemToEdit !== undefined) { return getFromFields( { itemAmount: { @@ -90,7 +91,7 @@ export const useItemFormik = ( ); } return getFromFields(fields, "value"); - }, [itemToEdit]); + }, [fields, itemToEdit]); const formik = useFormik({ initialValues, @@ -107,7 +108,6 @@ export const useItemFormik = ( getFieldProps, values, resetForm, - handleChange, handleBlur, handleSubmit, isValid: isFormValid, @@ -122,7 +122,7 @@ export const useItemFormik = ( handleBlur(e); setFieldValue(fieldName, value); }, - [handleBlur, handleChange] + [handleBlur, setFieldValue] ); const isValid = (fieldName: string): boolean => { diff --git a/src/components/accessories/patientOPD/patientOPDForm/PatientOPDForm.tsx b/src/components/accessories/patientOPD/patientOPDForm/PatientOPDForm.tsx index 840379b19..567627d4e 100644 --- a/src/components/accessories/patientOPD/patientOPDForm/PatientOPDForm.tsx +++ b/src/components/accessories/patientOPD/patientOPDForm/PatientOPDForm.tsx @@ -35,10 +35,7 @@ import { useTranslation } from "react-i18next"; import { object, string } from "yup"; import checkIcon from "../../../../assets/check-icon.png"; import warningIcon from "../../../../assets/warning-icon.png"; -import { - OpdWithOperationRowDTO, - OperationRowDTO -} from "../../../../generated"; +import { OpdWithOperationRowDTO, OperationRowDTO } from "../../../../generated"; import { renderDate } from "../../../../libraries/formatUtils/dataFormatting"; import { formatAllFieldValues, @@ -175,6 +172,7 @@ const PatientOPDForm: FunctionComponent = ({ setFieldValue(fieldName, value); formik.setFieldTouched(fieldName); }, + // eslint-disable-next-line react-hooks/exhaustive-deps [setFieldValue] ); @@ -323,6 +321,7 @@ const PatientOPDForm: FunctionComponent = ({ } : opRowToEdit ); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [operationCreationMode, opRowToEdit]); const handleUpdateOperationRow = @@ -357,7 +356,7 @@ const PatientOPDForm: FunctionComponent = ({ if (idx > -1) ops.splice(idx, 1); setOperationRows(() => [...ops]); } - }, [changeStatus]); + }, [changeStatus, deletedObjCode, operationRows]); return ( <> diff --git a/src/components/accessories/patientOperation/PatientOperation.tsx b/src/components/accessories/patientOperation/PatientOperation.tsx index 1f305e683..c64678e9f 100644 --- a/src/components/accessories/patientOperation/PatientOperation.tsx +++ b/src/components/accessories/patientOperation/PatientOperation.tsx @@ -140,6 +140,7 @@ const PatientOperation: FC = ({ opd, onSuccess }) => { } : opRowToEdit ); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [creationMode]); return ( diff --git a/src/components/accessories/patientOperation/consts.ts b/src/components/accessories/patientOperation/consts.ts index fa4a4bc3b..a8187735f 100644 --- a/src/components/accessories/patientOperation/consts.ts +++ b/src/components/accessories/patientOperation/consts.ts @@ -1,5 +1,4 @@ import moment from "moment"; -import { parseDate } from "../../../libraries/formDataHandling/functions"; import { TFields } from "../../../libraries/formDataHandling/types"; import { OperationRowFormFieldName } from "./operationForm/types"; diff --git a/src/components/accessories/patientOperation/operationForm/OperationRowForm.tsx b/src/components/accessories/patientOperation/operationForm/OperationRowForm.tsx index 43166ffff..57ded70a9 100644 --- a/src/components/accessories/patientOperation/operationForm/OperationRowForm.tsx +++ b/src/components/accessories/patientOperation/operationForm/OperationRowForm.tsx @@ -51,9 +51,6 @@ const OperationRowForm: FC = ({ }; const initialValues = getFromFields(fields, "value"); - const currentAdmission = useAppSelector( - (state: IState) => state.admissions.currentAdmissionByPatientId.data - ); const validationSchema = object({ operation: string().required(t("common.required")), @@ -97,7 +94,7 @@ const OperationRowForm: FC = ({ formik.setFieldTouched(fieldName); formik.validateField(fieldName); }, - [setFieldValue] + [formik, setFieldValue] ); const isValid = (fieldName: string): boolean => { diff --git a/src/components/accessories/patientPicker/PatientPicker.tsx b/src/components/accessories/patientPicker/PatientPicker.tsx index 3bd9297de..d5e9398e2 100644 --- a/src/components/accessories/patientPicker/PatientPicker.tsx +++ b/src/components/accessories/patientPicker/PatientPicker.tsx @@ -135,7 +135,7 @@ const PatientPicker: FC = ({ useEffect(() => { const pat = patientData?.find((item) => item.code === fieldValue); pat ? setValue(pat) : setValue(initialValue ?? ({} as any)); - }, [fieldValue]); + }, [fieldValue, initialValue, patientData]); const handleOnBlur = (e: React.FocusEvent) => { if (value) onBlur(e, value); diff --git a/src/components/accessories/patientTherapy/patientTherapyTable/PatientTherapyTable.tsx b/src/components/accessories/patientTherapy/patientTherapyTable/PatientTherapyTable.tsx index 67a3afbfd..94fab2329 100644 --- a/src/components/accessories/patientTherapy/patientTherapyTable/PatientTherapyTable.tsx +++ b/src/components/accessories/patientTherapy/patientTherapyTable/PatientTherapyTable.tsx @@ -101,10 +101,6 @@ const PatientTherapyTable: FunctionComponent = ({ (state) => state.therapies.therapiesByPatientId.status ); - const onDelete = (row: TherapyRowDTO) => { - handleDelete(row.therapyID); - }; - const onEdit = (row: TherapyRowDTO) => { handleEdit(data.find((item) => item.therapyID === row.therapyID)); }; diff --git a/src/components/accessories/patientTherapy/therapyForm/TherapyForm.tsx b/src/components/accessories/patientTherapy/therapyForm/TherapyForm.tsx index 5e903c2d3..e07f9c5b6 100644 --- a/src/components/accessories/patientTherapy/therapyForm/TherapyForm.tsx +++ b/src/components/accessories/patientTherapy/therapyForm/TherapyForm.tsx @@ -118,6 +118,7 @@ const TherapyForm: FC = ({ ); computeEndDate(formik.values.startDate); }, + // eslint-disable-next-line react-hooks/exhaustive-deps [formik] ); @@ -129,6 +130,7 @@ const TherapyForm: FC = ({ formik.setFieldTouched(fieldName); } }, + // eslint-disable-next-line react-hooks/exhaustive-deps [formik] ); @@ -148,7 +150,7 @@ const TherapyForm: FC = ({ formik.handleBlur(e); setFieldValue(fieldName, value); }, - [setFieldValue, handleBlur] + [formik, setFieldValue] ); const [openResetConfirmation, setOpenResetConfirmation] = useState(false); diff --git a/src/components/accessories/patientTherapy/therapyForm/types.ts b/src/components/accessories/patientTherapy/therapyForm/types.ts index 558f5b256..4f4566774 100644 --- a/src/components/accessories/patientTherapy/therapyForm/types.ts +++ b/src/components/accessories/patientTherapy/therapyForm/types.ts @@ -1,4 +1,4 @@ -import { PatientDTO, TherapyRowDTO } from "../../../../generated"; +import { TherapyRowDTO } from "../../../../generated"; import { TFields } from "../../../../libraries/formDataHandling/types"; interface ITherapyProps { diff --git a/src/components/accessories/patientTriage/PatientTriage.tsx b/src/components/accessories/patientTriage/PatientTriage.tsx index 5ce192757..8e38daede 100644 --- a/src/components/accessories/patientTriage/PatientTriage.tsx +++ b/src/components/accessories/patientTriage/PatientTriage.tsx @@ -79,13 +79,13 @@ const PatientTriage: FC = () => { if (status === "SUCCESS" && patientDataCode) { dispatch(getLastByPatientId(patientDataCode)); } - }, [status]); + }, [dispatch, patientDataCode, status]); useEffect(() => { if (deleteStatus === "SUCCESS" && patientDataCode) { dispatch(getLastByPatientId(patientDataCode)); } - }, [deleteStatus]); + }, [deleteStatus, dispatch, patientDataCode]); useEffect(() => { dispatch(createExaminationReset()); @@ -109,7 +109,7 @@ const PatientTriage: FC = () => { dispatch(getLastByPatientId(patientDataCode)); dispatch(getDefaultPatientExamination(patientDataCode)); } - }, [patientDataCode]); + }, [dispatch, patientDataCode]); const onSubmit = (triage: PatientExaminationDTO) => { setShouldResetForm(false); diff --git a/src/components/accessories/patientTriage/patientTriageForm/PatientTriageForm.tsx b/src/components/accessories/patientTriage/patientTriageForm/PatientTriageForm.tsx index 57ac59fe4..8107d9f3e 100644 --- a/src/components/accessories/patientTriage/patientTriageForm/PatientTriageForm.tsx +++ b/src/components/accessories/patientTriage/patientTriageForm/PatientTriageForm.tsx @@ -128,7 +128,7 @@ const PatientTriageForm: FunctionComponent = ({ setFieldValue(fieldName, value); formik.setFieldTouched(fieldName); }, - [setFieldValue] + [formik, setFieldValue] ); const isValid = (fieldName: string): boolean => { diff --git a/src/components/accessories/patientTriage/patientTriageTable/PatientTriageTable.tsx b/src/components/accessories/patientTriage/patientTriageTable/PatientTriageTable.tsx index f34a16e44..e60f353a5 100644 --- a/src/components/accessories/patientTriage/patientTriageTable/PatientTriageTable.tsx +++ b/src/components/accessories/patientTriage/patientTriageTable/PatientTriageTable.tsx @@ -96,10 +96,6 @@ const PatientTriageTable: FunctionComponent = ({ t("common.somethingwrong") ) as string; - const onDelete = (row: PatientExaminationDTO) => { - handleDelete(row.pex_ID); - }; - return (
{t("examination.previousentries")}
diff --git a/src/components/accessories/patientVisit/patientVisit.tsx b/src/components/accessories/patientVisit/patientVisit.tsx index de06acde9..01b672c2d 100644 --- a/src/components/accessories/patientVisit/patientVisit.tsx +++ b/src/components/accessories/patientVisit/patientVisit.tsx @@ -36,8 +36,6 @@ const PatientVisit: FunctionComponent = () => { const [creationMode, setCreationMode] = useState(true); - const [showModal, setShowModal] = useState(false); - const changeStatus = useAppSelector((state) => { /* Apart from "IDLE" create and update cannot reach "LOADING", "SUCCESS" and "FAIL" @@ -112,10 +110,6 @@ const PatientVisit: FunctionComponent = () => { scrollToElement(null); }; - const addOperationCallback = () => { - setShowModal(true); - }; - const onEdit: (row: VisitDTO) => void = (row) => { setVisitToEdit(row); setCreationMode(false); @@ -141,7 +135,7 @@ const PatientVisit: FunctionComponent = () => { isLoading={changeStatus === "LOADING"} shouldResetForm={shouldResetForm} resetFormCallback={resetFormCallback} - addOperationCallback={addOperationCallback} + addOperationCallback={() => {}} /> {changeStatus === "FAIL" && (
diff --git a/src/components/accessories/paymentsTable/PaymentsTable.tsx b/src/components/accessories/paymentsTable/PaymentsTable.tsx index 6e97d7aef..2d1f19de0 100644 --- a/src/components/accessories/paymentsTable/PaymentsTable.tsx +++ b/src/components/accessories/paymentsTable/PaymentsTable.tsx @@ -92,7 +92,7 @@ export const PaymentsTable: FC = ({ fields }) => { useEffect(() => { dispatch(searchPayments(initialValues as TFilterValues)); - }, [fields]); + }, [dispatch, fields, initialValues]); const { setFieldValue, handleBlur } = formik; diff --git a/src/components/accessories/profilePicture/ProfilePicture.tsx b/src/components/accessories/profilePicture/ProfilePicture.tsx index 843481382..1de796c80 100644 --- a/src/components/accessories/profilePicture/ProfilePicture.tsx +++ b/src/components/accessories/profilePicture/ProfilePicture.tsx @@ -30,10 +30,7 @@ import Webcam from "../../accessories/webcam/Webcam"; import { ProfilePictureCropper } from "../profilePictureCropper/ProfilePictureCropper"; import "./styles.scss"; import { IProps } from "./types"; -import { - extractPictureFromSelection, - preprocessImage -} from "./utils"; +import { extractPictureFromSelection, preprocessImage } from "./utils"; export const ProfilePicture: FunctionComponent = ({ isEditable, @@ -81,7 +78,7 @@ export const ProfilePicture: FunctionComponent = ({ setFromFileSystem(false); openCropper(); } - }, [pictureToResize]); + }, [fromFileSystem, pictureToResize, showModal]); const pictureInputRef = useRef(null); @@ -122,6 +119,7 @@ export const ProfilePicture: FunctionComponent = ({ preprocessImage(setPicture, image, setShowError); closeModal(); }, + // eslint-disable-next-line react-hooks/exhaustive-deps [setPicture] ); diff --git a/src/components/accessories/profilePicture/utils.ts b/src/components/accessories/profilePicture/utils.ts index ef5ee634f..a88a21e64 100644 --- a/src/components/accessories/profilePicture/utils.ts +++ b/src/components/accessories/profilePicture/utils.ts @@ -1,7 +1,6 @@ -import { ChangeEvent, Dispatch, SetStateAction } from "react"; import imageCompression from "browser-image-compression"; +import { ChangeEvent, Dispatch, SetStateAction } from "react"; import { MAX_FILE_UPLOAD_SIZE } from "./consts"; -import { pick } from "lodash"; const createPreview = (img: HTMLImageElement) => { const canvas = document.createElement("canvas"); diff --git a/src/components/accessories/table/Table.tsx b/src/components/accessories/table/Table.tsx index f5bd9d6ea..b33e1fe55 100644 --- a/src/components/accessories/table/Table.tsx +++ b/src/components/accessories/table/Table.tsx @@ -348,6 +348,7 @@ const Table: FunctionComponent = ({ if (onFilterChange && !manualFilter) { onFilterChange(filters); } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [filters]); return ( diff --git a/src/components/accessories/table/filter/FilterButton.tsx b/src/components/accessories/table/filter/FilterButton.tsx index 7c00a6e9b..b8a8d36c9 100644 --- a/src/components/accessories/table/filter/FilterButton.tsx +++ b/src/components/accessories/table/filter/FilterButton.tsx @@ -101,6 +101,7 @@ export const FilterButton = ({ field, onChange }: IOwnProps) => { useEffect(() => { formik.submitForm(); + // eslint-disable-next-line react-hooks/exhaustive-deps }, [formik.values]); return ( diff --git a/src/components/accessories/tabs/RouterTabs.tsx b/src/components/accessories/tabs/RouterTabs.tsx index c094f9c49..36bcc7ece 100644 --- a/src/components/accessories/tabs/RouterTabs.tsx +++ b/src/components/accessories/tabs/RouterTabs.tsx @@ -30,7 +30,7 @@ const RouterTabs: FunctionComponent = ({ config, defaultRoute }) => { if (!mobile) { return tabs.map((item, index) => { const path = item.path!; - return tabs.length == 1 ? ( + return tabs.length === 1 ? ( <> ) : (
{ if (item.checkPermissions) { const checkPermissions = asArray(item.checkPermissions); return checkPermissions.find((permission) => - permissions.includes(permission) + permissions.includes(permission as TPermission) ); } return true; diff --git a/src/components/activities/editPatientActivity/EditPatientActivity.tsx b/src/components/activities/editPatientActivity/EditPatientActivity.tsx index f73ae8524..d291558e1 100644 --- a/src/components/activities/editPatientActivity/EditPatientActivity.tsx +++ b/src/components/activities/editPatientActivity/EditPatientActivity.tsx @@ -50,7 +50,7 @@ const EditPatientActivity = () => { if (isEmpty(patient.data) && patient.status === "IDLE" && id) { dispatch(getPatient(id)); } - }, [patient, id, getPatient]); + }, [patient, id, dispatch]); const breadcrumbMap = { [t("nav.patients")]: PATHS.patients, @@ -81,10 +81,6 @@ const EditPatientActivity = () => { }, }) ); - else - console.error( - 'The Patient: PatientDTO object must have a "code" property.' - ); }; const [activityTransitionState, setActivityTransitionState] = @@ -96,10 +92,9 @@ const EditPatientActivity = () => { if (isEmpty(patient.data) && patient.status === "IDLE") { getPatient(id!); } - }, [patient, id, getPatient]); + }, [patient, id]); useEffect(() => { - console.log(activityTransitionState); if (activityTransitionState === "TO_PATIENT") { getPatient(id!); updatePatientReset(); @@ -108,7 +103,7 @@ const EditPatientActivity = () => { setOpenConfirmationMessage(false); setActivityTransitionState("IDLE"); } - }, [activityTransitionState, updatePatientReset, getPatient, id]); + }, [activityTransitionState, id]); useEffect(() => { setOpenConfirmationMessage(hasSucceeded); diff --git a/src/components/activities/laboratoryActivity/LaboratoryActivity.tsx b/src/components/activities/laboratoryActivity/LaboratoryActivity.tsx index 9f5a69e92..a028f0d0d 100644 --- a/src/components/activities/laboratoryActivity/LaboratoryActivity.tsx +++ b/src/components/activities/laboratoryActivity/LaboratoryActivity.tsx @@ -27,7 +27,7 @@ const LaboratoryActivity: FC = () => { return { [t("nav.laboratory")]: PATHS.laboratory, }; - }, [location]); + }, [location.pathname, t]); const userCredentials = useAppSelector( (state) => state.main.authentication.data diff --git a/src/components/activities/newPatientActivity/NewPatientActivity.tsx b/src/components/activities/newPatientActivity/NewPatientActivity.tsx index aa5e501c6..6542af7c5 100644 --- a/src/components/activities/newPatientActivity/NewPatientActivity.tsx +++ b/src/components/activities/newPatientActivity/NewPatientActivity.tsx @@ -60,7 +60,7 @@ const NewPatientActivity: FunctionComponent = ({ useEffect(() => { dispatch(getPatientReset()); - }, []); + }, [dispatch]); useEffect(() => { if ( @@ -77,7 +77,7 @@ const NewPatientActivity: FunctionComponent = ({ }); } } - }, [activityTransitionState, createPatientReset]); + }, [activityTransitionState, dispatch, navigate, patient?.code]); const infoBoxRef = useRef(null); useEffect(() => { diff --git a/src/components/activities/newPatientActivity/types.ts b/src/components/activities/newPatientActivity/types.ts index c682e0979..3fa083d29 100644 --- a/src/components/activities/newPatientActivity/types.ts +++ b/src/components/activities/newPatientActivity/types.ts @@ -1,4 +1,3 @@ -import { PatientDTO } from "../../../generated"; import { TUserCredentials } from "../../../state/main/types"; export interface IOwnProps { diff --git a/src/components/activities/patientDetailsActivity/InPatientDashboardMenu.tsx b/src/components/activities/patientDetailsActivity/InPatientDashboardMenu.tsx index 3d121c567..1fbcd0042 100644 --- a/src/components/activities/patientDetailsActivity/InPatientDashboardMenu.tsx +++ b/src/components/activities/patientDetailsActivity/InPatientDashboardMenu.tsx @@ -10,7 +10,7 @@ import { } from "@mui/icons-material"; import React, { FunctionComponent, useCallback } from "react"; import { useTranslation } from "react-i18next"; -import { useLocation, useNavigate } from "react-router"; +import { useNavigate } from "react-router"; import Arrow from "../../../assets/arrow-w.svg"; import { Permission } from "../../../libraries/permissionUtils/Permission"; import "./styles.scss"; @@ -27,7 +27,6 @@ const InPatientDashboardMenu: FunctionComponent = ({ }) => { const { t } = useTranslation(); - const { pathname } = useLocation(); const navigate = useNavigate(); const isActive = (value: string) => { diff --git a/src/components/activities/patientDetailsActivity/OutPatientDashboardMenu.tsx b/src/components/activities/patientDetailsActivity/OutPatientDashboardMenu.tsx index bfa339129..3e4de4957 100644 --- a/src/components/activities/patientDetailsActivity/OutPatientDashboardMenu.tsx +++ b/src/components/activities/patientDetailsActivity/OutPatientDashboardMenu.tsx @@ -8,7 +8,7 @@ import { } from "@mui/icons-material"; import React, { FunctionComponent, useCallback } from "react"; import { useTranslation } from "react-i18next"; -import { useLocation, useNavigate } from "react-router"; +import { useNavigate } from "react-router"; import Arrow from "../../../assets/arrow-w.svg"; import "./styles.scss"; import { IUserSection } from "./types"; @@ -28,7 +28,6 @@ const OutPatientDashboardMenu: FunctionComponent = ({ return value === userSection ? "active" : "default"; }; - const { pathname } = useLocation(); const navigate = useNavigate(); const changeUserSection = useCallback( @@ -36,7 +35,7 @@ const OutPatientDashboardMenu: FunctionComponent = ({ setUserSection(section); navigate(`${section}`, { replace: true }); }, - [navigate, pathname, setUserSection] + [navigate, setUserSection] ); return ( diff --git a/src/components/activities/searchPatientActivity/PatientSearchItem.tsx b/src/components/activities/searchPatientActivity/PatientSearchItem.tsx index 55379330c..cf3581e98 100644 --- a/src/components/activities/searchPatientActivity/PatientSearchItem.tsx +++ b/src/components/activities/searchPatientActivity/PatientSearchItem.tsx @@ -24,7 +24,7 @@ const PatientSearchItem: FunctionComponent = ({ navigate(`/patients/details/${patient.code}`); } } - }, [activityTransitionState, getPatientSuccessCallback, patient]); + }, [activityTransitionState, getPatientSuccessCallback, navigate, patient]); const patientDate = renderDate(patient.birthDate ?? ""); diff --git a/src/components/activities/searchPatientActivity/types.ts b/src/components/activities/searchPatientActivity/types.ts index c35e85394..b695e9020 100644 --- a/src/components/activities/searchPatientActivity/types.ts +++ b/src/components/activities/searchPatientActivity/types.ts @@ -1,6 +1,6 @@ import { PatientDTO } from "../../../generated"; import { TUserCredentials } from "../../../state/main/types"; -import { IAction, TAPIResponseStatus } from "../../../state/types"; +import { TAPIResponseStatus } from "../../../state/types"; export interface IStateProps { userCredentials: TUserCredentials; diff --git a/src/libraries/authUtils/getAuthenticationFromSession.ts b/src/libraries/authUtils/getAuthenticationFromSession.ts index 1b53e105f..460a33c49 100644 --- a/src/libraries/authUtils/getAuthenticationFromSession.ts +++ b/src/libraries/authUtils/getAuthenticationFromSession.ts @@ -3,7 +3,7 @@ import { IAuthentication } from "../../state/main/types"; import { SessionStorage } from "../storage/storage"; export const getAuthenticationFromSession = (): IAuthentication => { - const { permissions, userName } = SessionStorage.read(PERMISSION_KEY); + const { permissions } = SessionStorage.read(PERMISSION_KEY); const { username, token } = SessionStorage.read(AUTH_KEY); if (!(token && username && permissions)) { diff --git a/src/libraries/dashboardUtils/admissions/useAdmByAdmTypeData.ts b/src/libraries/dashboardUtils/admissions/useAdmByAdmTypeData.ts index ef7098b56..8cfd178ec 100644 --- a/src/libraries/dashboardUtils/admissions/useAdmByAdmTypeData.ts +++ b/src/libraries/dashboardUtils/admissions/useAdmByAdmTypeData.ts @@ -21,10 +21,7 @@ export const useAdmByAdmTypeData = () => { state.admissions.getAdmissions.status ?? "" ) ); - const wardStatus = useAppSelector( - (state) => state.wards.allWards.status ?? "IDLE" - ); - const sexLabels = [t("common.male"), t("common.female")]; + const labels = admissionTypes.map((e) => e.description ?? ""); const data = { labels: labels, diff --git a/src/libraries/dashboardUtils/admissions/useAdmByWardData.ts b/src/libraries/dashboardUtils/admissions/useAdmByWardData.ts index 41a1c9a87..b7859bfc8 100644 --- a/src/libraries/dashboardUtils/admissions/useAdmByWardData.ts +++ b/src/libraries/dashboardUtils/admissions/useAdmByWardData.ts @@ -1,8 +1,5 @@ -import { useTranslation } from "react-i18next"; -import { AdmissionDTO, WardDTO } from "../../../generated"; -import { TAPIResponseStatus } from "../../../state/types"; -import { IState } from "../../../types"; import { useAppSelector } from "libraries/hooks/redux"; +import { useTranslation } from "react-i18next"; export const useAdmByAdmWardData = () => { const { t } = useTranslation(); diff --git a/src/libraries/dashboardUtils/discharges/useDisByAgeTypeData.ts b/src/libraries/dashboardUtils/discharges/useDisByAgeTypeData.ts index 6acf55b70..aeeac06d5 100644 --- a/src/libraries/dashboardUtils/discharges/useDisByAgeTypeData.ts +++ b/src/libraries/dashboardUtils/discharges/useDisByAgeTypeData.ts @@ -1,8 +1,5 @@ -import { useTranslation } from "react-i18next"; import { useAppSelector } from "libraries/hooks/redux"; -import { AdmissionDTO, AgeTypeDTO } from "../../../generated"; -import { TAPIResponseStatus } from "../../../state/types"; -import { IState } from "../../../types"; +import { useTranslation } from "react-i18next"; export const useDisByAgeTypeData = () => { const { t } = useTranslation(); diff --git a/src/libraries/dashboardUtils/discharges/useDisByDisTypeData.ts b/src/libraries/dashboardUtils/discharges/useDisByDisTypeData.ts index 4c7644da7..338411f8d 100644 --- a/src/libraries/dashboardUtils/discharges/useDisByDisTypeData.ts +++ b/src/libraries/dashboardUtils/discharges/useDisByDisTypeData.ts @@ -1,8 +1,5 @@ -import { useTranslation } from "react-i18next"; import { useAppSelector } from "libraries/hooks/redux"; -import { AdmissionDTO, AdmissionTypeDTO } from "../../../generated"; -import { TAPIResponseStatus } from "../../../state/types"; -import { IState } from "../../../types"; +import { useTranslation } from "react-i18next"; import { colorGen } from "../../uiUtils/colorGenerator"; export const useDisByDisTypeData = () => { diff --git a/src/libraries/dashboardUtils/discharges/useDisBySexData.ts b/src/libraries/dashboardUtils/discharges/useDisBySexData.ts index dc4708613..49f02c299 100644 --- a/src/libraries/dashboardUtils/discharges/useDisBySexData.ts +++ b/src/libraries/dashboardUtils/discharges/useDisBySexData.ts @@ -1,8 +1,5 @@ -import { useTranslation } from "react-i18next"; import { useAppSelector } from "libraries/hooks/redux"; -import { AdmissionDTO } from "../../../generated"; -import { TAPIResponseStatus } from "../../../state/types"; -import { IState } from "../../../types"; +import { useTranslation } from "react-i18next"; export const useDisBySexData = () => { const { t } = useTranslation(); diff --git a/src/libraries/dashboardUtils/discharges/useDisByWardData.ts b/src/libraries/dashboardUtils/discharges/useDisByWardData.ts index ffad9861d..8d3f5f746 100644 --- a/src/libraries/dashboardUtils/discharges/useDisByWardData.ts +++ b/src/libraries/dashboardUtils/discharges/useDisByWardData.ts @@ -1,8 +1,5 @@ -import { useTranslation } from "react-i18next"; import { useAppSelector } from "libraries/hooks/redux"; -import { AdmissionDTO, WardDTO } from "../../../generated"; -import { TAPIResponseStatus } from "../../../state/types"; -import { IState } from "../../../types"; +import { useTranslation } from "react-i18next"; export const useDisByWardData = () => { const { t } = useTranslation(); diff --git a/src/libraries/formDataHandling/functions.ts b/src/libraries/formDataHandling/functions.ts index 0a19d8bc9..2f501c91c 100644 --- a/src/libraries/formDataHandling/functions.ts +++ b/src/libraries/formDataHandling/functions.ts @@ -1,5 +1,10 @@ import { produce } from "immer"; +import { isEmpty } from "lodash"; import moment from "moment"; +import { + TAgeFieldName, + TAgeType, +} from "../../components/accessories/patientDataForm/types"; import { IFormCustomizationProps } from "../../customization/formCustomization/type"; import { AdmissionDTO, @@ -17,11 +22,6 @@ import { WardDTO, } from "../../generated"; import { TFieldAddress, TFieldFormattedValue, TFields } from "./types"; -import { - TAgeFieldName, - TAgeType, -} from "../../components/accessories/patientDataForm/types"; -import { isEmpty } from "lodash"; export const getFromFields = ( fields: TFields, @@ -328,10 +328,10 @@ export const getBirthDateAndAge = ( switch (ageType) { case "agetype": let selectedAgeType = allAgeTypes?.find( - (at, i) => at.code == values.agetype + (at, i) => at.code === values.agetype ); - if (selectedAgeType != undefined) { + if (selectedAgeType !== undefined) { let averageAge = Math.round( selectedAgeType.from && selectedAgeType.to ? (selectedAgeType.from + selectedAgeType.to) / 2 diff --git a/src/libraries/hooks/api/useAdmissions.ts b/src/libraries/hooks/api/useAdmissions.ts index d4817d86d..9c509c5f7 100644 --- a/src/libraries/hooks/api/useAdmissions.ts +++ b/src/libraries/hooks/api/useAdmissions.ts @@ -36,7 +36,7 @@ export const useAdmissions = () => { useEffect(() => { dispatch(getAdmissions({ admissionrange: range, page, size })); - }, [page]); + }, [dispatch, page, range, size]); return { pageInfo, diff --git a/src/libraries/hooks/api/useDischarges.ts b/src/libraries/hooks/api/useDischarges.ts index 69113d756..9a6b70b62 100644 --- a/src/libraries/hooks/api/useDischarges.ts +++ b/src/libraries/hooks/api/useDischarges.ts @@ -36,7 +36,7 @@ export const useDisharges = () => { useEffect(() => { dispatch(getDischarges({ dischargerange: range, page, size })); - }, [page]); + }, [dispatch, page, range, size]); return { pageInfo, diff --git a/src/mockServer/fixtures/examRequestDTO.js b/src/mockServer/fixtures/examRequestDTO.js new file mode 100644 index 000000000..a8c78939f --- /dev/null +++ b/src/mockServer/fixtures/examRequestDTO.js @@ -0,0 +1,48 @@ +export const examRequestDTO = [ + { + code: 344, + material: "Undefined", + exam: { + code: "01.04", + description: "1.4 Film Comment", + procedure: 1, + defaultResult: "0", + examtype: { code: "HB", description: "1.Haematology" }, + lock: 1, + }, + registrationDate: "2024-10-03T11:03:31", + labDate: "2024-10-03T00:03:30", + result: "", + lock: 0, + note: null, + patientCode: 85, + patName: "Threadgill Mack", + inOutPatient: "O", + age: 64, + sex: "F", + status: "draft", + }, + { + code: 345, + material: "Undefined", + exam: { + code: "01.03", + description: "1.3 Differential ", + procedure: 1, + defaultResult: "", + examtype: { code: "HB", description: "1.Haematology" }, + lock: 0, + }, + registrationDate: "2024-10-03T11:05:02", + labDate: "2024-10-03T00:05:01", + result: "", + lock: 0, + note: null, + patientCode: 85, + patName: "Threadgill Mack", + inOutPatient: "O", + age: 64, + sex: "F", + status: "draft", + }, +]; diff --git a/src/mockServer/routes/labExamRequest.js b/src/mockServer/routes/labExamRequest.js new file mode 100644 index 000000000..2136d32fc --- /dev/null +++ b/src/mockServer/routes/labExamRequest.js @@ -0,0 +1,19 @@ +import { examRequestDTO } from "mockServer/fixtures/examRequestDTO"; + +export const labExamRequestRoutes = (server) => { + server.namespace("/laboratories/examRequest", () => { + server.get("/patient/:id").intercept((req, res) => { + res.status(200).json(examRequestDTO); + }); + server.post("/").intercept((req, res) => { + let body = req.jsonBody(); + switch (body.code) { + case "FAIL": + res.status(400).json({ message: "Fail to create lab exam request" }); + break; + default: + res.status(200).json(body); + } + }); + }); +}; diff --git a/src/mockServer/server.js b/src/mockServer/server.js index 417d51792..7e20c60e1 100644 --- a/src/mockServer/server.js +++ b/src/mockServer/server.js @@ -1,38 +1,39 @@ import XHRAdapter from "@pollyjs/adapter-xhr"; import { Polly } from "@pollyjs/core"; import { BASE_PATH } from "../generated/runtime"; -import { authRoutes } from "./routes/auth"; -import { examinationsRoutes } from "./routes/examinations"; -import { patientRoutes } from "./routes/patients"; -import { userRoutes } from "./routes/users"; -import { userGroupRoutes } from "./routes/userGroups"; -import { visitRoutes } from "./routes/visits"; -import { opdRoutes } from "./routes/opd"; -import { diseasesRoutes } from "./routes/diseases"; -import { diseaseTypeRoutes } from "./routes/diseaseTypes"; -import { ageTypeRoutes } from "./routes/ageTypes"; -import { therapyRoutes } from "./routes/therapies"; -import { medicalRoutes } from "./routes/medicals"; import { admissionRoutes } from "./routes/admissions"; import { admissionTypesRoutes } from "./routes/admissionTypes"; +import { ageTypeRoutes } from "./routes/ageTypes"; +import { authRoutes } from "./routes/auth"; +import { billRoutes } from "./routes/bill"; +import { deliveryResultTypeRoutes } from "./routes/deliveryResultType"; +import { deliveryTypesRoutes } from "./routes/deliveryTypes"; import { dischargeTypesRoutes } from "./routes/dischargeTypes"; -import { wardsRoutes } from "./routes/wards"; -import { labRoutes } from "./routes/lab"; +import { diseasesRoutes } from "./routes/diseases"; +import { diseaseTypeRoutes } from "./routes/diseaseTypes"; import { examRoutes } from "./routes/exam"; +import { examinationsRoutes } from "./routes/examinations"; import { examRowRoutes } from "./routes/examRow"; import { examTypesRoutes } from "./routes/examTypes"; -import { billRoutes } from "./routes/bill"; -import { pricesRoutes } from "./routes/prices"; -import { operationRoutes } from "./routes/operations"; import { hospitalRoutes } from "./routes/hospital"; +import { labRoutes } from "./routes/lab"; +import { labExamRequestRoutes } from "./routes/labExamRequest"; +import { medicalRoutes } from "./routes/medicals"; +import { medicalTypesRoutes } from "./routes/medicalTypes"; +import { opdRoutes } from "./routes/opd"; +import { operationRoutes } from "./routes/operations"; import { operationTypeRoutes } from "./routes/operationTypes"; +import { patientRoutes } from "./routes/patients"; +import { pregnantTreatmentTypeRoutes } from "./routes/pregnantTreatmentType"; +import { pricesRoutes } from "./routes/prices"; +import { suppliersRoutes } from "./routes/suppliers"; +import { therapyRoutes } from "./routes/therapies"; +import { userGroupRoutes } from "./routes/userGroups"; +import { userRoutes } from "./routes/users"; import { vaccineRoutes } from "./routes/vaccine"; import { vaccineTypesRoutes } from "./routes/vaccineTypes"; -import { deliveryTypesRoutes } from "./routes/deliveryTypes"; -import { suppliersRoutes } from "./routes/suppliers"; -import { medicalTypesRoutes } from "./routes/medicalTypes"; -import { pregnantTreatmentTypeRoutes } from "./routes/pregnantTreatmentType"; -import { deliveryResultTypeRoutes } from "./routes/deliveryResultType"; +import { visitRoutes } from "./routes/visits"; +import { wardsRoutes } from "./routes/wards"; export function makeServer() { Polly.register(XHRAdapter); @@ -76,6 +77,7 @@ export function makeServer() { medicalTypesRoutes(server); pregnantTreatmentTypeRoutes(server); deliveryResultTypeRoutes(server); + labExamRequestRoutes(server); }); return server; } diff --git a/src/routes/MainRouter.tsx b/src/routes/MainRouter.tsx index 4b9759656..475b82bef 100644 --- a/src/routes/MainRouter.tsx +++ b/src/routes/MainRouter.tsx @@ -24,7 +24,7 @@ export const MainRouter: React.FC = () => { if (status === "SUCCESS") { dispatch(getUserSettings()); } - }, [status]); + }, [dispatch, status]); const RequiredAdminAccess = withPermission( "admin.access", diff --git a/src/styles/index.scss b/src/styles/index.scss index e0d627f65..5d0229f6f 100644 --- a/src/styles/index.scss +++ b/src/styles/index.scss @@ -9,7 +9,7 @@ .App { & > div { - height: 100vh; + min-height: 100vh; } [class*="Form"],