diff --git a/src/Utils/Notifications.js b/src/Utils/Notifications.js index 87de7991a6e..ce57ab5edd9 100644 --- a/src/Utils/Notifications.js +++ b/src/Utils/Notifications.js @@ -1,6 +1,6 @@ import { alert, Stack, defaultModules } from "@pnotify/core"; import * as PNotifyMobile from "@pnotify/mobile"; -import _ from "lodash-es"; +import { startCase, camelCase } from "lodash-es"; defaultModules.set(PNotifyMobile, {}); @@ -44,7 +44,7 @@ const notifyError = (error) => { errorMsg = error.detail; } else { for (let [key, value] of Object.entries(error)) { - let keyName = _.startCase(_.camelCase(key)); + let keyName = startCase(camelCase(key)); if (Array.isArray(value)) { const uniques = [...new Set(value)]; errorMsg += `${keyName} - ${uniques.splice(0, 5).join(", ")}`; diff --git a/src/components/Common/ExcelFIleDragAndDrop.tsx b/src/components/Common/ExcelFIleDragAndDrop.tsx index 566c8d0e600..d79cab62d34 100644 --- a/src/components/Common/ExcelFIleDragAndDrop.tsx +++ b/src/components/Common/ExcelFIleDragAndDrop.tsx @@ -1,4 +1,4 @@ -import * as _ from "lodash-es"; +import { forIn } from "lodash-es"; import { useEffect, useRef, useState } from "react"; import * as Notification from "../../Utils/Notifications"; import { useTranslation } from "react-i18next"; @@ -63,7 +63,7 @@ export default function ExcelFileDragAndDrop({ const data = XLSX.utils.sheet_to_json(worksheet, { defval: "" }); //converts the date to string data.forEach((row: any) => { - _.forIn(row, (value: any, key: string) => { + forIn(row, (value: any, key: string) => { if (value instanceof Date) { row[key] = value.toISOString().split("T")[0]; } diff --git a/src/components/Facility/Investigations/InvestigationsPrintPreview.tsx b/src/components/Facility/Investigations/InvestigationsPrintPreview.tsx index 107b0831bed..56f6f4a14e5 100644 --- a/src/components/Facility/Investigations/InvestigationsPrintPreview.tsx +++ b/src/components/Facility/Investigations/InvestigationsPrintPreview.tsx @@ -1,4 +1,3 @@ -import * as _ from "lodash-es"; import { lazy } from "react"; import routes from "../../../Redux/api"; import useQuery from "../../../Utils/request/useQuery"; diff --git a/src/components/Facility/Investigations/Reports/index.tsx b/src/components/Facility/Investigations/Reports/index.tsx index e4e54c36994..246d50f94bd 100644 --- a/src/components/Facility/Investigations/Reports/index.tsx +++ b/src/components/Facility/Investigations/Reports/index.tsx @@ -1,7 +1,7 @@ import { useCallback, useReducer, useState } from "react"; import { InvestigationGroup, InvestigationType } from ".."; -import _ from "lodash"; +import { chain } from "lodash-es"; import { useTranslation } from "react-i18next"; import routes from "../../../../Redux/api"; import * as Notification from "../../../../Utils/Notifications"; @@ -172,7 +172,7 @@ const InvestigationReports = ({ id }: any) => { ), ); - const investigationList = _.chain(data) + const investigationList = chain(data) .flatMap((i) => i?.data?.results) .compact() .flatten() diff --git a/src/components/Facility/Investigations/Reports/utils.tsx b/src/components/Facility/Investigations/Reports/utils.tsx index c6c6a0f6d45..eed1afc571e 100644 --- a/src/components/Facility/Investigations/Reports/utils.tsx +++ b/src/components/Facility/Investigations/Reports/utils.tsx @@ -1,8 +1,8 @@ -import * as _ from "lodash-es"; +import { memoize, chain, findIndex } from "lodash-es"; import { InvestigationResponse } from "./types"; -export const transformData = _.memoize((data: InvestigationResponse) => { - const sessions = _.chain(data) +export const transformData = memoize((data: InvestigationResponse) => { + const sessions = chain(data) .map((value: any) => { return { ...value.session_object, @@ -13,14 +13,14 @@ export const transformData = _.memoize((data: InvestigationResponse) => { .uniqBy("session_external_id") .orderBy("session_created_date", "desc") .value(); - const groupByInvestigation = _.chain(data) + const groupByInvestigation = chain(data) .groupBy("investigation_object.external_id") .values() .value(); const reqData = groupByInvestigation.map((value: any) => { const sessionValues = Array.from({ length: sessions.length }); value.forEach((val: any) => { - const sessionIndex = _.findIndex(sessions, [ + const sessionIndex = findIndex(sessions, [ "session_external_id", val.session_object.session_external_id, ]); @@ -59,7 +59,7 @@ export const transformData = _.memoize((data: InvestigationResponse) => { return { sessions, data: reqData }; }); -export const getColorIndex = _.memoize( +export const getColorIndex = memoize( ({ max, min, value }: { min?: number; max?: number; value?: number }) => { if (!max && min && value) { // 1 => yellow color diff --git a/src/components/Facility/Investigations/ShowInvestigation.tsx b/src/components/Facility/Investigations/ShowInvestigation.tsx index 0755b3687cd..00fe2c33549 100644 --- a/src/components/Facility/Investigations/ShowInvestigation.tsx +++ b/src/components/Facility/Investigations/ShowInvestigation.tsx @@ -1,4 +1,4 @@ -import * as _ from "lodash-es"; +import { set, chain } from "lodash-es"; import { useCallback, useReducer } from "react"; import routes from "../../../Redux/api"; import * as Notification from "../../../Utils/Notifications"; @@ -89,7 +89,7 @@ export default function ShowInvestigation(props: ShowInvestigationProps) { const handleValueChange = (value: any, name: string) => { const changedFields = { ...state.changedFields }; - _.set(changedFields, name, value); + set(changedFields, name, value); dispatch({ type: "set_changed_fields", changedFields }); }; @@ -147,7 +147,7 @@ export default function ShowInvestigation(props: ShowInvestigationProps) { }; const handleUpdateCancel = useCallback(() => { - const changedValues = _.chain(state.initialValues) + const changedValues = chain(state.initialValues) .map((val: any, _key: string) => ({ id: val?.id, initialValue: val?.notes || val?.value || null, diff --git a/src/components/Patient/PatientRegister.tsx b/src/components/Patient/PatientRegister.tsx index 6aab7799772..a3a8287dd34 100644 --- a/src/components/Patient/PatientRegister.tsx +++ b/src/components/Patient/PatientRegister.tsx @@ -59,7 +59,7 @@ import Spinner from "@/components/Common/Spinner"; import TextAreaFormField from "../Form/FormFields/TextAreaFormField"; import TextFormField from "../Form/FormFields/TextFormField"; import TransferPatientDialog from "../Facility/TransferPatientDialog"; -import _ from "lodash"; +import { startCase, toLower } from "lodash-es"; import countryList from "@/common/static/countries.json"; import { debounce } from "lodash-es"; import request from "../../Utils/request/request"; @@ -635,7 +635,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { ? formData.last_vaccinated_date : null : null, - name: _.startCase(_.toLower(formData.name)), + name: startCase(toLower(formData.name)), pincode: formData.pincode ? formData.pincode : undefined, gender: Number(formData.gender), nationality: formData.nationality, diff --git a/src/components/Patient/SampleDetails.tsx b/src/components/Patient/SampleDetails.tsx index 2e8b93c7bb4..aaf524ef0ae 100644 --- a/src/components/Patient/SampleDetails.tsx +++ b/src/components/Patient/SampleDetails.tsx @@ -5,7 +5,7 @@ import ButtonV2 from "@/components/Common/components/ButtonV2"; import Card from "../../CAREUI/display/Card"; import { FileUpload } from "../Files/FileUpload"; import Page from "@/components/Common/components/Page"; -import * as _ from "lodash-es"; +import { startCase, camelCase, capitalize } from "lodash-es"; import { formatDateTime, formatPatientAge } from "../../Utils/utils"; import { navigate } from "raviger"; @@ -244,11 +244,11 @@ export const SampleDetails = ({ id }: DetailRoute) => {