'use client'; import React, { useEffect, useState } from 'react'; import Link from 'next/link'; import { AlertCircle, Bell, Clock3, Loader2, RefreshCw, ArrowRight } from 'lucide-react'; import { listNotifications } from '@/lib/api'; import type { NotificationRun } from '@/types'; import { pickAppText } from '@/lib/i18n/core'; import { useAppI18n } from '@/lib/i18n/provider'; import { containedLongTextClass } from '@/lib/text-wrapping'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; import { Card, CardContent } from '@/components/ui/card'; export default function NotificationsPage() { const { locale } = useAppI18n(); const [items, setItems] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); const load = React.useCallback(async () => { setLoading(true); setError(null); try { setItems(await listNotifications()); } catch (err: any) { setError(err.message || pickAppText(locale, '加载通知失败', 'Failed to load notifications')); } finally { setLoading(false); } }, [locale]); useEffect(() => { void load(); }, [load]); const formatTime = (value?: string | null) => { if (!value) return '-'; return new Date(value).toLocaleString(locale, { month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' }); }; return (

{pickAppText(locale, '通知', 'Notifications')}

{pickAppText(locale, '定时任务生成的日报、提醒和总结会固定出现在这里。', 'Scheduled reports, reminders, and summaries appear here.')}

{error && ( {error} )}
{loading ? (
{pickAppText(locale, '加载中', 'Loading')}
) : items.length === 0 ? (

{pickAppText(locale, '暂无通知', 'No notifications yet')}

) : (
{items.map((item) => (
{item.title || item.job_name} {item.engaged && {pickAppText(locale, '已接入 Task', 'Task linked')}} {item.status === 'error' && {pickAppText(locale, '错误', 'Error')}}

{item.output || item.message}

{formatTime(item.started_at)}
{item.job_name}
))}
)}
); }