From 6d17f578cf08b1c717a17e38c3e0a06703fb9255 Mon Sep 17 00:00:00 2001 From: Gokulram A Date: Sun, 16 Oct 2022 10:20:39 +0530 Subject: [PATCH 1/6] Added component to replace MUI's Accordion component --- .../Common/components/AccordionTW.tsx | 79 +++++++++++++++++++ .../components/ResponsiveMedicineTables.tsx | 68 ++++++++-------- .../Common/components/SelectMenu.tsx | 9 ++- src/Components/Facility/HospitalList.tsx | 74 ++++++++++++----- src/Components/Patient/PatientRegister.tsx | 35 ++++---- 5 files changed, 193 insertions(+), 72 deletions(-) create mode 100644 src/Components/Common/components/AccordionTW.tsx diff --git a/src/Components/Common/components/AccordionTW.tsx b/src/Components/Common/components/AccordionTW.tsx new file mode 100644 index 00000000000..b42d865b622 --- /dev/null +++ b/src/Components/Common/components/AccordionTW.tsx @@ -0,0 +1,79 @@ +import React, { useState } from "react"; + +export default function AccordionTW(props: { + children: JSX.Element[]; + expandIcon: JSX.Element; + className?: string; +}) { + const [toggle, setToggle] = useState(false); + const contentEl = React.useRef(null); + + return ( +
+
+ + +
+
+ {React.Children.map(props.children, (child) => { + if (child.type.displayName === "AccordionDetailsTW") { + return child; + } + })} +
+
+ ); +} + +interface Props { + children: JSX.Element | JSX.Element[]; +} + +export class AccordionSummaryTW extends React.Component { + static displayName = "AccordionSummaryTW"; + render() { + return <>{this.props.children}; + } +} +export class AccordionDetailsTW extends React.Component { + static displayName = "AccordionDetailsTW"; + render() { + return <>{this.props.children}; + } +} diff --git a/src/Components/Common/components/ResponsiveMedicineTables.tsx b/src/Components/Common/components/ResponsiveMedicineTables.tsx index 7500b9f4efa..c25dd5fe630 100644 --- a/src/Components/Common/components/ResponsiveMedicineTables.tsx +++ b/src/Components/Common/components/ResponsiveMedicineTables.tsx @@ -1,9 +1,8 @@ -import { - Accordion, - AccordionDetails, - AccordionSummary, -} from "@material-ui/core"; import { useEffect, useState } from "react"; +import AccordionTW, { + AccordionDetailsTW, + AccordionSummaryTW, +} from "./AccordionTW"; function getWindowSize() { const { innerWidth, innerHeight } = window; @@ -67,28 +66,31 @@ export default function ResponsiveMedicineTable(props: { ) : (
{props.list.map((med: any, index: number) => ( - - - - - } - aria-controls={`panel${index + 1}a-content`} - id={`panel${index + 1}a-header`} - > + + + + } + key={index} + > +

@@ -106,10 +108,10 @@ export default function ResponsiveMedicineTable(props: { ))}

-
- -
-
+ + +
+
{props.objectKeys.map((key, i) => { if (i !== 0 && i !== props.objectKeys.length - 1) return ( @@ -133,8 +135,8 @@ export default function ResponsiveMedicineTable(props: { })}
- - +
+ ))}
)} diff --git a/src/Components/Common/components/SelectMenu.tsx b/src/Components/Common/components/SelectMenu.tsx index 3a2f1fa3fea..8869916cf99 100644 --- a/src/Components/Common/components/SelectMenu.tsx +++ b/src/Components/Common/components/SelectMenu.tsx @@ -12,6 +12,7 @@ type Props = { selected?: T; label?: string; position?: string; + parentRelative?: boolean; }; export default function SelectMenu(props: Props) { @@ -34,7 +35,13 @@ export default function SelectMenu(props: Props) { {({ open }) => ( <> {props.label} -
+
diff --git a/src/Components/Facility/HospitalList.tsx b/src/Components/Facility/HospitalList.tsx index 2fb4e4ff71b..55e7eec8f2f 100644 --- a/src/Components/Facility/HospitalList.tsx +++ b/src/Components/Facility/HospitalList.tsx @@ -22,18 +22,24 @@ import { sendNotificationMessages, } from "../../Redux/actions"; import loadable from "@loadable/component"; -import { InputLabel, TextField } from "@material-ui/core"; + +import { + AccordionSummary, + AccordionDetails, + InputLabel, + TextField, +} from "@material-ui/core"; import Pagination from "../Common/Pagination"; import { FacilityModel } from "./models"; import { InputSearchBox } from "../Common/SearchBox"; import { CSVLink } from "react-csv"; import moment from "moment"; import { Theme, createStyles, makeStyles } from "@material-ui/core/styles"; -import Accordion from "@material-ui/core/Accordion"; import CircularProgress from "@material-ui/core/CircularProgress"; -import AccordionSummary from "@material-ui/core/AccordionSummary"; -import AccordionDetails from "@material-ui/core/AccordionDetails"; -import Typography from "@material-ui/core/Typography"; +import { + AccordionDetailsTW, + AccordionSummaryTW, +} from "../Common/components/AccordionTW"; import ExpandMoreIcon from "@material-ui/icons/ExpandMore"; import GetAppIcon from "@material-ui/icons/GetApp"; import { make as SlideOver } from "../Common/SlideOver.gen"; @@ -42,6 +48,7 @@ import { useTranslation } from "react-i18next"; import * as Notification from "../../Utils/Notifications.js"; import { Modal } from "@material-ui/core"; import SelectMenu from "../Common/components/SelectMenu"; +import AccordionTW from "../Common/components/AccordionTW"; const Loading = loadable(() => import("../Common/Loading")); const PageTitle = loadable(() => import("../Common/PageTitle")); @@ -558,19 +565,16 @@ export const HospitalList = (props: any) => {
- - } - aria-controls="panel1a-content" - id="panel1a-header" - > - - {t("downloads")} - - - -
- + } + > + +

Downloads

+
+ +
+ {t("download_type")}
@@ -583,7 +587,8 @@ export const HospitalList = (props: any) => { ]} selected={downloadSelect} onSelect={setdownloadSelect} - position="right" + position="left" + parentRelative={false} /> {downloadLoading ? (
@@ -630,8 +635,8 @@ export const HospitalList = (props: any) => { id="triageDownloader" >
- - + +
@@ -704,6 +709,33 @@ export const HospitalList = (props: any) => {
+ + + + + } + > + +

Hello Title

+
+ +

Hello World

+
+
+
diff --git a/src/Components/Patient/PatientRegister.tsx b/src/Components/Patient/PatientRegister.tsx index cde439e9dd8..11141ac6ffc 100644 --- a/src/Components/Patient/PatientRegister.tsx +++ b/src/Components/Patient/PatientRegister.tsx @@ -1,7 +1,4 @@ import { - Accordion, - AccordionDetails, - AccordionSummary, Box, Card, CardContent, @@ -59,11 +56,16 @@ import { validatePincode } from "../../Common/validation"; import { InfoOutlined } from "@material-ui/icons"; import ExpandMoreIcon from "@material-ui/icons/ExpandMore"; import { goBack } from "../../Utils/utils"; +import AccordionTW, { + AccordionDetailsTW, + AccordionSummaryTW, +} from "../Common/components/AccordionTW"; const Loading = loadable(() => import("../Common/Loading")); const PageTitle = loadable(() => import("../Common/PageTitle")); -const debounce = require("lodash.debounce"); +import { debounce } from "lodash"; +// const debounce = require("lodash.debounce"); interface PatientRegisterProps extends PatientModel { facilityId: number; @@ -1429,18 +1431,17 @@ export const PatientRegister = (props: PatientRegisterProps) => { - - } - aria-controls="panel1a-content" - id="panel1a-header" - > -

- Health Details + } + > + +

+ Health Detailsss

- - -
+ + +
{ />
- - +
+ From 30dd38c62492f0828748f520b3ea90b8a5248d48 Mon Sep 17 00:00:00 2001 From: Gokulram A Date: Sun, 16 Oct 2022 10:25:53 +0530 Subject: [PATCH 2/6] minor ui fix --- src/Components/Facility/HospitalList.tsx | 26 ------------------------ 1 file changed, 26 deletions(-) diff --git a/src/Components/Facility/HospitalList.tsx b/src/Components/Facility/HospitalList.tsx index 55e7eec8f2f..1bfec3a38d5 100644 --- a/src/Components/Facility/HospitalList.tsx +++ b/src/Components/Facility/HospitalList.tsx @@ -710,32 +710,6 @@ export const HospitalList = (props: any) => {

- - - - } - > - -

Hello Title

-
- -

Hello World

-
-
-
From 97f8256bc22c4bf34af45b935e5ea7546ba2f8b5 Mon Sep 17 00:00:00 2001 From: Gokulram A Date: Sun, 16 Oct 2022 13:35:41 +0530 Subject: [PATCH 3/6] Added AccordionV2 and CollapseV2 --- .../Common/components/AccordionTW.tsx | 79 ---------- .../Common/components/AccordionV2.tsx | 90 +++++++++++ .../Common/components/CollapseV2.tsx | 25 +++ .../components/ResponsiveMedicineTables.tsx | 93 +++++------ src/Components/Facility/HospitalList.tsx | 145 ++++++++---------- src/Components/Patient/PatientRegister.tsx | 56 +++---- 6 files changed, 238 insertions(+), 250 deletions(-) delete mode 100644 src/Components/Common/components/AccordionTW.tsx create mode 100644 src/Components/Common/components/AccordionV2.tsx create mode 100644 src/Components/Common/components/CollapseV2.tsx diff --git a/src/Components/Common/components/AccordionTW.tsx b/src/Components/Common/components/AccordionTW.tsx deleted file mode 100644 index b42d865b622..00000000000 --- a/src/Components/Common/components/AccordionTW.tsx +++ /dev/null @@ -1,79 +0,0 @@ -import React, { useState } from "react"; - -export default function AccordionTW(props: { - children: JSX.Element[]; - expandIcon: JSX.Element; - className?: string; -}) { - const [toggle, setToggle] = useState(false); - const contentEl = React.useRef(null); - - return ( -
-
- - -
-
- {React.Children.map(props.children, (child) => { - if (child.type.displayName === "AccordionDetailsTW") { - return child; - } - })} -
-
- ); -} - -interface Props { - children: JSX.Element | JSX.Element[]; -} - -export class AccordionSummaryTW extends React.Component { - static displayName = "AccordionSummaryTW"; - render() { - return <>{this.props.children}; - } -} -export class AccordionDetailsTW extends React.Component { - static displayName = "AccordionDetailsTW"; - render() { - return <>{this.props.children}; - } -} diff --git a/src/Components/Common/components/AccordionV2.tsx b/src/Components/Common/components/AccordionV2.tsx new file mode 100644 index 00000000000..f2c03f2d51f --- /dev/null +++ b/src/Components/Common/components/AccordionV2.tsx @@ -0,0 +1,90 @@ +import React, { useState } from "react"; + +export default function AccordionV2(props: { + children: JSX.Element | JSX.Element[]; + expandIcon?: JSX.Element; + title: JSX.Element | JSX.Element[] | string; + className?: string; + expanded?: boolean; +}) { + const [toggle, setToggle] = useState(props.expanded as boolean); + const contentEl = React.useRef(null); + + return ( +
+
+ + +
+
+ {props.children} +
+
+ ); +} + +// interface Props { +// children: JSX.Element | JSX.Element[]; +// } + +// export class AccordionSummaryV2 extends React.Component { +// static displayName = "AccordionSummaryV2"; +// render() { +// return <>{this.props.children}; +// } +// } +// export class AccordionDetailsV2 extends React.Component { +// static displayName = "AccordionDetailsV2"; +// render() { +// return <>{this.props.children}; +// } +// } diff --git a/src/Components/Common/components/CollapseV2.tsx b/src/Components/Common/components/CollapseV2.tsx new file mode 100644 index 00000000000..babf1e27f9c --- /dev/null +++ b/src/Components/Common/components/CollapseV2.tsx @@ -0,0 +1,25 @@ +import React from "react"; + +export default function CollapseV2(props: { + children: JSX.Element | JSX.Element[]; + opened: boolean; + className?: string; +}) { + const content = React.useRef(null); + + return ( +
+ {props.children} +
+ ); +} diff --git a/src/Components/Common/components/ResponsiveMedicineTables.tsx b/src/Components/Common/components/ResponsiveMedicineTables.tsx index c25dd5fe630..271563a4d2f 100644 --- a/src/Components/Common/components/ResponsiveMedicineTables.tsx +++ b/src/Components/Common/components/ResponsiveMedicineTables.tsx @@ -1,8 +1,5 @@ import { useEffect, useState } from "react"; -import AccordionTW, { - AccordionDetailsTW, - AccordionSummaryTW, -} from "./AccordionTW"; +import AccordionV2 from "./AccordionV2"; function getWindowSize() { const { innerWidth, innerHeight } = window; @@ -66,34 +63,11 @@ export default function ResponsiveMedicineTable(props: { ) : (
{props.list.map((med: any, index: number) => ( - - - - } - key={index} - > - +
-

+

{med[props.objectKeys[0]]}

@@ -108,35 +82,40 @@ export default function ResponsiveMedicineTable(props: { ))}
- - -
-
- {props.objectKeys.map((key, i) => { - if (i !== 0 && i !== props.objectKeys.length - 1) - return ( -
-

- {props.theads[i]} -

{" "} -

{med[key]}

-
- ); + } + className={ + props.list.length - 1 === index + ? "bg-white p-5 " + : "bg-white p-5 border-b border-b-gray-400" + } + key={index} + > +
+
+ {props.objectKeys.map((key, i) => { + if (i !== 0 && i !== props.objectKeys.length - 1) + return ( +
+

+ {props.theads[i]} +

{" "} +

{med[key]}

+
+ ); - if (i === props.objectKeys.length - 1) - return ( -
-

- {props.theads[i]} -

{" "} -

{med[key]}

-
- ); - })} -
+ if (i === props.objectKeys.length - 1) + return ( +
+

+ {props.theads[i]} +

{" "} +

{med[key]}

+
+ ); + })}
- - +
+ ))}
)} diff --git a/src/Components/Facility/HospitalList.tsx b/src/Components/Facility/HospitalList.tsx index 1bfec3a38d5..fdf7b5fb129 100644 --- a/src/Components/Facility/HospitalList.tsx +++ b/src/Components/Facility/HospitalList.tsx @@ -23,12 +23,7 @@ import { } from "../../Redux/actions"; import loadable from "@loadable/component"; -import { - AccordionSummary, - AccordionDetails, - InputLabel, - TextField, -} from "@material-ui/core"; +import { InputLabel, TextField } from "@material-ui/core"; import Pagination from "../Common/Pagination"; import { FacilityModel } from "./models"; import { InputSearchBox } from "../Common/SearchBox"; @@ -36,10 +31,6 @@ import { CSVLink } from "react-csv"; import moment from "moment"; import { Theme, createStyles, makeStyles } from "@material-ui/core/styles"; import CircularProgress from "@material-ui/core/CircularProgress"; -import { - AccordionDetailsTW, - AccordionSummaryTW, -} from "../Common/components/AccordionTW"; import ExpandMoreIcon from "@material-ui/icons/ExpandMore"; import GetAppIcon from "@material-ui/icons/GetApp"; import { make as SlideOver } from "../Common/SlideOver.gen"; @@ -48,7 +39,7 @@ import { useTranslation } from "react-i18next"; import * as Notification from "../../Utils/Notifications.js"; import { Modal } from "@material-ui/core"; import SelectMenu from "../Common/components/SelectMenu"; -import AccordionTW from "../Common/components/AccordionTW"; +import AccordionV2 from "../Common/components/AccordionV2"; const Loading = loadable(() => import("../Common/Loading")); const PageTitle = loadable(() => import("../Common/PageTitle")); @@ -565,78 +556,74 @@ export const HospitalList = (props: any) => {
- Downloads

} className="lg:mt-0 md:mt-0 sm:mt-0 bg-white shadow-md rounded-lg p-3 relative" expandIcon={} > - -

Downloads

-
- -
- - {t("download_type")} - -
- ({ - title: download, - value: download, - })), - ]} - selected={downloadSelect} - onSelect={setdownloadSelect} - position="left" - parentRelative={false} - /> - {downloadLoading ? ( -
- -
- ) : ( - - )} -
-
-
- - - - +
+ + {t("download_type")} + +
+ ({ + title: download, + value: download, + })), + ]} + selected={downloadSelect} + onSelect={setdownloadSelect} + position="left" + parentRelative={false} + /> + {downloadLoading ? ( +
+ +
+ ) : ( + + )}
- - +
+
+ + + + +
+
diff --git a/src/Components/Patient/PatientRegister.tsx b/src/Components/Patient/PatientRegister.tsx index 11141ac6ffc..88f93e6d985 100644 --- a/src/Components/Patient/PatientRegister.tsx +++ b/src/Components/Patient/PatientRegister.tsx @@ -3,7 +3,6 @@ import { Card, CardContent, CircularProgress, - Collapse, FormControlLabel, InputLabel, Radio, @@ -56,14 +55,11 @@ import { validatePincode } from "../../Common/validation"; import { InfoOutlined } from "@material-ui/icons"; import ExpandMoreIcon from "@material-ui/icons/ExpandMore"; import { goBack } from "../../Utils/utils"; -import AccordionTW, { - AccordionDetailsTW, - AccordionSummaryTW, -} from "../Common/components/AccordionTW"; const Loading = loadable(() => import("../Common/Loading")); const PageTitle = loadable(() => import("../Common/PageTitle")); - +import AccordionV2 from "../Common/components/AccordionV2"; +import CollapseV2 from "../Common/components/CollapseV2"; import { debounce } from "lodash"; // const debounce = require("lodash.debounce"); @@ -1142,11 +1138,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { />
- + {
{
} -
+
{ - } - > - + title={

- Health Detailsss + Health Details

-
- + } + > +
{ /> -
@@ -1533,7 +1523,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { disableFuture={true} />
-
+
@@ -1565,10 +1555,8 @@ export const PatientRegister = (props: PatientRegisterProps) => {
- {
@@ -1671,7 +1659,7 @@ export const PatientRegister = (props: PatientRegisterProps) => {
} - +
Contact with confirmed Covid patient? @@ -1725,8 +1713,8 @@ export const PatientRegister = (props: PatientRegisterProps) => {
- { state.form.contact_with_suspected_carrier ) } - timeout="auto" - unmountOnExit >
@@ -1784,7 +1770,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { />
-
+
{ />
-
-
+
+ From dae15063febb1701097b7b679d8d34e7f1c5236c Mon Sep 17 00:00:00 2001 From: Gokulram A Date: Sun, 16 Oct 2022 13:42:09 +0530 Subject: [PATCH 4/6] removed comments --- .../Common/components/AccordionV2.tsx | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/Components/Common/components/AccordionV2.tsx b/src/Components/Common/components/AccordionV2.tsx index f2c03f2d51f..2ab6303dfe4 100644 --- a/src/Components/Common/components/AccordionV2.tsx +++ b/src/Components/Common/components/AccordionV2.tsx @@ -71,20 +71,3 @@ export default function AccordionV2(props: {
); } - -// interface Props { -// children: JSX.Element | JSX.Element[]; -// } - -// export class AccordionSummaryV2 extends React.Component { -// static displayName = "AccordionSummaryV2"; -// render() { -// return <>{this.props.children}; -// } -// } -// export class AccordionDetailsV2 extends React.Component { -// static displayName = "AccordionDetailsV2"; -// render() { -// return <>{this.props.children}; -// } -// } From d693bc12500fff88c255c456773e87fb1646ec2e Mon Sep 17 00:00:00 2001 From: Gokulram A Date: Wed, 19 Oct 2022 17:43:02 +0530 Subject: [PATCH 5/6] patient registration fields alignment fix --- .../Common/components/CollapseV2.tsx | 43 ++++++++++++++++--- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/src/Components/Common/components/CollapseV2.tsx b/src/Components/Common/components/CollapseV2.tsx index babf1e27f9c..6552868b6ac 100644 --- a/src/Components/Common/components/CollapseV2.tsx +++ b/src/Components/Common/components/CollapseV2.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useEffect, useState } from "react"; export default function CollapseV2(props: { children: JSX.Element | JSX.Element[]; @@ -6,20 +6,49 @@ export default function CollapseV2(props: { className?: string; }) { const content = React.useRef(null); + const [innerDivState, setInnerDivState] = useState(false); + const [outerDivState, setOuterDivState] = useState(false); + + useEffect(() => { + if (props.opened) { + setOuterDivState(props.opened); + setTimeout(() => { + setInnerDivState(props.opened); + }, 1); + } else { + setInnerDivState(props.opened); + setTimeout(() => { + setOuterDivState(props.opened); + }, 300); + } + }, [props.opened]); return (
- {props.children} +
+ {props.children} +
); } From f8bf2d78161ac5f7da6d1d2c6be632a508f5e980 Mon Sep 17 00:00:00 2001 From: Gokulram A Date: Fri, 21 Oct 2022 18:33:22 +0530 Subject: [PATCH 6/6] fixed accordion max height issue --- src/Components/Common/components/AccordionV2.tsx | 8 ++++---- src/Components/Patient/PatientRegister.tsx | 5 ++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Components/Common/components/AccordionV2.tsx b/src/Components/Common/components/AccordionV2.tsx index 2ab6303dfe4..e2b4ca54d93 100644 --- a/src/Components/Common/components/AccordionV2.tsx +++ b/src/Components/Common/components/AccordionV2.tsx @@ -54,16 +54,16 @@ export default function AccordionV2(props: {
{props.children} diff --git a/src/Components/Patient/PatientRegister.tsx b/src/Components/Patient/PatientRegister.tsx index 027460253e1..fc47eef9fc5 100644 --- a/src/Components/Patient/PatientRegister.tsx +++ b/src/Components/Patient/PatientRegister.tsx @@ -64,7 +64,6 @@ import CollapseV2 from "../Common/components/CollapseV2"; import { debounce } from "lodash"; // const debounce = require("lodash.debounce"); - interface PatientRegisterProps extends PatientModel { facilityId: number; } @@ -1595,7 +1594,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { onChange={handleChange} style={{ padding: "0px 5px" }} > - +
} @@ -1611,7 +1610,7 @@ export const PatientRegister = (props: PatientRegisterProps) => { control={} label="3 (Booster/Precautionary Dose)" /> - +