import { useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { Apple, ArrowRight, BarChart3, CalendarCheck, ClipboardCheck, Droplet, FileText, HeartHandshake, Leaf, LineChart, PencilLine, Sparkles, Sprout, Heart, Smile, CheckCircle2, type LucideIcon, } from 'lucide-react'; import { api } from '../api/client'; import { useToast } from '../components/Toast'; import { usePatient } from '../lib/usePatient'; import { BuildArchive } from '../components/BuildArchive'; import { greeting, riskBadgeClass, riskLabel } from '../lib/format'; import './HomePage.css'; type Tone = 'peach' | 'rose' | 'mint' | 'lilac'; interface Intent { label: string; q?: string; to?: string; icon: LucideIcon; tone: Tone; } const INTENTS: Intent[] = [ { label: '我能吃这个吗?', q: '孕期可以吃西瓜吗', icon: Apple, tone: 'peach' }, { label: '记录今天的血糖', to: '/data', icon: Droplet, tone: 'rose' }, { label: '今天该注意什么?', q: '孕期日常需要注意什么', icon: Leaf, tone: 'mint' }, { label: '孕期不适怎么办', q: '孕期恶心想吐怎么办', icon: HeartHandshake, tone: 'lilac' }, ]; const QUICK: { label: string; to: string; icon: LucideIcon; tone: Tone }[] = [ { label: '今日打卡', to: '/data', icon: ClipboardCheck, tone: 'peach' }, { label: '血糖趋势', to: '/data', icon: LineChart, tone: 'rose' }, { label: '产检提醒', to: '/tasks', icon: CalendarCheck, tone: 'mint' }, ]; export function HomePage(): JSX.Element { const navigate = useNavigate(); const { patient, loading, reload } = usePatient(); const { show } = useToast(); const [emotionScore, setEmotionScore] = useState(null); const [emotionNote, setEmotionNote] = useState(''); const [hasSubmittedEmotion, setHasSubmittedEmotion] = useState(false); const [submittingEmotion, setSubmittingEmotion] = useState(false); async function submitEmotion(): Promise { if (!emotionScore) { show('请选择一个情绪分值哦~'); return; } setSubmittingEmotion(true); try { await api.createEmotion({ score: emotionScore, note: emotionNote || '今日情绪状况良好' }); show('打卡成功!AI 已过滤异常信号并同步至管理师,祝您好心情🌸'); setHasSubmittedEmotion(true); setEmotionNote(''); } catch (err) { show('心情记录失败,请稍后重试'); } finally { setSubmittingEmotion(false); } } function goChat(q?: string): void { navigate('/chat', q ? { state: { initialQuestion: q } } : undefined); } if (!patient && !loading) { return (

你好,欢迎~

); } return (

{greeting()},{patient?.name ?? ''}

{patient && (

孕 {patient.gestationalWeeks} 周 {patient.gestationalDays ? ` ${patient.gestationalDays} 天` : ''} {riskLabel(patient.initialRiskLevel)}

)}
{/* 渐变 Hero 聊天主入口(AI-first) */} {/* 暖色暖系低焦虑今日心情自评打卡(T-D.9) */}

记录今日心情,倾听身体信号

{!hasSubmittedEmotion ? (

你今天的心情几分?(1-10分,分低代表压抑或焦虑)

{[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map((score) => ( ))}