Skip to content

Commit

Permalink
Phani | A - 1206804799445947 | Update IPD & CareViewDashboard Header …
Browse files Browse the repository at this point in the history
…with the navigations links and profile actions (#165)

* Phani : Remove patient dashboard link from Patient Header

* Phani : Refactor redirection link to open in same tab

* Phani : Add Navigation icons & links in Header

* Phani : Add hover state for icons

* Phani : Refactor CSS for User Actions, Change Password

* Phani : Update tests & snapshots

* Phani : Refactor based on feedbacks

* Phani : Update tests

* Phani : Update CSS for home dashboard icon in CareViewDashboard
  • Loading branch information
Phanindra-tw authored and Arjun-Go committed Apr 3, 2024
1 parent bb044fe commit 36cec0e
Show file tree
Hide file tree
Showing 21 changed files with 397 additions and 174 deletions.
4 changes: 2 additions & 2 deletions public/i18n/locale_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
"NON_MEDICATION_TASK_CONFIRMATION": "Please confirm the non-medication task",
"EMERGENCY_TASK_SAVE_MESSAGE": "Emergency Medication task created successfully.",
"NON_MEDICATION_TASK_SAVE_MESSAGE": "Non-Medication task created successfully.",
"PATIENT_DASHBOARD": "Patient Dashboard",
"VISIT_SUMMARY": "Visit Summaries",
"EDIT_DRUG_CHART": "Edit Drug Chart",
"DRUG_CHART_MODAL_EDIT_MESSAGE": "Medication task(s) updated successfully",
Expand All @@ -88,5 +87,6 @@
"TOTAL_TEXT": "Total",
"CURRENT_PERIOD": "Current Period",
"NOT_CURRENT_PERIOD_MESSAGE": "You're not viewing the current period",
"NO_IO_DATA_MESSAGE": "No intake output data is available for the patient in this period"
"NO_IO_DATA_MESSAGE": "No intake output data is available for the patient in this period",
"SCHEDULE_TREATMENTS": "Schedule Treatments"
}
70 changes: 70 additions & 0 deletions src/components/ProvideActions/ProviderActions.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import React, { useEffect, useState } from "react";
import {
Logout24,
UserAvatar24,
ChevronUp16,
ChevronDown16,
IbmCloudHyperProtectCryptoServices24,
} from "@carbon/icons-react";
import "./ProviderActions.scss";
import { FormattedMessage } from "react-intl";
import { getCookies } from "../../utils/CommonUtils";
import PropTypes from "prop-types";

export const ProviderActions = (props) => {
const { onLogOut } = props;
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
const cookies = getCookies();
const username = cookies["bahmni.user"]?.replace(/^"(.*)"$/, "$1");
const handleChangePassword = () => {
window.location = "/bahmni/home/#/changePassword";
};
const handleMenu = () => {
setIsDropdownOpen(!isDropdownOpen);
};
useEffect(() => {
const handleOutsideClick = (event) => {
if (!event.target.closest(".provider-actions")) {
setIsDropdownOpen(false);
}
};
window.addEventListener("click", handleOutsideClick);

return () => {
window.removeEventListener("click", handleOutsideClick);
};
}, []);

return (
<div className={"provider-actions"}>
<div>
<div
className={`provider-menu ${isDropdownOpen && "menu-selected"}`}
onClick={handleMenu}
>
<UserAvatar24 className={"user-avatar"} />
<div className={"username"}>{username}</div>
{isDropdownOpen ? <ChevronUp16 /> : <ChevronDown16 />}
</div>
{isDropdownOpen && (
<div className={"dropdown"}>
<div onClick={handleChangePassword}>
<IbmCloudHyperProtectCryptoServices24 />
<FormattedMessage
id={"CHANGE_PASSWORD"}
defaultMessage={"Change Password"}
/>
</div>
</div>
)}
</div>
<span onClick={onLogOut} className={"logout"}>
<Logout24 />
</span>
</div>
);
};

ProviderActions.propTypes = {
onLogOut: PropTypes.func.isRequired,
};
53 changes: 53 additions & 0 deletions src/components/ProvideActions/ProviderActions.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
.provider-actions {
display: flex;
align-items: center;
height: 3rem;
.options {
cursor: pointer;
padding: 0 8px;
height: 3rem;
display: flex;
align-items: center;
&:hover,
&:focus {
outline: none;
background-color: #004144;
}
}
.menu-selected {
background-color: #004144;
}
.provider-menu {
@extend .options;
}
.logout {
width: 50px;
justify-content: center;
box-sizing: border-box;
@extend .options;
}
.user-avatar {
margin-right: 8px;
}
.username {
max-width: 100px;
overflow: hidden;
text-overflow: ellipsis;
margin-right: 8px;
}
.dropdown {
position: absolute;
top: 3rem;
right: 3rem;
background-color: #004144;
cursor: pointer;
> * {
height: 3rem;
padding: 12px;
box-sizing: border-box;
display: flex;
align-items: center;
gap: 8px;
}
}
}
16 changes: 8 additions & 8 deletions src/entries/CareViewDashboard/CareViewDashboard.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from "react";
import PropTypes from "prop-types";
import { Header, Link, Loading } from "carbon-components-react";
import { Home20 } from "@carbon/icons-react";
import { Home24 } from "@carbon/icons-react";
import { ArrowLeft } from "@carbon/icons-react/next";
import _ from "lodash";
import "./CareViewDashboard.scss";
Expand All @@ -13,9 +13,11 @@ import { homePageUrl, WARD_SUMMARY_HEADER } from "../../constants";
import { CareViewContext } from "../../context/CareViewContext";
import { getConfigForCareViewDashboard } from "./CareViewDashboardUtils";
import { getDashboardConfig } from "../../utils/CommonUtils";
import { ProviderActions } from "../../components/ProvideActions/ProviderActions";

const CareViewDashboard = (props) => {
const { hostApi, hostData } = props;
const { onHome, onLogOut } = hostApi;
const [selectedWard, setSelectedWard] = useState({});
const [headerSelected, setHeaderSelected] = useState(
WARD_SUMMARY_HEADER.TOTAL_PATIENTS
Expand Down Expand Up @@ -54,12 +56,13 @@ const CareViewDashboard = (props) => {
<I18nProvider>
<main className="care-view-page">
<Header
className="border-bottom-0 header-bg-color"
className="border-bottom-0 header-bg-color care-view-header"
aria-label="IBM Platform Name"
>
<Link href={homePageUrl}>
<Home20 className="home" aria-label="home-button" />
<Link href={homePageUrl} className={"home"}>
<Home24 aria-label="home-button" />
</Link>
<ProviderActions onLogOut={onLogOut} />
</Header>

<section className="main">
Expand Down Expand Up @@ -87,10 +90,7 @@ const CareViewDashboard = (props) => {
size={20}
onClick={() => hostApi?.onHome()}
/>
<Link
className="ward-view-nav-link"
onClick={() => hostApi?.onHome()}
>
<Link className="ward-view-nav-link" onClick={onHome}>
<FormattedMessage
id={"WARD_LIST_VIEW_TEXT"}
defaultMessage="Ward List View"
Expand Down
20 changes: 18 additions & 2 deletions src/entries/CareViewDashboard/CareViewDashboard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,29 @@
height: 100%;
padding: 16px 0;
}
.care-view-header {
display: flex;
justify-content: space-between;
align-items: center;
height: 48px;
color: white;
}

.home {
background-color: #007d79;
fill: #ffffff;
color: #ffffff;
outline: none;
border: none;
margin-left: 16px;
padding: 12px 8px;
height: 3rem;
width: 50px;
justify-content: center;
&:hover,
&:focus {
outline: none;
background-color: #004144;
color: #fff;
}
}

.border-bottom-0 {
Expand Down
4 changes: 4 additions & 0 deletions src/entries/CareViewDashboard/CareViewDashboard.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ describe("CareViewDashboard", () => {
const { container, getByLabelText } = render(
<CareViewDashboard
hostData={{ provider: "c61c0d60-b483-4c6a-ad97-8cdec7d48b08" }}
hostApi={{ onHome: jest.fn(), onLogOut: jest.fn() }}
/>
);
await waitFor(() => {
Expand All @@ -110,6 +111,7 @@ describe("CareViewDashboard", () => {
const { getByLabelText } = render(
<CareViewDashboard
hostData={{ provider: "c61c0d60-b483-4c6a-ad97-8cdec7d48b08" }}
hostApi={{ onHome: jest.fn(), onLogOut: jest.fn() }}
/>
);
await waitFor(() => {
Expand All @@ -126,6 +128,7 @@ describe("CareViewDashboard", () => {
<CareViewContext.Provider value={mockContext}>
<CareViewDashboard
hostData={{ provider: "c61c0d60-b483-4c6a-ad97-8cdec7d48b08" }}
hostApi={{ onHome: jest.fn(), onLogOut: jest.fn() }}
/>
</CareViewContext.Provider>
);
Expand Down Expand Up @@ -166,6 +169,7 @@ describe("CareViewDashboard", () => {
<CareViewContext.Provider value={mockContext}>
<CareViewDashboard
hostData={{ provider: "c61c0d60-b483-4c6a-ad97-8cdec7d48b08" }}
hostApi={{ onHome: jest.fn(), onLogOut: jest.fn() }}
/>
</CareViewContext.Provider>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,94 @@ exports[`CareViewDashboard should match the snapshot 1`] = `
>
<header
aria-label="IBM Platform Name"
class="bx--header border-bottom-0 header-bg-color"
class="bx--header border-bottom-0 header-bg-color care-view-header"
>
<a
class="bx--link"
class="bx--link home"
href="/bahmni/home/#/dashboard"
>
<svg
aria-label="home-button"
class="home"
fill="currentColor"
focusable="false"
height="20"
height="24"
preserveAspectRatio="xMidYMid meet"
role="img"
viewBox="0 0 32 32"
width="20"
width="24"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M16.6123,2.2138a1.01,1.01,0,0,0-1.2427,0L1,13.4194l1.2427,1.5717L4,13.6209V26a2.0041,2.0041,0,0,0,2,2H26a2.0037,2.0037,0,0,0,2-2V13.63L29.7573,15,31,13.4282ZM18,26H14V18h4Zm2,0V18a2.0023,2.0023,0,0,0-2-2H14a2.002,2.002,0,0,0-2,2v8H6V12.0615l10-7.79,10,7.8005V26Z"
/>
</svg>
</a>
<div
class="provider-actions"
>
<div>
<div
class="provider-menu false"
>
<svg
aria-hidden="true"
class="user-avatar"
fill="currentColor"
focusable="false"
height="24"
preserveAspectRatio="xMidYMid meet"
viewBox="0 0 32 32"
width="24"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M16,8a5,5,0,1,0,5,5A5,5,0,0,0,16,8Zm0,8a3,3,0,1,1,3-3A3.0034,3.0034,0,0,1,16,16Z"
/>
<path
d="M16,2A14,14,0,1,0,30,16,14.0158,14.0158,0,0,0,16,2ZM10,26.3765V25a3.0033,3.0033,0,0,1,3-3h6a3.0033,3.0033,0,0,1,3,3v1.3765a11.8989,11.8989,0,0,1-12,0Zm13.9925-1.4507A5.0016,5.0016,0,0,0,19,20H13a5.0016,5.0016,0,0,0-4.9925,4.9258,12,12,0,1,1,15.985,0Z"
/>
</svg>
<div
class="username"
/>
<svg
aria-hidden="true"
fill="currentColor"
focusable="false"
height="16"
preserveAspectRatio="xMidYMid meet"
viewBox="0 0 16 16"
width="16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8 11L3 6 3.7 5.3 8 9.6 12.3 5.3 13 6z"
/>
</svg>
</div>
</div>
<span
class="logout"
>
<svg
aria-hidden="true"
fill="currentColor"
focusable="false"
height="24"
preserveAspectRatio="xMidYMid meet"
viewBox="0 0 32 32"
width="24"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M6,30H18a2.0023,2.0023,0,0,0,2-2V25H18v3H6V4H18V7h2V4a2.0023,2.0023,0,0,0-2-2H6A2.0023,2.0023,0,0,0,4,4V28A2.0023,2.0023,0,0,0,6,30Z"
/>
<path
d="M20.586 20.586L24.172 17 10 17 10 15 24.172 15 20.586 11.414 22 10 28 16 22 22 20.586 20.586z"
/>
</svg>
</span>
</div>
</header>
<section
class="main"
Expand Down
Loading

0 comments on commit 36cec0e

Please sign in to comment.