import Link from "next/link"; import { notFound } from "next/navigation"; import { SendMessageForm } from "@/components/dashboard-actions"; import { PanelShell } from "@/components/panel-shell"; import { getCaregiverDeviceDetail } from "@/lib/caregiver-panel"; import { formatDateTime, getConversationRoleLabel, getDeviceName, getImportanceLabel, getMessageHref, getUsageLabel, truncateText, } from "@/lib/panel-format"; import { requireCaregiverSession } from "@/lib/page-auth"; export const dynamic = "force-dynamic"; type DeviceDetailPageProps = { params: Promise<{ deviceUuid: string }>; }; export default async function DeviceDetailPage({ params }: DeviceDetailPageProps) { const { deviceUuid } = await params; const caregiver = await requireCaregiverSession(`/devices/${deviceUuid}`); const binding = await getCaregiverDeviceDetail(caregiver.id, deviceUuid); if (!binding) { notFound(); } const elderMessages = binding.elderDevice.messages.filter( (message) => message.direction === "ELDER_TO_FAMILY", ); const familyMessages = binding.elderDevice.messages.filter( (message) => message.direction === "FAMILY_TO_ELDER", ); return (

老人新留言

{binding.elderUnreadCount}

待老人查看

{binding.familyUnreadCount}

最近在线

{formatDateTime(binding.elderDevice.lastSeenAt)}

绑定链接

{truncateText(binding.bindUrl, 52)}

老人给家里的话

最近通过桥接工具送出的内容

去留言中心
{elderMessages.length === 0 ? (

这台设备暂时还没有新的老人留言。

) : ( elderMessages.map((message) => (
#{message.publicId} {getImportanceLabel(message.importance)} {formatDateTime(message.createdAt)}

{truncateText(message.content, 112)}

)) )}

最近活动

这台设备刚刚发生了什么

{binding.elderDevice.usageEvents.length === 0 ? (

暂时还没有同步到新的使用事件。

) : ( binding.elderDevice.usageEvents.map((event) => (
{getUsageLabel(event.eventType)} {formatDateTime(event.createdAt)}
)) )}

家属给老人的问候

最近写给这位老人的内容

{familyMessages.length === 0 ? (

还没有发给这位老人的问候。

) : ( familyMessages.map((message) => (
#{message.publicId} {getImportanceLabel(message.importance)} {formatDateTime(message.createdAt)}

{truncateText(message.content, 112)}

)) )}

最近对话片段

快速回看陪伴内容

{binding.elderDevice.conversationTurns.length === 0 ? (

这台设备最近还没有同步到对话片段。

) : ( binding.elderDevice.conversationTurns.map((turn) => (
{getConversationRoleLabel(turn.role)} {formatDateTime(turn.createdAt)}

{truncateText(turn.content, 124)}

)) )}
); }