import Link from "next/link"; import { PanelShell } from "@/components/panel-shell"; import { PwaControls } from "@/components/pwa-controls"; import { getCaregiverMessages } from "@/lib/caregiver-panel"; import { formatDateTime, getDeviceName, getImportanceLabel, getMessageDirectionLabel, getMessageHref, getMessageStatusLabel, truncateText, } from "@/lib/panel-format"; import { requireCaregiverSession } from "@/lib/page-auth"; export const dynamic = "force-dynamic"; export default async function MessagesPage() { const caregiver = await requireCaregiverSession("/messages"); const { messages, unreadIncomingCount, unreadOutgoingCount } = await getCaregiverMessages(caregiver.id); const incomingMessages = messages.filter( (message) => message.direction === "ELDER_TO_FAMILY", ); const outgoingMessages = messages.filter( (message) => message.direction === "FAMILY_TO_ELDER", ); return ( } >

全部留言

{messages.length}

老人给家里的未读留言

{unreadIncomingCount}

待老人查看的家属留言

{unreadOutgoingCount}

{messages.length === 0 ? (

还没有留言记录

去设备页给老人留一句问候,或等待老人通过桥接工具给家里捎话;新记录会自动出现在这里,并带有可分享的消息编号。

去设备页 去扫码绑定
) : (
{[ { title: "老人给家里的留言", subtitle: "收到新话时也会从这里直达详情页。", items: incomingMessages, }, { title: "家属给老人的问候", subtitle: "写出去的每条问候也有独立 URL,可回看送达状态。", items: outgoingMessages, }, ].map((section) => (

留言列表

{section.title}

{section.subtitle}

{section.items.length === 0 ? (

这一侧暂时还没有留言。

) : ( section.items.map((message) => (
#{message.publicId} {getMessageDirectionLabel(message.direction)} {getDeviceName(message.elderDevice.displayName)} {getImportanceLabel(message.importance)} {getMessageStatusLabel(message)}

{truncateText(message.content, 112)}

创建于 {formatDateTime(message.createdAt)}

)) )}
))}
)}
); }