Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Display total no. of entities with heading in Organization #10092

Open
wants to merge 36 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
05d91ad
add count with heading
AdityaJ2305 Jan 22, 2025
70337a2
nitpick sugg
AdityaJ2305 Jan 22, 2025
3996c56
typo error
AdityaJ2305 Jan 22, 2025
496adb1
Empty-Commit
AdityaJ2305 Jan 22, 2025
93a7a72
Merge branch 'develop' into orgtabs_count_with_header
AdityaJ2305 Jan 22, 2025
c3e6a53
Merge branch 'develop' into orgtabs_count_with_header
AdityaJ2305 Jan 22, 2025
4028c22
Merge branch 'develop' into orgtabs_count_with_header
AdityaJ2305 Jan 22, 2025
5a3feb0
replace 0 with ...
AdityaJ2305 Jan 22, 2025
f9c9ae2
add loading..
AdityaJ2305 Jan 22, 2025
27d4b0e
Merge branch 'develop' into orgtabs_count_with_header
AdityaJ2305 Jan 22, 2025
95c0ec3
Merge branch 'develop' into orgtabs_count_with_header
AdityaJ2305 Jan 22, 2025
fa3be6b
width add
AdityaJ2305 Jan 22, 2025
fffe7d1
Merge branch 'develop' into orgtabs_count_with_header
AdityaJ2305 Jan 22, 2025
d1cf587
entityBadge component
AdityaJ2305 Jan 23, 2025
f0eed5e
Merge branch 'develop' into orgtabs_count_with_header
AdityaJ2305 Jan 23, 2025
9af1f8a
Merge branch 'orgtabs_count_with_header' of https://github.com/Aditya…
AdityaJ2305 Jan 23, 2025
5894ab7
typo error fix
AdityaJ2305 Jan 23, 2025
78d2f9e
Merge branch 'develop' into orgtabs_count_with_header
AdityaJ2305 Jan 23, 2025
44b1639
Empty-Commit
AdityaJ2305 Jan 23, 2025
24abff4
Empty-Commit
AdityaJ2305 Jan 23, 2025
118b1da
double w-max
AdityaJ2305 Jan 23, 2025
7eebe13
Merge branch 'develop' into orgtabs_count_with_header
AdityaJ2305 Jan 23, 2025
8a32459
Merge branch 'develop' into orgtabs_count_with_header
AdityaJ2305 Jan 24, 2025
1e1939f
used isFetching
AdityaJ2305 Jan 24, 2025
58cf12e
replace isLoading with isFetching
AdityaJ2305 Jan 24, 2025
93a1957
updated offset
AdityaJ2305 Jan 24, 2025
038d54c
Merge branch 'develop' into orgtabs_count_with_header
AdityaJ2305 Jan 24, 2025
c51d6c8
Merge branch 'develop' into orgtabs_count_with_header
AdityaJ2305 Jan 25, 2025
381dd39
Merge branch 'develop' into orgtabs_count_with_header
AdityaJ2305 Jan 25, 2025
afa4172
Merge branch 'develop' into orgtabs_count_with_header
AdityaJ2305 Jan 26, 2025
f5c711c
Merge branch 'develop' into orgtabs_count_with_header
AdityaJ2305 Jan 27, 2025
4475934
Merge branch 'develop' into orgtabs_count_with_header
AdityaJ2305 Jan 27, 2025
785d1e8
Merge branch 'develop' into orgtabs_count_with_header
AdityaJ2305 Jan 27, 2025
eca5202
Merge branch 'develop' into orgtabs_count_with_header
AdityaJ2305 Jan 27, 2025
e987884
Merge branch 'develop' into orgtabs_count_with_header
AdityaJ2305 Jan 27, 2025
2432160
Merge branch 'develop' into orgtabs_count_with_header
AdityaJ2305 Jan 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,8 @@
"entered-in-error": "Entered in error",
"entered_in_error": "Entered in Error",
"entered_in_error_warning": "This action cannot be undone. The appointment will be marked as entered in error and removed from the system.",
"entity_count_one": "{{count}} {{entity}}",
"entity_count_other": "{{count}} {{entity}}s",
AdityaJ2305 marked this conversation as resolved.
Show resolved Hide resolved
"error_404": "Error 404",
"error_deleting_shifting": "Error while deleting Shifting record",
"error_fetching_facility_data": "Error while fetching facility data",
Expand Down Expand Up @@ -1020,6 +1022,8 @@
"facility": "Facility",
"facility_added_successfully": "Facility created successfully",
"facility_consent_requests_page_title": "Patient Consent List",
"facility_count_one": "{{count}} Facility",
"facility_count_other": "{{count}} Facilities ",
"facility_district_name": "Facility/District Name",
"facility_district_pincode": "Facility/District/Pincode",
"facility_for_care_support": "Facility for Care Support",
Expand Down Expand Up @@ -2184,8 +2188,6 @@
"use_phone_number_for_emergency": "Use this phone number for emergency contact",
"user_add_error": "Error while adding User",
"user_added_successfully": "User added successfully",
"user_count_one": "{{count}} user",
"user_count_other": "{{count}} users",
"user_delete_error": "Error while deleting User",
"user_deleted_successfully": "User Deleted Successfully",
"user_deleted_successfuly": "User Deleted Successfully",
Expand Down
9 changes: 7 additions & 2 deletions src/components/Facility/FacilityUsers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,15 @@ export default function FacilityUsers(props: { facilityId: string }) {
title={t("users_management")}
componentRight={
<Badge
className="bg-purple-50 text-purple-700 ml-2 text-sm font-medium rounded-xl px-3 m-3"
className="bg-purple-50 text-purple-700 ml-2 text-sm font-medium rounded-xl px-3 m-3 w-max"
variant="outline"
>
{t("user_count", { count: userListData?.count ?? 0 })}
{userListLoading
AdityaJ2305 marked this conversation as resolved.
Show resolved Hide resolved
? "Loading..."
: t("entity_count", {
count: userListData?.count ?? 0,
entity: "User",
})}
</Badge>
}
>
Expand Down
10 changes: 9 additions & 1 deletion src/pages/Organization/OrganizationFacilities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { BaseFacility } from "@/types/facility/facility";

import AddFacilitySheet from "./components/AddFacilitySheet";
import EditFacilitySheet from "./components/EditFacilitySheet";
import EntityBadge from "./components/EntityBadge";
import OrganizationLayout from "./components/OrganizationLayout";

interface Props {
Expand Down Expand Up @@ -58,7 +59,14 @@ export default function OrganizationFacilities({
<OrganizationLayout id={id} navOrganizationId={navOrganizationId}>
<div className="space-y-6">
<div className="flex justify-between items-center">
<h2 className="text-lg font-semibold">{t("facilities")}</h2>
<div className="mt-1 flex flex-col justify-start space-y-2 md:flex-row md:justify-between md:space-y-0">
AdityaJ2305 marked this conversation as resolved.
Show resolved Hide resolved
<EntityBadge
title={t("facilities")}
count={facilities?.count}
isLoading={isLoading}
customTranslation="facility_count"
/>
</div>
<AddFacilitySheet organizationId={id} />
</div>

Expand Down
10 changes: 9 additions & 1 deletion src/pages/Organization/OrganizationPatients.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { Patient } from "@/types/emr/newPatient";
import { Organization } from "@/types/organization/organization";
import organizationApi from "@/types/organization/organizationApi";

import EntityBadge from "./components/EntityBadge";
import OrganizationLayout from "./components/OrganizationLayout";

interface Props {
Expand Down Expand Up @@ -97,7 +98,14 @@ export default function OrganizationPatients({ id, navOrganizationId }: Props) {
>
<div className="space-y-6">
<div className="flex justify-between items-center">
<h2 className="text-lg font-semibold">{t("patients")}</h2>
<div className="mt-1 flex flex-col justify-start space-y-2 md:flex-row md:justify-between md:space-y-0">
<EntityBadge
title={t("patients")}
count={patients?.count}
isLoading={isLoading}
translationParams={{ entity: "Patient" }}
/>
</div>
</div>

<SearchByMultipleFields
Expand Down
10 changes: 9 additions & 1 deletion src/pages/Organization/OrganizationUsers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import organizationApi from "@/types/organization/organizationApi";

import AddUserSheet from "./components/AddUserSheet";
import EditUserRoleSheet from "./components/EditUserRoleSheet";
import EntityBadge from "./components/EntityBadge";
import LinkUserSheet from "./components/LinkUserSheet";
import OrganizationLayout from "./components/OrganizationLayout";

Expand Down Expand Up @@ -57,7 +58,14 @@ export default function OrganizationUsers({ id, navOrganizationId }: Props) {
<OrganizationLayout id={id} navOrganizationId={navOrganizationId}>
<div className="space-y-6">
<div className="flex justify-between items-center">
<h2 className="text-lg font-semibold">{t("users")}</h2>
<div className="mt-1 flex flex-col justify-start space-y-2 md:flex-row md:justify-between md:space-y-0">
<EntityBadge
title={t("users")}
count={users?.count}
isLoading={isLoadingUsers}
translationParams={{ entity: "User" }}
/>
</div>
<div className="flex gap-2">
<AddUserSheet
open={openAddUserSheet}
Expand Down
10 changes: 9 additions & 1 deletion src/pages/Organization/OrganizationView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import query from "@/Utils/request/query";
import { Organization, getOrgLabel } from "@/types/organization/organization";
import organizationApi from "@/types/organization/organizationApi";

import EntityBadge from "./components/EntityBadge";
import OrganizationLayout from "./components/OrganizationLayout";

interface Props {
Expand Down Expand Up @@ -52,7 +53,14 @@ export default function OrganizationView({ id, navOrganizationId }: Props) {
<OrganizationLayout id={id} navOrganizationId={navOrganizationId}>
<div className="space-y-6">
<div className="flex flex-col justify-between items-start gap-4">
<h2 className="text-lg font-semibold">{t("organizations")}</h2>
<div className="mt-1 flex flex-col justify-start space-y-2 md:flex-row md:justify-between md:space-y-0">
<EntityBadge
title={t("organizations")}
count={children?.count}
isLoading={isLoading}
translationParams={{ entity: "Organization" }}
/>
</div>
<div className="w-72">
<Input
placeholder="Search by name..."
Expand Down
41 changes: 41 additions & 0 deletions src/pages/Organization/components/EntityBadge.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React from "react";
import { useTranslation } from "react-i18next";

import { Badge } from "@/components/ui/badge";

interface EntityBadgeProps {
title: string;
count?: number | null | undefined;
isLoading: boolean;
translationParams?: Record<string, string>;
customTranslation?: string;
}

const EntityBadge: React.FC<EntityBadgeProps> = ({
title,
count,
isLoading,
translationParams,
customTranslation,
}) => {
const { t } = useTranslation();

return (
<div className="flex items-center">
<h2 className="text-lg font-semibold">{title}</h2>
<Badge
className="bg-purple-50 text-purple-700 ml-2 text-sm font-medium rounded-xl px-3 m-3 w-max"
variant="outline"
>
{isLoading
? "Loading..."
: t(customTranslation || "entity_count", {
count: count ?? 0,
...translationParams,
})}
</Badge>
</div>
);
};

export default EntityBadge;
Loading