Skip to content

Commit

Permalink
Merge branch 'develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
nihal467 authored Oct 18, 2024
2 parents 02ddd14 + 8d4640b commit d239847
Show file tree
Hide file tree
Showing 13 changed files with 123 additions and 174 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"cpus": 4
},
"waitFor": "onCreateCommand",
"postCreateCommand": "npm install",
"postCreateCommand": "npm run install-all",
"postAttachCommand": {
"server": "npm run dev"
},
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cypress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
node-version: "20"

- name: Install dependencies 📦
run: npm install
run: npm run install-all

- name: Build ⚙️
run: npm run build
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ RUN npm install

COPY . .

RUN npm run setup

RUN npm run build


Expand Down
2 changes: 1 addition & 1 deletion cypress/pageobject/Facility/FacilityHome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class FacilityHome {
}

verifyOccupancyBadgeVisibility() {
cy.get("#occupany-badge").should("be.visible");
cy.get('[data-test-id="occupancy-badge"]').should("be.visible");
}

verifyAndCloseNotifyModal() {
Expand Down
29 changes: 9 additions & 20 deletions scripts/sort-locales.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const fs = require("fs");
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require("path");

const directory = "src/Locale";

fs.readdir(directory, (err, files) => {
if (err) throw err;
const file = "src/Locale/en.json";

files.forEach((file) => {
if (file.endsWith(".json")) {
const filePath = path.join(directory, file);
const data = JSON.parse(fs.readFileSync(filePath, "utf8"));
const data = JSON.parse(fs.readFileSync(file, "utf8"));

const sortedData = Object.keys(data)
.sort()
.reduce((acc, key) => {
acc[key] = data[key];
return acc;
}, {});
const sortedData = Object.keys(data)
.sort()
.reduce((acc, key) => {
acc[key] = data[key];
return acc;
}, {});

fs.writeFileSync(filePath, JSON.stringify(sortedData, null, 2) + "\n");
}
});
});
fs.writeFileSync(file, JSON.stringify(sortedData, null, 2) + "\n");
10 changes: 4 additions & 6 deletions src/CAREUI/display/Count.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ interface Props {

export default function CountBlock(props: Props) {
return (
<div
className={classNames("rounded-lg bg-white p-4 shadow", props.className)}
>
<dl>
<div className="flex h-10 w-10 items-center justify-center rounded-lg bg-primary-100 text-xl">
<div className={classNames("rounded-lg", props.className)}>
<dl className="flex gap-3">
<div className="flex aspect-square h-16 items-center justify-center rounded-lg border border-black/10 bg-primary-100 text-2xl">
<CareIcon icon={props.icon} className="text-primary-600" />
</div>
<div>
<dt className="my-2 truncate text-sm font-semibold text-secondary-700">
<dt className="mb-1 truncate text-sm font-semibold text-secondary-700">
{props.text}
</dt>
{props.loading ? (
Expand Down
62 changes: 37 additions & 25 deletions src/Components/Common/Avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from "react";
import { cn } from "@/lib/utils";
import React, { useEffect, useRef, useState } from "react";

const colors: string[] = [
"#E6F3FF", // Light Blue
Expand Down Expand Up @@ -44,43 +45,54 @@ const initials = (name: string): string => {
interface AvatarProps {
colors?: [string, string];
name: string;
imageUrl?: string;
className?: string;
square?: boolean; // New prop to determine if the avatar should be square
}

const Avatar: React.FC<AvatarProps> = ({
colors: propColors,
name,
imageUrl,
className,
square = false, // Default to false for backwards compatibility
}) => {
const [bgColor, fgColor] = propColors || toColor(name);
const [bgColor] = propColors || toColor(name);
const [width, setWidth] = useState(0);
const avatarRef = useRef<HTMLDivElement>(null);

useEffect(() => {
const updateWidth = () => {
const avatarRect = avatarRef.current?.getBoundingClientRect();
const width = avatarRect?.width || 0;
setWidth(width);
};
updateWidth();
document.addEventListener("resize", updateWidth);
return () => document.removeEventListener("resize", updateWidth);
}, []);

return (
<svg
xmlns="http://www.w3.org/2000/svg"
version="1.1"
viewBox="0 0 100 100"
className={className}
<div
ref={avatarRef}
className={cn(
`flex aspect-square w-full items-center justify-center overflow-hidden border border-black/10 font-black text-black/10`,
className,
)}
style={{
background: bgColor,
borderRadius: width / 15 + "px",
fontSize: width / 2.5 + "px",
}}
>
{square ? (
<rect width="100" height="100" fill={bgColor} />
{imageUrl ? (
<img
src={imageUrl}
alt={name}
className="aspect-square w-full object-cover"
/>
) : (
<circle cx="50" cy="50" r="50" fill={bgColor} />
<div>{initials(name)}</div>
)}
<text
fill={fgColor}
fontSize="42"
fontFamily="sans-serif"
x="50"
y="54"
textAnchor="middle"
dominantBaseline="middle"
alignmentBaseline="middle"
>
{initials(name)}
</text>
</svg>
</div>
);
};

Expand Down
2 changes: 1 addition & 1 deletion src/Components/Common/Sidebar/SidebarUserCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const SidebarUserCard: React.FC<SidebarUserCardProps> = ({ shrinked }) => {
<div className="flex-none text-lg">
<Avatar
name={formatDisplayName(user)}
className="w-8 text-sm font-medium"
className="h-8 rounded-full text-black/50"
/>
</div>
<div className="max-w-32">
Expand Down
14 changes: 5 additions & 9 deletions src/Components/Facility/FacilityBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,11 @@ export default function FacilityBlock(props: {

return (
<Element className="flex items-center gap-4 text-left text-inherit">
<div className="flex aspect-square h-14 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-gray-400 bg-gray-200">
{facility.read_cover_image_url ? (
<img
className="h-full w-full object-cover"
src={facility.read_cover_image_url}
/>
) : (
<Avatar name={facility.name!} square={true} />
)}
<div className="flex aspect-square h-14 shrink-0 items-center justify-center overflow-hidden">
<Avatar
name={facility.name!}
imageUrl={facility.read_cover_image_url}
/>
</div>
<div>
<b className="font-semibold">{facility.name}</b>
Expand Down
105 changes: 36 additions & 69 deletions src/Components/Facility/FacilityCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import CareIcon from "../../CAREUI/icons/CareIcon";
import { formatPhoneNumber, parsePhoneNumber } from "../../Utils/utils";
import DialogModal from "../Common/Dialog";
import TextAreaFormField from "../Form/FormFields/TextAreaFormField";
import { classNames } from "../../Utils/utils";
import request from "../../Utils/request/request";
import routes from "../../Redux/api";
import careConfig from "@careConfig";
Expand Down Expand Up @@ -52,42 +51,31 @@ export const FacilityCard = (props: {

return (
<div key={`usr_${facility.id}`} className="w-full">
<div className="block h-full overflow-hidden rounded-lg bg-white shadow hover:border-primary-500">
<div className="block h-full overflow-hidden rounded-lg border border-secondary-300 bg-white transition-all hover:border-secondary-400">
<div className="flex h-full">
<div className="h-full w-full grow">
<Link
href={`/facility/${facility.id}`}
className="group relative z-0 flex w-full min-w-[15%] items-center justify-center self-stretch bg-secondary-300 min-[425px]:hidden"
className="group relative z-0 flex w-full min-w-[15%] items-center justify-center self-stretch min-[425px]:hidden"
>
{(facility.read_cover_image_url && (
<img
src={facility.read_cover_image_url}
alt={facility.name}
className="h-full max-h-32 w-full object-cover"
/>
)) || <Avatar name={facility.name ?? "Unknown"} square={true} />}
<Avatar
name={facility.name || ""}
imageUrl={facility.read_cover_image_url}
className="m-4 mb-0 md:m-0"
/>
</Link>

<div className="mx-auto flex h-fit w-full max-w-full flex-col flex-wrap justify-between md:h-full lg:max-w-3xl">
<div className="w-full p-4">
<div className="flex flex-col gap-5 sm:flex-row">
<Link
href={`/facility/${facility.id}`}
className="group relative z-0 hidden h-[150px] min-h-[150px] w-[150px] min-w-[150px] items-center justify-center rounded-md bg-secondary-300 sm:flex"
className="hidden h-[150px] min-h-[150px] w-[150px] min-w-[150px] sm:block"
>
{(facility.read_cover_image_url && (
<img
src={facility.read_cover_image_url}
alt={facility.name}
className="h-full w-full rounded-md object-cover"
/>
)) || (
<Avatar
name={facility.name || ""}
square={true}
className="h-full w-full rounded-md object-cover"
/>
)}
<Avatar
name={facility.name || ""}
imageUrl={facility.read_cover_image_url}
/>
</Link>
<div className="flow-root grow">
{facility.kasp_empanelled && (
Expand All @@ -99,12 +87,27 @@ export const FacilityCard = (props: {
className="flex flex-wrap items-center justify-between"
id="facility-name-card"
>
<Link
href={`/facility/${facility.id}`}
className="text-xl font-bold capitalize text-inherit hover:text-inherit"
>
{facility.name}
</Link>
<div>
<Link
href={`/facility/${facility.id}`}
className="text-xl font-bold capitalize text-inherit hover:text-inherit"
>
{facility.name}
</Link>
<div
data-test-id="occupancy-badge"
className={`tooltip flex items-center gap-1 text-sm ${(facility.patient_count || 0) / (facility.bed_count || 0) > 0.85 ? "justify-center rounded-md border border-red-600 bg-red-500 p-1 font-bold text-white" : "text-secondary-700"}`}
>
<span className="tooltip-text tooltip-top">
{t("live_patients_total_beds")}
</span>{" "}
<CareIcon icon="l-bed" />
<dt>
{t("occupancy")}: {facility.patient_count} /{" "}
{facility.bed_count}{" "}
</dt>
</div>
</div>
<ButtonV2
id="view-cns-button"
href={`/facility/${facility.id}/cns`}
Expand All @@ -116,9 +119,10 @@ export const FacilityCard = (props: {
icon="l-monitor-heart-rate"
className="text-lg"
/>
<span>View CNS</span>
<span>{t("view_cns")}</span>
</ButtonV2>
</div>

<div className="mt-2 flex flex-wrap gap-1">
<Chip
text={facility.facility_type || ""}
Expand Down Expand Up @@ -170,47 +174,10 @@ export const FacilityCard = (props: {
</div>
</div>
</div>
<div className="flex flex-wrap border-t bg-secondary-50 px-2 py-1 md:px-3">
<div className="flex flex-wrap border-t border-t-secondary-300 bg-secondary-50 px-2 py-1 md:px-3">
{/* <div className="flex justify-between py-2"> */}
<div className="flex w-full flex-wrap justify-between gap-2 py-2">
<div className="flex flex-wrap gap-2">
<div
id="occupany-badge"
className={`tooltip button-size-default ml-auto flex w-fit items-center justify-center rounded-md px-2 ${
(facility.patient_count || 0) /
(facility.bed_count || 0) >
0.85
? "button-danger-border bg-red-500"
: "button-primary-border bg-primary-100"
}`}
>
<span className="tooltip-text tooltip-top">
Live Patients / Total beds
</span>{" "}
<CareIcon
icon="l-bed"
className={classNames(
"mr-2",
(facility.patient_count || 0) /
(facility.bed_count || 0) >
0.85
? "text-white"
: "text-primary-600",
)}
/>{" "}
<dt
className={`text-sm font-semibold ${
(facility.patient_count || 0) /
(facility.bed_count || 0) >
0.85
? "text-white"
: "text-secondary-700"
}`}
>
Occupancy: {facility.patient_count} /{" "}
{facility.bed_count}{" "}
</dt>{" "}
</div>
<DialogModal
show={notifyModalFor === facility.id}
title={
Expand Down
Loading

0 comments on commit d239847

Please sign in to comment.