chore: finish workspace cleanup
This commit is contained in:
@@ -377,7 +377,7 @@ await database
|
|||||||
- Good: use one additive `care_tasks` table for MVP execution records instead of building a full recurring care-plan engine.
|
- Good: use one additive `care_tasks` table for MVP execution records instead of building a full recurring care-plan engine.
|
||||||
- Good: preserve `/app/health` separation; care execution is operational and not the health admin settings page.
|
- Good: preserve `/app/health` separation; care execution is operational and not the health admin settings page.
|
||||||
- Base: `elderId` can be nullable for future public-area checks, but seeded MVP examples should use real elders.
|
- Base: `elderId` can be nullable for future public-area checks, but seeded MVP examples should use real elders.
|
||||||
- Bad: render fake care metrics in `ModulePage` after the module becomes real.
|
- Bad: render fake care metrics in a static placeholder after the module becomes real.
|
||||||
- Bad: update task status by ID alone without `organizationId`.
|
- Bad: update task status by ID alone without `organizationId`.
|
||||||
- Bad: only disable buttons in the UI while leaving Route Handlers on broad elder permissions.
|
- Bad: only disable buttons in the UI while leaving Route Handlers on broad elder permissions.
|
||||||
|
|
||||||
|
|||||||
@@ -165,44 +165,17 @@ The project Dialog adapter must:
|
|||||||
|
|
||||||
### Static Module Data Contract
|
### Static Module Data Contract
|
||||||
|
|
||||||
Static or reserved module pages must not fabricate operational data. If a module does
|
Operational module pages must not fabricate data. If a module does not have a
|
||||||
not have a Drizzle-backed query/API and real persisted records, render a clear empty or
|
Drizzle-backed query/API and real persisted records, render a clear empty or
|
||||||
not-connected state instead of generated counters, fake workflows, sample records, or
|
not-connected state inside that module's own route/component instead of generated
|
||||||
mock priority/status rows.
|
counters, fake workflows, sample records, or mock priority/status rows.
|
||||||
|
|
||||||
`modules/shared/components/ModulePage.tsx` is the shared placeholder for these modules.
|
The old shared reserved-module placeholder components were removed after devices,
|
||||||
Its props should stay descriptive only:
|
notices, alerts, family, health, care, and emergency became real persisted workspaces.
|
||||||
|
Do not reintroduce a generic `ReservedModulePages` layer for operational modules.
|
||||||
|
|
||||||
```typescript
|
When a module becomes real, implement the route as a Server Component that loads data
|
||||||
type ModulePageProps = {
|
from the server boundary and passes only persisted, permission-filtered data into
|
||||||
title: string;
|
|
||||||
eyebrow: string;
|
|
||||||
description: string;
|
|
||||||
icon: LucideIcon;
|
|
||||||
phase: "待接入" | "二期预留" | "三期预留";
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
// Bad: static pages pretending to have live business data.
|
|
||||||
<ModulePage
|
|
||||||
title="Care"
|
|
||||||
metrics={[{ label: "Today", value: "184", detail: "142 done" }]}
|
|
||||||
workflows={["Create plan", "Dispatch task"]}
|
|
||||||
/>
|
|
||||||
|
|
||||||
// Good: no fabricated records until a real data source exists.
|
|
||||||
<ModulePage
|
|
||||||
title="Care"
|
|
||||||
eyebrow="Plans and inspections"
|
|
||||||
description="Pending connection to care plans, task dispatch, and execution records."
|
|
||||||
icon={ClipboardCheck}
|
|
||||||
phase="待接入"
|
|
||||||
/>
|
|
||||||
```
|
|
||||||
|
|
||||||
When a module becomes real, replace the placeholder with a Server Component that loads
|
|
||||||
data from the server boundary and pass only persisted, permission-filtered data into
|
|
||||||
client components.
|
client components.
|
||||||
|
|
||||||
### App Shell Tenant and Account Menu Contract
|
### App Shell Tenant and Account Menu Contract
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ the rest conversationally.
|
|||||||
|
|
||||||
## Status (update the checkboxes as you complete each item)
|
## Status (update the checkboxes as you complete each item)
|
||||||
|
|
||||||
- [ ] Fill backend guidelines
|
- [x] Fill backend guidelines
|
||||||
- [ ] Fill frontend guidelines
|
- [x] Fill frontend guidelines
|
||||||
- [ ] Add code examples
|
- [x] Add code examples
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
"name": "00-bootstrap-guidelines",
|
"name": "00-bootstrap-guidelines",
|
||||||
"title": "Bootstrap Guidelines",
|
"title": "Bootstrap Guidelines",
|
||||||
"description": "Fill in project development guidelines for AI agents",
|
"description": "Fill in project development guidelines for AI agents",
|
||||||
"status": "in_progress",
|
"status": "completed",
|
||||||
"dev_type": "docs",
|
"dev_type": "docs",
|
||||||
"scope": null,
|
"scope": null,
|
||||||
"package": null,
|
"package": null,
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
"creator": "TalexDreamSoul",
|
"creator": "TalexDreamSoul",
|
||||||
"assignee": "TalexDreamSoul",
|
"assignee": "TalexDreamSoul",
|
||||||
"createdAt": "2026-07-01",
|
"createdAt": "2026-07-01",
|
||||||
"completedAt": null,
|
"completedAt": "2026-07-03",
|
||||||
"branch": null,
|
"branch": null,
|
||||||
"base_branch": null,
|
"base_branch": null,
|
||||||
"worktree_path": null,
|
"worktree_path": null,
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { renderHealthWorkspacePage } from "@/modules/health/components/HealthWorkspacePage";
|
import { renderHealthSettingsPage } from "@/modules/health/components/HealthWorkspacePage";
|
||||||
|
|
||||||
export default async function HealthSettingsPage(): Promise<React.ReactElement> {
|
export default async function HealthSettingsPage(): Promise<React.ReactElement> {
|
||||||
return renderHealthWorkspacePage();
|
return renderHealthSettingsPage();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,52 @@
|
|||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
import { HeartPulse } from "lucide-react";
|
import { Activity, FileText, HeartPulse, ShieldAlert, Stethoscope } from "lucide-react";
|
||||||
|
|
||||||
|
import { Badge } from "@/components/ui/badge";
|
||||||
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||||
|
import { Table } from "@/components/ui/table";
|
||||||
import { getCurrentAuthContext } from "@/modules/core/server/auth";
|
import { getCurrentAuthContext } from "@/modules/core/server/auth";
|
||||||
import { hasPermission } from "@/modules/core/server/permissions";
|
import { hasPermission } from "@/modules/core/server/permissions";
|
||||||
import { HealthAdminClient } from "@/modules/health/components/HealthAdminClient";
|
import { HealthAdminClient } from "@/modules/health/components/HealthAdminClient";
|
||||||
import { listHealthAdminData } from "@/modules/health/server/operations";
|
import { listHealthAdminData } from "@/modules/health/server/operations";
|
||||||
|
import type { HealthReviewSeverity, HealthReviewStatus } from "@/modules/health/types";
|
||||||
|
import {
|
||||||
|
CHRONIC_CONDITION_STATUS_LABELS,
|
||||||
|
HEALTH_REVIEW_SEVERITY_LABELS,
|
||||||
|
HEALTH_REVIEW_STATUS_LABELS,
|
||||||
|
VITAL_SOURCE_LABELS,
|
||||||
|
} from "@/modules/health/types";
|
||||||
import { getWorkspaceHref } from "@/modules/shared/lib/workspace-routing";
|
import { getWorkspaceHref } from "@/modules/shared/lib/workspace-routing";
|
||||||
|
|
||||||
export async function renderHealthWorkspacePage(): Promise<React.ReactElement> {
|
type HealthPageData = {
|
||||||
|
canManage: boolean;
|
||||||
|
data: Awaited<ReturnType<typeof listHealthAdminData>>;
|
||||||
|
};
|
||||||
|
|
||||||
|
function formatDateTime(value: string | undefined): string {
|
||||||
|
return value ? new Date(value).toLocaleString("zh-CN") : "-";
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatTenths(value: number | undefined, suffix = ""): string {
|
||||||
|
return value === undefined ? "-" : `${(value / 10).toFixed(1)}${suffix}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function severityBadgeVariant(severity: HealthReviewSeverity): "secondary" | "warning" | "danger" {
|
||||||
|
if (severity === "critical") {
|
||||||
|
return "danger";
|
||||||
|
}
|
||||||
|
|
||||||
|
return severity === "warning" ? "warning" : "secondary";
|
||||||
|
}
|
||||||
|
|
||||||
|
function reviewStatusBadgeVariant(status: HealthReviewStatus): "success" | "secondary" | "warning" {
|
||||||
|
if (status === "pending") {
|
||||||
|
return "warning";
|
||||||
|
}
|
||||||
|
|
||||||
|
return status === "resolved" ? "success" : "secondary";
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadHealthPageData(): Promise<HealthPageData> {
|
||||||
const context = await getCurrentAuthContext();
|
const context = await getCurrentAuthContext();
|
||||||
if (!context) {
|
if (!context) {
|
||||||
redirect("/login");
|
redirect("/login");
|
||||||
@@ -23,6 +62,17 @@ export async function renderHealthWorkspacePage(): Promise<React.ReactElement> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const data = await listHealthAdminData(organizationId);
|
const data = await listHealthAdminData(organizationId);
|
||||||
|
return {
|
||||||
|
canManage: hasPermission(context.permissions, "health:manage"),
|
||||||
|
data,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function renderHealthWorkspacePage(): Promise<React.ReactElement> {
|
||||||
|
const { data } = await loadHealthPageData();
|
||||||
|
const pendingReviews = data.reviews.filter((review) => review.status === "pending").slice(0, 8);
|
||||||
|
const recentVitals = data.vitals.slice(0, 8);
|
||||||
|
const activeConditions = data.chronicConditions.filter((condition) => condition.status === "active").slice(0, 8);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mx-auto flex w-full max-w-7xl flex-col gap-5">
|
<div className="mx-auto flex w-full max-w-7xl flex-col gap-5">
|
||||||
@@ -33,12 +83,172 @@ export async function renderHealthWorkspacePage(): Promise<React.ReactElement> {
|
|||||||
</span>
|
</span>
|
||||||
<div className="min-w-0">
|
<div className="min-w-0">
|
||||||
<h1 className="truncate text-xl font-semibold tracking-normal">健康照护</h1>
|
<h1 className="truncate text-xl font-semibold tracking-normal">健康照护</h1>
|
||||||
<p className="mt-1 truncate text-sm text-muted-foreground">健康档案、生命体征、慢病管理与异常复核</p>
|
<p className="mt-1 truncate text-sm text-muted-foreground">健康概览、重点慢病、生命体征与异常复核队列</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<HealthAdminClient canManage={hasPermission(context.permissions, "health:manage")} initialData={data} />
|
<section className="grid gap-4 md:grid-cols-2 xl:grid-cols-4">
|
||||||
|
<MetricCard icon={<FileText className="size-4" aria-hidden="true" />} label="健康档案" value={data.metrics.eldersWithProfiles} />
|
||||||
|
<MetricCard icon={<Activity className="size-4" aria-hidden="true" />} label="今日体征" value={data.metrics.vitalsToday} />
|
||||||
|
<MetricCard icon={<Stethoscope className="size-4" aria-hidden="true" />} label="慢病管理" value={data.metrics.activeChronicConditions} />
|
||||||
|
<MetricCard icon={<ShieldAlert className="size-4" aria-hidden="true" />} label="待复核" value={data.metrics.pendingReviews} />
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section className="grid gap-4 xl:grid-cols-[1.1fr_0.9fr]">
|
||||||
|
<Card>
|
||||||
|
<CardHeader>
|
||||||
|
<CardTitle>待复核健康异常</CardTitle>
|
||||||
|
<CardDescription>按最新异常记录展示护理复核队列。</CardDescription>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent className="overflow-x-auto">
|
||||||
|
<Table className="w-full min-w-[720px] text-sm">
|
||||||
|
<Table.Header className="bg-secondary text-left text-xs text-muted-foreground">
|
||||||
|
<Table.Row>
|
||||||
|
<Table.Head className="px-4 py-3 font-medium">老人</Table.Head>
|
||||||
|
<Table.Head className="px-4 py-3 font-medium">异常</Table.Head>
|
||||||
|
<Table.Head className="px-4 py-3 font-medium">级别</Table.Head>
|
||||||
|
<Table.Head className="px-4 py-3 font-medium">状态</Table.Head>
|
||||||
|
<Table.Head className="px-4 py-3 font-medium">创建时间</Table.Head>
|
||||||
|
</Table.Row>
|
||||||
|
</Table.Header>
|
||||||
|
<Table.Body className="divide-y bg-card">
|
||||||
|
{pendingReviews.map((review) => (
|
||||||
|
<Table.Row key={review.id}>
|
||||||
|
<Table.Cell className="px-4 py-3 font-medium">{review.elderName}</Table.Cell>
|
||||||
|
<Table.Cell className="px-4 py-3">
|
||||||
|
<p className="font-medium">{review.title}</p>
|
||||||
|
<p className="text-xs text-muted-foreground">{review.description}</p>
|
||||||
|
</Table.Cell>
|
||||||
|
<Table.Cell className="px-4 py-3">
|
||||||
|
<Badge variant={severityBadgeVariant(review.severity)}>
|
||||||
|
{HEALTH_REVIEW_SEVERITY_LABELS[review.severity]}
|
||||||
|
</Badge>
|
||||||
|
</Table.Cell>
|
||||||
|
<Table.Cell className="px-4 py-3">
|
||||||
|
<Badge variant={reviewStatusBadgeVariant(review.status)}>
|
||||||
|
{HEALTH_REVIEW_STATUS_LABELS[review.status]}
|
||||||
|
</Badge>
|
||||||
|
</Table.Cell>
|
||||||
|
<Table.Cell className="px-4 py-3 text-muted-foreground">{formatDateTime(review.createdAt)}</Table.Cell>
|
||||||
|
</Table.Row>
|
||||||
|
))}
|
||||||
|
{pendingReviews.length === 0 ? (
|
||||||
|
<Table.Row>
|
||||||
|
<Table.Cell className="px-4 py-8 text-center text-muted-foreground" colSpan={5}>
|
||||||
|
暂无待复核健康异常
|
||||||
|
</Table.Cell>
|
||||||
|
</Table.Row>
|
||||||
|
) : null}
|
||||||
|
</Table.Body>
|
||||||
|
</Table>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<Card>
|
||||||
|
<CardHeader>
|
||||||
|
<CardTitle>慢病重点关注</CardTitle>
|
||||||
|
<CardDescription>持续管理中的慢病记录。</CardDescription>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent className="grid gap-2">
|
||||||
|
{activeConditions.map((condition) => (
|
||||||
|
<div className="rounded-md border p-3" key={condition.id}>
|
||||||
|
<div className="flex items-start justify-between gap-3">
|
||||||
|
<div className="min-w-0">
|
||||||
|
<p className="truncate text-sm font-medium">{condition.elderName}</p>
|
||||||
|
<p className="mt-1 text-xs text-muted-foreground">{condition.name}</p>
|
||||||
|
</div>
|
||||||
|
<Badge variant="warning">{CHRONIC_CONDITION_STATUS_LABELS[condition.status]}</Badge>
|
||||||
|
</div>
|
||||||
|
<p className="mt-2 text-xs text-muted-foreground">{condition.followUpNotes || condition.treatmentNotes || "暂无随访备注"}</p>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
{activeConditions.length === 0 ? <p className="text-sm text-muted-foreground">暂无持续管理慢病记录</p> : null}
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<Card>
|
||||||
|
<CardHeader>
|
||||||
|
<CardTitle>最近生命体征</CardTitle>
|
||||||
|
<CardDescription>展示最新录入或采集的生命体征记录。</CardDescription>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent className="overflow-x-auto">
|
||||||
|
<Table className="w-full min-w-[820px] text-sm">
|
||||||
|
<Table.Header className="bg-secondary text-left text-xs text-muted-foreground">
|
||||||
|
<Table.Row>
|
||||||
|
<Table.Head className="px-4 py-3 font-medium">老人</Table.Head>
|
||||||
|
<Table.Head className="px-4 py-3 font-medium">时间</Table.Head>
|
||||||
|
<Table.Head className="px-4 py-3 font-medium">来源</Table.Head>
|
||||||
|
<Table.Head className="px-4 py-3 font-medium">血压</Table.Head>
|
||||||
|
<Table.Head className="px-4 py-3 font-medium">心率</Table.Head>
|
||||||
|
<Table.Head className="px-4 py-3 font-medium">体温</Table.Head>
|
||||||
|
<Table.Head className="px-4 py-3 font-medium">血氧</Table.Head>
|
||||||
|
<Table.Head className="px-4 py-3 font-medium">备注</Table.Head>
|
||||||
|
</Table.Row>
|
||||||
|
</Table.Header>
|
||||||
|
<Table.Body className="divide-y bg-card">
|
||||||
|
{recentVitals.map((vital) => (
|
||||||
|
<Table.Row key={vital.id}>
|
||||||
|
<Table.Cell className="px-4 py-3 font-medium">{vital.elderName}</Table.Cell>
|
||||||
|
<Table.Cell className="px-4 py-3 text-muted-foreground">{formatDateTime(vital.recordedAt)}</Table.Cell>
|
||||||
|
<Table.Cell className="px-4 py-3">{VITAL_SOURCE_LABELS[vital.source]}</Table.Cell>
|
||||||
|
<Table.Cell className="px-4 py-3">
|
||||||
|
{vital.systolicBp && vital.diastolicBp ? `${vital.systolicBp}/${vital.diastolicBp}` : "-"}
|
||||||
|
</Table.Cell>
|
||||||
|
<Table.Cell className="px-4 py-3">{vital.heartRate?.toString() ?? "-"}</Table.Cell>
|
||||||
|
<Table.Cell className="px-4 py-3">{formatTenths(vital.temperatureTenths, "°C")}</Table.Cell>
|
||||||
|
<Table.Cell className="px-4 py-3">{vital.spo2 === undefined ? "-" : `${vital.spo2}%`}</Table.Cell>
|
||||||
|
<Table.Cell className="px-4 py-3 text-muted-foreground">{vital.notes || "-"}</Table.Cell>
|
||||||
|
</Table.Row>
|
||||||
|
))}
|
||||||
|
{recentVitals.length === 0 ? (
|
||||||
|
<Table.Row>
|
||||||
|
<Table.Cell className="px-4 py-8 text-center text-muted-foreground" colSpan={8}>
|
||||||
|
暂无生命体征记录
|
||||||
|
</Table.Cell>
|
||||||
|
</Table.Row>
|
||||||
|
) : null}
|
||||||
|
</Table.Body>
|
||||||
|
</Table>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function renderHealthSettingsPage(): Promise<React.ReactElement> {
|
||||||
|
const { canManage, data } = await loadHealthPageData();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="mx-auto flex w-full max-w-7xl flex-col gap-5">
|
||||||
|
<section className="flex flex-col gap-3 border-b pb-4 lg:flex-row lg:items-start lg:justify-between">
|
||||||
|
<div className="flex min-w-0 items-center gap-3">
|
||||||
|
<span className="inline-flex size-9 items-center justify-center rounded-md bg-secondary text-primary">
|
||||||
|
<HeartPulse className="size-4" aria-hidden="true" />
|
||||||
|
</span>
|
||||||
|
<div className="min-w-0">
|
||||||
|
<h1 className="truncate text-xl font-semibold tracking-normal">健康数据管理</h1>
|
||||||
|
<p className="mt-1 truncate text-sm text-muted-foreground">维护健康档案、生命体征、慢病记录与异常复核</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<HealthAdminClient canManage={canManage} initialData={data} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function MetricCard({ icon, label, value }: { icon: React.ReactNode; label: string; value: number }): React.ReactElement {
|
||||||
|
return (
|
||||||
|
<Card>
|
||||||
|
<CardHeader className="flex flex-row items-center justify-between space-y-0">
|
||||||
|
<CardDescription>{label}</CardDescription>
|
||||||
|
<span className="text-primary">{icon}</span>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent>
|
||||||
|
<CardTitle className="text-3xl">{value}</CardTitle>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
HeartPulse,
|
HeartPulse,
|
||||||
LayoutDashboard,
|
LayoutDashboard,
|
||||||
ListChecks,
|
ListChecks,
|
||||||
|
LockKeyhole,
|
||||||
Radio,
|
Radio,
|
||||||
Settings,
|
Settings,
|
||||||
ShieldAlert,
|
ShieldAlert,
|
||||||
@@ -49,7 +50,15 @@ type AppSidebarNavProps = {
|
|||||||
permissions: Permission[];
|
permissions: Permission[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type SidebarNavItem = NavItem & {
|
||||||
|
canAccess: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
function canViewNavItem(item: NavItem, permissions: readonly Permission[]): boolean {
|
function canViewNavItem(item: NavItem, permissions: readonly Permission[]): boolean {
|
||||||
|
if (permissions.includes("platform:manage")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (item.permission && !permissions.includes(item.permission)) {
|
if (item.permission && !permissions.includes(item.permission)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -63,12 +72,13 @@ function canViewNavItem(item: NavItem, permissions: readonly Permission[]): bool
|
|||||||
|
|
||||||
export function AppSidebarNav({ organizationSlug, permissions }: AppSidebarNavProps): React.ReactElement {
|
export function AppSidebarNav({ organizationSlug, permissions }: AppSidebarNavProps): React.ReactElement {
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const visibleNavGroups = navGroups
|
const visibleNavGroups = navGroups.map((group): { label: string; items: SidebarNavItem[] } => ({
|
||||||
.map((group) => ({
|
|
||||||
...group,
|
...group,
|
||||||
items: group.items.filter((item) => canViewNavItem(item, permissions)),
|
items: group.items.map((item) => ({
|
||||||
}))
|
...item,
|
||||||
.filter((group) => group.items.length > 0);
|
canAccess: canViewNavItem(item, permissions),
|
||||||
|
})),
|
||||||
|
}));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<nav className="min-h-0 flex-1 overflow-y-auto px-3 py-4" aria-label="主导航">
|
<nav className="min-h-0 flex-1 overflow-y-auto px-3 py-4" aria-label="主导航">
|
||||||
@@ -80,10 +90,11 @@ export function AppSidebarNav({ organizationSlug, permissions }: AppSidebarNavPr
|
|||||||
{group.items.map((item) => {
|
{group.items.map((item) => {
|
||||||
const Icon = iconMap[item.icon];
|
const Icon = iconMap[item.icon];
|
||||||
const href = getWorkspaceHref(organizationSlug, item.path);
|
const href = getWorkspaceHref(organizationSlug, item.path);
|
||||||
const isActive = isWorkspacePathActive(pathname, item.path);
|
const isActive = item.canAccess && isWorkspacePathActive(pathname, item.path);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li key={item.path}>
|
<li key={item.path}>
|
||||||
|
{item.canAccess ? (
|
||||||
<Link
|
<Link
|
||||||
href={href}
|
href={href}
|
||||||
aria-current={isActive ? "page" : undefined}
|
aria-current={isActive ? "page" : undefined}
|
||||||
@@ -103,6 +114,18 @@ export function AppSidebarNav({ organizationSlug, permissions }: AppSidebarNavPr
|
|||||||
/>
|
/>
|
||||||
<span className="min-w-0 truncate font-medium">{item.label}</span>
|
<span className="min-w-0 truncate font-medium">{item.label}</span>
|
||||||
</Link>
|
</Link>
|
||||||
|
) : (
|
||||||
|
<span
|
||||||
|
className="flex min-h-11 cursor-not-allowed items-center gap-3 rounded-md px-3 text-sm text-muted-foreground/70"
|
||||||
|
aria-disabled="true"
|
||||||
|
title="当前角色无权访问"
|
||||||
|
>
|
||||||
|
<Icon className="size-4 shrink-0 text-muted-foreground/60" aria-hidden="true" />
|
||||||
|
<span className="min-w-0 flex-1 truncate font-medium">{item.label}</span>
|
||||||
|
<LockKeyhole className="size-3.5 shrink-0 text-muted-foreground/55" aria-hidden="true" />
|
||||||
|
<span className="sr-only">当前角色无权访问</span>
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
import type { LucideIcon } from "lucide-react";
|
|
||||||
import { Database } from "lucide-react";
|
|
||||||
|
|
||||||
import { Badge } from "@/components/ui/badge";
|
|
||||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
|
||||||
|
|
||||||
type ModulePageProps = {
|
|
||||||
title: string;
|
|
||||||
eyebrow: string;
|
|
||||||
description: string;
|
|
||||||
icon: LucideIcon;
|
|
||||||
phase: "待接入" | "二期预留" | "三期预留";
|
|
||||||
};
|
|
||||||
|
|
||||||
export function ModulePage({ title, eyebrow, description, icon: Icon, phase }: ModulePageProps): React.ReactElement {
|
|
||||||
return (
|
|
||||||
<div className="mx-auto flex w-full max-w-7xl flex-col gap-6">
|
|
||||||
<section className="flex flex-col gap-3 border-b pb-4 lg:flex-row lg:items-start lg:justify-between">
|
|
||||||
<div className="flex min-w-0 items-center gap-3">
|
|
||||||
<span className="inline-flex size-9 items-center justify-center rounded-md bg-secondary text-primary">
|
|
||||||
<Icon className="size-4" aria-hidden="true" />
|
|
||||||
</span>
|
|
||||||
<div className="min-w-0">
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<h1 className="truncate text-xl font-semibold tracking-normal">{title}</h1>
|
|
||||||
<Badge variant="secondary">{phase}</Badge>
|
|
||||||
</div>
|
|
||||||
<p className="mt-1 truncate text-sm text-muted-foreground">{eyebrow}</p>
|
|
||||||
<p className="mt-2 max-w-3xl text-sm text-muted-foreground">{description}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section>
|
|
||||||
<Card className="max-w-3xl">
|
|
||||||
<CardHeader>
|
|
||||||
<CardTitle className="flex items-center gap-2 text-base">
|
|
||||||
<Database className="size-5 text-primary" aria-hidden="true" />
|
|
||||||
未接入真实数据源
|
|
||||||
</CardTitle>
|
|
||||||
<CardDescription>当前模块暂不展示业务记录、统计指标或流程入口。</CardDescription>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent>
|
|
||||||
<p className="text-sm text-muted-foreground">
|
|
||||||
接入对应的 Drizzle 查询和操作 API 前,这里只保留模块位置,不渲染未落库记录或伪造待办。
|
|
||||||
</p>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
</section>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
import { Bell, Radio, TabletSmartphone, Wrench } from "lucide-react";
|
|
||||||
|
|
||||||
import { ModulePage } from "@/modules/shared/components/ModulePage";
|
|
||||||
|
|
||||||
export function DevicesModulePage(): React.ReactElement {
|
|
||||||
return (
|
|
||||||
<ModulePage
|
|
||||||
title="设备运维"
|
|
||||||
eyebrow="设备台账与维修工单"
|
|
||||||
description="待接入设备台账、故障上报、维修派单、处理记录和状态恢复数据源。"
|
|
||||||
icon={Wrench}
|
|
||||||
phase="待接入"
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function FamilyModulePage(): React.ReactElement {
|
|
||||||
return (
|
|
||||||
<ModulePage
|
|
||||||
title="家属服务"
|
|
||||||
eyebrow="家属端与探访反馈"
|
|
||||||
description="二期计划接入家属授权、老人动态、探访预约和服务反馈数据源。"
|
|
||||||
icon={TabletSmartphone}
|
|
||||||
phase="二期预留"
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function NoticesModulePage(): React.ReactElement {
|
|
||||||
return (
|
|
||||||
<ModulePage
|
|
||||||
title="公告通知"
|
|
||||||
eyebrow="公告发布与阅读状态"
|
|
||||||
description="待接入公告草稿、发布范围、阅读状态和通知记录数据源。"
|
|
||||||
icon={Bell}
|
|
||||||
phase="待接入"
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function AlertsModulePage(): React.ReactElement {
|
|
||||||
return (
|
|
||||||
<ModulePage
|
|
||||||
title="规则预警"
|
|
||||||
eyebrow="规则中心与风险识别"
|
|
||||||
description="三期计划接入健康阈值、任务逾期、设备故障、应急事件和风险老人识别规则。"
|
|
||||||
icon={Radio}
|
|
||||||
phase="三期预留"
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user