From f3cf6cff5ebe1d29813c6794388ef06a44ddbef9 Mon Sep 17 00:00:00 2001 From: Aakash Singh Date: Mon, 11 Nov 2024 21:43:39 +0530 Subject: [PATCH] Revert "[production-patch] Fix investigations crashes and same day discharge" (#9085) This reverts commit c5e9b5ddbbe3bb960d9fc359cf35ef28cdc60c4c. --- src/components/Common/DateInputV2.tsx | 10 ---------- .../Facility/Investigations/Reports/index.tsx | 4 ++-- .../Facility/Investigations/Reports/utils.tsx | 7 +++---- .../Facility/Investigations/ShowInvestigation.tsx | 5 ++--- 4 files changed, 7 insertions(+), 19 deletions(-) diff --git a/src/components/Common/DateInputV2.tsx b/src/components/Common/DateInputV2.tsx index 627abdcf327..87a29debe5b 100644 --- a/src/components/Common/DateInputV2.tsx +++ b/src/components/Common/DateInputV2.tsx @@ -190,16 +190,6 @@ const DateInputV2: React.FC = ({ year = datePickerHeaderDate.getFullYear(), ) => { const date = new Date(year, month, day); - if ( - min && - max && - min.getDate() === max.getDate() && - day === min.getDate() && - month === min.getMonth() && - year === min.getFullYear() - ) { - return true; - } if (min) if (date < min) return false; if (max) if (date > max) return false; return true; 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 3c01cf8bba4..eed1afc571e 100644 --- a/src/components/Facility/Investigations/Reports/utils.tsx +++ b/src/components/Facility/Investigations/Reports/utils.tsx @@ -1,9 +1,8 @@ -import _ from "lodash"; -import { memoize, findIndex } from "lodash-es"; +import { memoize, chain, findIndex } from "lodash-es"; import { InvestigationResponse } from "./types"; export const transformData = memoize((data: InvestigationResponse) => { - const sessions = _.chain(data) + const sessions = chain(data) .map((value: any) => { return { ...value.session_object, @@ -14,7 +13,7 @@ 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(); diff --git a/src/components/Facility/Investigations/ShowInvestigation.tsx b/src/components/Facility/Investigations/ShowInvestigation.tsx index f923d2bb2da..00fe2c33549 100644 --- a/src/components/Facility/Investigations/ShowInvestigation.tsx +++ b/src/components/Facility/Investigations/ShowInvestigation.tsx @@ -1,5 +1,4 @@ -import _ from "lodash"; -import { set } 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"; @@ -148,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,