Skip to content

Commit

Permalink
fix merge conflicts again
Browse files Browse the repository at this point in the history
  • Loading branch information
shivankacker committed Oct 17, 2024
2 parents 50558aa + 5455e97 commit 792f6c0
Show file tree
Hide file tree
Showing 13 changed files with 4,179 additions and 4,101 deletions.
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
"prepare": "husky install",
"lint": "eslint ./src",
"lint-fix": "eslint ./src --fix",
"format": "prettier ./src --write"
"format": "prettier ./src --write",
"sort-locales": "node ./scripts/sort-locales.js"
},
"dependencies": {
"@fontsource/figtree": "^5.1.0",
Expand Down Expand Up @@ -163,10 +164,13 @@
"prettier --write --ignore-unknown --plugin prettier-plugin-tailwindcss",
"eslint --fix",
"git update-index --again"
],
"src/Locale/*.json": [
"npm run sort-locales"
]
},
"engines": {
"node": ">=20.12.0"
},
"packageManager": "[email protected]"
}
}
26 changes: 26 additions & 0 deletions scripts/sort-locales.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// 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;

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

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

fs.writeFileSync(filePath, JSON.stringify(sortedData, null, 2) + "\n");
}
});
});
29 changes: 21 additions & 8 deletions src/Components/Facility/FacilityBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
import { Link } from "raviger";
import { FacilityModel } from "./models";
import { ReactNode } from "react";
import { Avatar } from "@/Components/Common/Avatar";

export default function FacilityBlock(props: { facility: FacilityModel }) {
const { facility } = props;
export default function FacilityBlock(props: {
facility: FacilityModel;
redirect?: boolean;
}) {
const { facility, redirect = true } = props;

const Element = (props: { children: ReactNode; className?: string }) =>
redirect ? (
<Link
target="_blank"
href={`/facility/${facility.id}`}
className={props.className}
>
{props.children}
</Link>
) : (
<button className={props.className}>{props.children}</button>
);

return (
<Link
className="flex items-center gap-4 text-inherit"
target="_blank"
href={`/facility/${facility.id}`}
>
<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">
<Avatar
name={facility.name!}
Expand All @@ -23,6 +36,6 @@ export default function FacilityBlock(props: { facility: FacilityModel }) {
{facility.address} {facility.local_body_object?.name}
</p>
</div>
</Link>
</Element>
);
}
16 changes: 10 additions & 6 deletions src/Components/Facility/FacilityCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ import TextAreaFormField from "../Form/FormFields/TextAreaFormField";
import request from "../../Utils/request/request";
import routes from "../../Redux/api";
import careConfig from "@careConfig";
import { FacilityModel } from "./models";
import { Avatar } from "../Common/Avatar";

export const FacilityCard = (props: { facility: any; userType: any }) => {
export const FacilityCard = (props: {
facility: FacilityModel;
userType: string;
}) => {
const { facility, userType } = props;

const { t } = useTranslation();
const [notifyModalFor, setNotifyModalFor] = useState(undefined);
const [notifyModalFor, setNotifyModalFor] = useState<string>();
const [notifyMessage, setNotifyMessage] = useState("");
const [notifyError, setNotifyError] = useState("");

Expand Down Expand Up @@ -55,7 +59,7 @@ export const FacilityCard = (props: { facility: any; userType: any }) => {
className="group relative z-0 flex w-full min-w-[15%] items-center justify-center self-stretch min-[425px]:hidden"
>
<Avatar
name={facility.name}
name={facility.name || ""}
imageUrl={facility.read_cover_image_url}
className="m-4 mb-0 md:m-0"
/>
Expand All @@ -69,7 +73,7 @@ export const FacilityCard = (props: { facility: any; userType: any }) => {
className="hidden h-[150px] min-h-[150px] w-[150px] min-w-[150px] sm:block"
>
<Avatar
name={facility.name}
name={facility.name || ""}
imageUrl={facility.read_cover_image_url}
/>
</Link>
Expand All @@ -92,7 +96,7 @@ export const FacilityCard = (props: { facility: any; userType: any }) => {
</Link>
<div
data-test-id="occupancy-badge"
className={`tooltip flex items-center gap-1 text-sm ${facility.patient_count / facility.bed_count > 0.85 ? "justify-center rounded-md border border-red-600 bg-red-500 p-1 font-bold text-white" : "text-secondary-700"}`}
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")}
Expand Down Expand Up @@ -121,7 +125,7 @@ export const FacilityCard = (props: { facility: any; userType: any }) => {

<div className="mt-2 flex flex-wrap gap-1">
<Chip
text={facility.facility_type}
text={facility.facility_type || ""}
variant="custom"
className="bg-blue-100 text-blue-900"
hideBorder
Expand Down
41 changes: 33 additions & 8 deletions src/Components/Facility/FacilityHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,20 @@ export const FacilityHome = ({ facilityId }: Props) => {
},
});

const spokesQuery = useQuery(routes.getFacilitySpokes, {
pathParams: {
id: facilityId,
},
silent: true,
});

const hubsQuery = useQuery(routes.getFacilityHubs, {
pathParams: {
id: facilityId,
},
silent: true,
});

const handleDeleteClose = () => {
setOpenDeleteDialog(false);
};
Expand All @@ -93,13 +107,6 @@ export const FacilityHome = ({ facilityId }: Props) => {
});
};

const spokesQuery = useQuery(routes.getFacilitySpokes, {
pathParams: {
id: facilityId,
},
silent: true,
});

if (isLoading) {
return <Loading />;
}
Expand Down Expand Up @@ -257,7 +264,7 @@ export const FacilityHome = ({ facilityId }: Props) => {
/>
</div>
</div>
{!!spokesQuery.data?.results.length && (
{!!spokesQuery.data?.results?.length && (
<div className="mt-4 flex items-center gap-3">
<div id="spokes-view">
<h1 className="text-base font-semibold text-[#B9B9B9]">
Expand All @@ -274,6 +281,24 @@ export const FacilityHome = ({ facilityId }: Props) => {
</div>
</div>
)}

{!!hubsQuery.data?.results?.length && (
<div className="mt-4 flex items-center gap-3">
<div id="hubs-view">
<h1 className="text-base font-semibold text-[#B9B9B9]">
{t("hubs")}
</h1>
<div className="mt-4 grid grid-cols-1 gap-4 xl:grid-cols-2">
{hubsQuery.data.results.map((hub) => (
<FacilityBlock
facility={hub.hub_object}
redirect={false}
/>
))}
</div>
</div>
</div>
)}
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Facility/models.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ export interface FacilityModel {
latitude?: string;
longitude?: string;
kasp_empanelled?: boolean;
patient_count?: string;
bed_count?: string;
patient_count?: number;
bed_count?: number;
}

export enum SpokeRelationship {
Expand Down
Loading

0 comments on commit 792f6c0

Please sign in to comment.