From aeb5b1faf8e75649efc0affb0aea9d7a4f7d52dc Mon Sep 17 00:00:00 2001 From: Spandan-Mishra Date: Wed, 5 Mar 2025 23:36:43 +0530 Subject: [PATCH 1/6] Redesigned the dashboard for the user organisation page --- public/locale/en.json | 9 +- src/pages/UserDashboard.tsx | 342 ++++++++++++++++++++++++------------ 2 files changed, 231 insertions(+), 120 deletions(-) diff --git a/public/locale/en.json b/public/locale/en.json index fe41ef8bed7..11e8bbe02ea 100644 --- a/public/locale/en.json +++ b/public/locale/en.json @@ -736,6 +736,9 @@ "cylinders_per_day": "Cylinders/day", "daily_rounds": "Daily Rounds", "dashboard": "Dashboard", + "dashboard_tab_administrations": "These are the Local Self-Government (LSG) networks or groups you're affiliated with, including State, District, Block, Municipality, Corporation, Panchayat, and Ward-level governance bodies", + "dashboard_tab_associations": "These are the professional or role-based groups - such as doctors, nurses, technicians, volunteers, or staff - that you are affiliated with", + "dashboard_tab_facilities": "These are the clinics, hospitals, or health centers you manage or belong to", "date": "Date", "date_and_time": "Date and Time", "date_and_time_of_death": "Date and Time of Death", @@ -2575,8 +2578,10 @@ "we_ve_sent_you_a_code_to": "We've sent you a code to", "weekly_schedule": "Weekly Schedule", "weekly_working_hours_error": "Average weekly working hours must be a number between 0 and 168", - "welcome_back_name": "Welcome Back {{name}} !", + "welcome_back": "Welcome back,", "welcome_back_to_hospital_dashboard": "Welcome back to the overview ", + "welcome_dr": "Dr. {{name}}", + "welcome_dr_banner": "You are logged in as a doctor!", "what_facility_assign_the_patient_to": "What facility would you like to assign the patient to", "whatsapp_number": "Whatsapp Number", "whatsapp_number_same_as_phone_number": "WhatsApp number is same as phone number", @@ -2595,8 +2600,6 @@ "yesterday": "Yesterday", "yet_to_be_decided": "Yet to be decided", "you_need_at_least_a_location_to_create_an_assest": "You need at least a location to create an assest.", - "your_facilities": "Your Facilities", - "your_organizations": "Your Organizations", "zoom_in": "Zoom In", "zoom_out": "Zoom Out" } diff --git a/src/pages/UserDashboard.tsx b/src/pages/UserDashboard.tsx index 104c55230ca..17ff9a5a515 100644 --- a/src/pages/UserDashboard.tsx +++ b/src/pages/UserDashboard.tsx @@ -1,5 +1,12 @@ -import { ChevronRight, LogOut, Settings, User2Icon } from "lucide-react"; +import { + ChevronRight, + EllipsisVerticalIcon, + LogOut, + SquarePen, + User2Icon, +} from "lucide-react"; import { Link } from "raviger"; +import { useState } from "react"; import { useTranslation } from "react-i18next"; import { Button } from "@/components/ui/button"; @@ -19,47 +26,72 @@ export default function UserDashboard() { const { t } = useTranslation(); const organizations = user.organizations || []; + const associations = + organizations.filter((org) => org.org_type === "role") || []; + const administrations = + organizations.filter((org) => org.org_type === "govt") || []; + + const [activeTab, setActiveTab] = useState("My Facilities"); + const tabs = ["My Facilities", "Associations", "Administrations"]; return (
{/* Welcome Section */} -
-
- -
-

- {t("welcome_back_name", { name: user.first_name })} -

-

- {new Date().toLocaleDateString("en-US", { - weekday: "long", - year: "numeric", - month: "long", - day: "numeric", - })} -

+
+
+
+ +
+
+

+ {t("welcome_back")} +

+

+ {user.user_type === "doctor" + ? t("welcome_dr", { name: user.first_name }) + : user.first_name} +

+
+

+ {new Date().toLocaleDateString("en-US", { + weekday: "long", + year: "numeric", + month: "long", + day: "numeric", + })} +

+
-
-
- - {user.is_superuser && ( + + {t("sign_out")} + + {user.is_superuser && ( + + )} - )} - + +
+ {user.user_type === "doctor" && ( +
+ {t("welcome_dr_banner")} +
+ )}
- {/* Facilities Section */} - {facilities.length > 0 && ( -
-

{t("your_facilities")}

-
- {facilities.map((facility) => ( - + {/* Tabs Headings */} +
+ {tabs.map((tab) => ( + + ))} +
+ + {/* Tabs Content */} +
+ {/* Facilities Section */} + {activeTab === "My Facilities" && facilities.length > 0 && ( +
+

+ {t("dashboard_tab_facilities")} +

+
- - - -
-

- {facility.name} -

-

- {t("view_facility_details")} -

-
- -
-
- - ))} -
-
- )} + {facilities.map((facility) => ( + + + + +
+

+ {facility.name} +

+

+ {t("view_facility_details")} +

+
+ +
+
+ + ))} +
+
+ )} - {/* Organizations Section */} - {organizations.length > 0 && ( -
-

- {t("your_organizations")} -

-
- {organizations.map((org) => ( - - - - -
-

- {org.name} -

-

- {getOrgLabel(org.org_type, org.metadata)} -

-
- -
-
- - ))} -
-
- )} + {/*Associations Section*/} + {activeTab === "Associations" && associations.length > 0 && ( +
+

+ {t("dashboard_tab_associations")} +

+
+ {associations.map((association) => ( + + + + +
+

+ {association.name} +

+

+ {getOrgLabel( + association.org_type, + association.metadata, + )} +

+
+ +
+
+ + ))} +
+
+ )} + + {/*Administrations Section*/} + {activeTab === "Administrations" && administrations.length > 0 && ( +
+

+ {t("dashboard_tab_administrations")} +

+
+ {administrations.map((administration) => ( + + + + +
+

+ {administration.name} +

+

+ {getOrgLabel( + administration.org_type, + administration.metadata, + )} +

+
+ +
+
+ + ))} +
+
+ )} +
+
); } From 6e824d58a3d676ecfd70bb32f8f0bcb08c9ae95e Mon Sep 17 00:00:00 2001 From: Spandan-Mishra Date: Thu, 6 Mar 2025 12:20:07 +0530 Subject: [PATCH 2/6] Fixed proposed changes in PR Added UI feedback when lists are empty, added accessibilty attributes and fixed some typos --- public/locale/en.json | 4 +- src/pages/UserDashboard.tsx | 248 +++++++++++++++++++++--------------- 2 files changed, 145 insertions(+), 107 deletions(-) diff --git a/public/locale/en.json b/public/locale/en.json index 11e8bbe02ea..90564eb5141 100644 --- a/public/locale/en.json +++ b/public/locale/en.json @@ -736,9 +736,9 @@ "cylinders_per_day": "Cylinders/day", "daily_rounds": "Daily Rounds", "dashboard": "Dashboard", - "dashboard_tab_administrations": "These are the Local Self-Government (LSG) networks or groups you're affiliated with, including State, District, Block, Municipality, Corporation, Panchayat, and Ward-level governance bodies", "dashboard_tab_associations": "These are the professional or role-based groups - such as doctors, nurses, technicians, volunteers, or staff - that you are affiliated with", "dashboard_tab_facilities": "These are the clinics, hospitals, or health centers you manage or belong to", + "dashboard_tab_governance": "These are the Local Self-Government (LSG) networks or groups you're affiliated with, including State, District, Block, Municipality, Corporation, Panchayat, and Ward-level governance bodies", "date": "Date", "date_and_time": "Date and Time", "date_and_time_of_death": "Date and Time of Death", @@ -1536,6 +1536,7 @@ "no_address_provided": "No address provided", "no_allergies_recorded": "No allergies recorded", "no_appointments": "No appointments found", + "no_associations_found": "No associations found", "no_attachments_found": "This communication has no attachments.", "no_availabilities_yet": "No availabilities yet", "no_bed_asset_linked_allocated": "No bed/asset linked allocated", @@ -1561,6 +1562,7 @@ "no_facilities": "No Facilities found", "no_facilities_found": "No facilities found", "no_files_found": "No {{type}} files found", + "no_governance_found": "No governance found", "no_home_facility": "No home facility", "no_home_facility_found": "No home facility found", "no_image_found": "No image found", diff --git a/src/pages/UserDashboard.tsx b/src/pages/UserDashboard.tsx index 17ff9a5a515..f739ed1917f 100644 --- a/src/pages/UserDashboard.tsx +++ b/src/pages/UserDashboard.tsx @@ -28,11 +28,11 @@ export default function UserDashboard() { const organizations = user.organizations || []; const associations = organizations.filter((org) => org.org_type === "role") || []; - const administrations = + const governance = organizations.filter((org) => org.org_type === "govt") || []; const [activeTab, setActiveTab] = useState("My Facilities"); - const tabs = ["My Facilities", "Associations", "Administrations"]; + const tabs = ["My Facilities", "Associations", "Governance"]; return (
@@ -109,8 +109,8 @@ export default function UserDashboard() { @@ -126,11 +126,14 @@ export default function UserDashboard() { {/* Tabs Section */}
{/* Tabs Headings */} -
+
{tabs.map((tab) => (
- {user.is_superuser && ( - + + + + + + + + {t("sign_out")} + + +
{user.user_type === "doctor" && ( @@ -126,12 +139,17 @@ export default function UserDashboard() { {/* Tabs Section */}
{/* Tabs Headings */} -
+
{tabs.map((tab) => ( - )} @@ -133,25 +115,16 @@ export default function UserDashboard() { - {user.is_superuser && ( - - - - {t("admin_dashboard")} - - - )} - - - {t("sign_out")} - + + + {t("admin_dashboard")} + + + + + + {t("sign_out")} +
From 90310741c61a14eed0b02a83a6b6415ef653b822 Mon Sep 17 00:00:00 2001 From: Spandan-Mishra Date: Sat, 8 Mar 2025 23:21:34 +0530 Subject: [PATCH 6/6] Admin dashboard restricted to superusers --- src/pages/UserDashboard.tsx | 48 ++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/src/pages/UserDashboard.tsx b/src/pages/UserDashboard.tsx index 5929e86dba7..b85405f55c6 100644 --- a/src/pages/UserDashboard.tsx +++ b/src/pages/UserDashboard.tsx @@ -90,20 +90,22 @@ export default function UserDashboard() {
- + + + {t("admin_dashboard")} + + + )}