Skip to content

Commit

Permalink
OH2-385 | Code improvement: equality check, unused imports, missing d…
Browse files Browse the repository at this point in the history
…ependencies,... (#668)

* fix:eslint warings - unused imports, exhaustive deps, ...

* fix:fix caniuse and browserlit

* fix:patient discharge
  • Loading branch information
SilverD3 authored Oct 8, 2024
1 parent f9be3b1 commit d0dbfc3
Show file tree
Hide file tree
Showing 96 changed files with 376 additions and 441 deletions.
54 changes: 31 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@date-io/date-fns": "^1.3.13",
"@emotion/react": "^11.13.0",
"@emotion/styled": "^11.13.0",
Expand Down
3 changes: 1 addition & 2 deletions src/components/Private.js
Original file line number Diff line number Diff line change
@@ -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() ? <Outlet /> : <Navigate to={PATHS.login} replace />;
};
13 changes: 5 additions & 8 deletions src/components/accessories/admin/diseases/Diseases.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const EditSupplier = () => {
if (state?.supId !== Number(id)) {
navigate(PATHS.admin_suppliers);
}
}, [id, state]);
}, [id, navigate, state]);

return (
<SupplierForm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ import TextField from "../../../textField/TextField";
import "./styles.scss";
import { ISupplierFormProps } from "./types";

const FORMAT = /^([0-9]{3})?[0-9]{2,10}$/;

const SupplierForm: FC<ISupplierFormProps> = ({
fields,
onSubmit,
Expand Down
10 changes: 7 additions & 3 deletions src/components/accessories/admin/types/TypesAdmin.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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<TypeOption>(defaultTypeOption);
const mode = useAppSelector((state) => state.types.config.mode);
Expand Down Expand Up @@ -57,7 +61,7 @@ const TypesAdmin = () => {
setSelectedOption(defaultTypeOption);
}
}
}, [location]);
}, [defaultTypeOption, location, typeOptions]);

const handleTypeChange = (value: string) => {
if (value?.length > 0) {
Expand Down
6 changes: 3 additions & 3 deletions src/components/accessories/admission/PatientAdmission.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -157,7 +157,7 @@ const PatientAdmission: FC = () => {
dispatch(getPatient(id!!));
dispatch(getCurrentAdmission(parseInt(id!!)));
}
}, [createStatus, updateStatus]);
}, [createStatus, dispatch, id, updateStatus]);

const resetFormCallback = () => {
setCreationMode(true);
Expand All @@ -173,7 +173,7 @@ const PatientAdmission: FC = () => {
return () => {
dispatch(getCurrentAdmissionReset());
};
}, [dispatch]);
}, [dispatch, id]);

const onEdit = (row: AdmissionDTO) => {
setAdmissionToEdit(row);
Expand Down
2 changes: 1 addition & 1 deletion src/components/accessories/appHeader/AppHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const AppHeader: FunctionComponent<IOwnProps> = ({ breadcrumbMap }) => {
);
useEffect(() => {
dispatch(getHospital());
}, [dispatch, getHospital]);
}, [dispatch]);

const hospital = useAppSelector(
(state) => state.hospital.getHospital.data
Expand Down
1 change: 0 additions & 1 deletion src/components/accessories/appHeader/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { TUserCredentials } from "../../../state/main/types";
import { TAPIResponseStatus } from "../../../state/types";

export type TBreadcrumbMap = Record<string, string>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import _ from "lodash";
import React, {
ChangeEvent,
FC,
Fragment,
useCallback,
useEffect,
useState,
Expand Down Expand Up @@ -76,6 +75,7 @@ const AutocompleteField: FC<IProps> = ({
}
};

// eslint-disable-next-line react-hooks/exhaustive-deps
const debounceUpdate = useCallback(
debounce((value: any) => {
setValue(value);
Expand Down Expand Up @@ -111,16 +111,6 @@ const AutocompleteField: FC<IProps> = ({
return option.label;
};

const isSelected = (option: DefaultOptionType, v: DefaultOptionType) => {
return option.value === v.value;
};

const rendOption = (props: any, option: DefaultOptionType | string) => {
return (
<Fragment>{typeof option === "string" ? option : option.label}</Fragment>
);
};

const filter = createFilterOptions<DefaultOptionType>({
limit: options_limit,
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/accessories/billTable/BillTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const BillTable: FC<IBillTableProps> = ({ fields }) => {
dispatch(searchBills(filter));
break;
}
}, [filter]);
}, [dispatch, filter]);

const { setFieldValue, handleBlur } = formik;

Expand Down
4 changes: 2 additions & 2 deletions src/components/accessories/billrecords/BillRecords.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const BillRecords = () => {
dispatch(deleteBillReset());
dispatch(payBillReset());
dispatch(closeBillReset());
}, []);
}, [dispatch]);

useEffect(() => {
if (patient && patient.code) {
Expand Down Expand Up @@ -275,7 +275,7 @@ const BillRecords = () => {
}}
handleSecondaryButtonClick={() => ({})}
/>
<iframe id="ifmcontentstoprint"></iframe>
<iframe id="ifmcontentstoprint" title="ifmcontentstoprint"></iframe>
</div>
);
};
Expand Down
Loading

0 comments on commit d0dbfc3

Please sign in to comment.