Skip to content

Commit

Permalink
Merge branch 'ohcnetwork:develop' into issue-10293-UI-Enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwinpraveengo authored Jan 30, 2025
2 parents 5a6a3f2 + e35cc72 commit e1ae6dc
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 25 deletions.
4 changes: 4 additions & 0 deletions public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,8 @@
"make_facility_public_description": "When enabled, this facility will be visible to the public and can be discovered by anyone using the platform",
"make_multiple_beds_label": "Do you want to make multiple beds?",
"manage_bed_presets": "Manage Presets of Bed",
"manage_facility_users": "Manage encounters",
"manage_my_schedule": "Manage my schedule",
"manage_organizations": "Manage Organizations",
"manage_organizations_description": "Add or remove organizations from this questionnaire",
"manage_prescriptions": "Manage Prescriptions",
Expand Down Expand Up @@ -1434,6 +1436,7 @@
"otp_verification_error": "Failed to verify OTP. Please try again later.",
"otp_verification_success": "OTP has been verified successfully.",
"out_of_range_error": "Value must be between {{ start }} and {{ end }}.",
"overview": "Overview",
"oxygen_information": "Oxygen Information",
"packages": "Packages",
"page_load_error": "Couldn't Load the Page",
Expand Down Expand Up @@ -2216,6 +2219,7 @@
"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_to_hospital_dashboard": "Welcome back to the overview ",
"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",
Expand Down
7 changes: 3 additions & 4 deletions src/Routers/routes/FacilityRoutes.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { Redirect } from "raviger";

import { FacilityHome } from "@/components/Facility/FacilityHome";
import FacilityUsers from "@/components/Facility/FacilityUsers";
import ResourceCreate from "@/components/Resource/ResourceCreate";

import { AppRoutes } from "@/Routers/AppRouter";
import { FacilityOverview } from "@/pages/Facility/overview";
import { SettingsLayout } from "@/pages/Facility/settings/layout";

const FacilityRoutes: AppRoutes = {
"/facility": () => <Redirect to="/" />,

"/facility/:facilityId": ({ facilityId }) => (
<FacilityHome facilityId={facilityId} />
"/facility/:facilityId/overview": ({ facilityId }) => (
<FacilityOverview facilityId={facilityId} />
),
"/facility/:facilityId/users": ({ facilityId }) => (
<FacilityUsers facilityId={facilityId} />
Expand Down
2 changes: 1 addition & 1 deletion src/components/Facility/FacilityBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function FacilityBlock(props: {
redirect ? (
<Link
target="_blank"
href={`/facility/${facility.id}`}
href={`/facility/${facility.id}/overview`}
className={props.className}
>
{props.children}
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/sidebar/app-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export function AppSidebar({

<SidebarContent>
{facilitySidebar && !selectedOrganization && (
<FacilityNav selectedFacility={selectedFacility} user={user} />
<FacilityNav selectedFacility={selectedFacility} />
)}
{selectedOrganization && (
<OrgNav organizations={user?.organizations || []} />
Expand Down
19 changes: 4 additions & 15 deletions src/components/ui/sidebar/facility-nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { useTranslation } from "react-i18next";

import { NavMain } from "@/components/ui/sidebar/nav-main";

import { UserFacilityModel, UserModel } from "@/components/Users/models";

import { conditionalArrayAttribute } from "@/Utils/utils";
import { UserFacilityModel } from "@/components/Users/models";

interface NavigationLink {
name: string;
Expand All @@ -15,19 +13,17 @@ interface NavigationLink {

interface FacilityNavProps {
selectedFacility: UserFacilityModel | null;
user?: UserModel;
}

function generateFacilityLinks(
selectedFacility: UserFacilityModel | null,
t: TFunction,
user?: UserModel,
) {
if (!selectedFacility) return [];

const baseUrl = `/facility/${selectedFacility.id}`;
const links: NavigationLink[] = [
{ name: t("facility"), url: baseUrl, icon: "d-hospital" },
{ name: t("overview"), url: `${baseUrl}/overview`, icon: "d-hospital" },
{
name: t("appointments"),
url: `${baseUrl}/appointments`,
Expand All @@ -41,13 +37,6 @@ function generateFacilityLinks(
{ name: t("encounters"), url: `${baseUrl}/encounters`, icon: "d-patient" },
{ name: t("resource"), url: "/resource", icon: "d-book-open" },
{ name: t("users"), url: `${baseUrl}/users`, icon: "d-people" },
...conditionalArrayAttribute(!!user, [
{
name: t("my_schedules"),
url: `${baseUrl}/users/${user?.username}/availability`,
icon: "d-calendar",
},
]),
{
name: t("settings"),
url: `${baseUrl}/settings`,
Expand All @@ -58,7 +47,7 @@ function generateFacilityLinks(
return links;
}

export function FacilityNav({ selectedFacility, user }: FacilityNavProps) {
export function FacilityNav({ selectedFacility }: FacilityNavProps) {
const { t } = useTranslation();
return <NavMain links={generateFacilityLinks(selectedFacility, t, user)} />;
return <NavMain links={generateFacilityLinks(selectedFacility, t)} />;
}
2 changes: 1 addition & 1 deletion src/components/ui/sidebar/facility-switcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function FacilitySwitcher({
<DropdownMenuItem
key={index}
onClick={() => {
navigate(`/facility/${facility.id}`);
navigate(`/facility/${facility.id}/overview`);
if (isMobile) {
setOpenMobile(false);
}
Expand Down
4 changes: 3 additions & 1 deletion src/pages/Facility/components/FacilityCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ export function FacilityCard({ facility, className }: Props) {
<div className="mt-auto border-t border-gray-100 bg-gray-50 p-4">
<div className="flex justify-end">
<Button variant="outline" asChild>
<Link href={`/facility/${facility.id}`}>View Facility</Link>
<Link href={`/facility/${facility.id}/overview`}>
View Facility
</Link>
</Button>
</div>
</div>
Expand Down
90 changes: 90 additions & 0 deletions src/pages/Facility/overview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { Calendar, Users } from "lucide-react";
import { Link } from "raviger";
import { useTranslation } from "react-i18next";

import {
Card,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card";

import useAuthUser from "@/hooks/useAuthUser";

interface FacilityOverviewProps {
facilityId: string;
}

export function FacilityOverview({ facilityId }: FacilityOverviewProps) {
const { t } = useTranslation();
const user = useAuthUser();

const shortcuts = [
{
title: t("my_schedules"),
description: t("manage_my_schedule"),
icon: Calendar,
href: `/facility/${facilityId}/users/${user?.username}/availability`,
},
{
title: t("Encounters"),
description: t("manage_facility_users"),
icon: Users,
href: `/facility/${facilityId}/encounters`,
},
];

return (
<div className="min-h-screen bg-gray-50">
<div className="container mx-auto p-6 space-y-8">
{/* Welcome Header */}
<div className="bg-white rounded-lg p-6 shadow-sm">
<div className="flex items-center gap-4 mb-4">
<div>
<h1 className="text-2xl font-bold text-gray-900">
Hey {user?.first_name}
</h1>
<p className="text-gray-500">
{t("welcome_back_to_hospital_dashboard")}
</p>
</div>
</div>
</div>

{/* Quick Actions Section */}
<div className="">
<h2 className="text-xl font-semibold mb-6 text-gray-900">
{t("quick_actions")}
</h2>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
{shortcuts.map((shortcut) => (
<Link
key={shortcut.href}
href={shortcut.href}
className="block transition-all duration-200 hover:scale-102 hover:shadow-md"
>
<Card className="border-0 shadow-sm hover:bg-gray-50">
<CardHeader className="flex flex-row items-center gap-4">
<div className="p-2 bg-primary/10 rounded-lg">
<shortcut.icon className="h-6 w-6 text-primary" />
</div>
<div>
<CardTitle className="text-lg">
{shortcut.title}
</CardTitle>
<CardDescription className="text-gray-500">
{shortcut.description}
</CardDescription>
</div>
</CardHeader>
</Card>
</Link>
))}
</div>
</div>
</div>
</div>
);
}

export default FacilityOverview;
2 changes: 1 addition & 1 deletion src/pages/Organization/OrganizationFacilities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export default function OrganizationFacilities({
asChild
>
<Link
href={`/facility/${facility.id}`}
href={`/facility/${facility.id}/overview`}
className="text-sm w-full hover:underline"
>
{t("view_facility")}
Expand Down
5 changes: 4 additions & 1 deletion src/pages/UserDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ export default function UserDashboard() {
data-cy="facility-list"
>
{facilities.map((facility) => (
<Link key={facility.id} href={`/facility/${facility.id}`}>
<Link
key={facility.id}
href={`/facility/${facility.id}/overview`}
>
<Card className="transition-all hover:shadow-md hover:border-primary/20">
<CardContent className="flex items-center gap-3 p-3 md:p-4">
<Avatar
Expand Down

0 comments on commit e1ae6dc

Please sign in to comment.