diff --git a/src/elderly/components/ScheduleList.tsx b/src/elderly/components/ScheduleList.tsx new file mode 100644 index 0000000..2227883 --- /dev/null +++ b/src/elderly/components/ScheduleList.tsx @@ -0,0 +1,121 @@ +import React from 'react'; +import { X, Clock } from 'lucide-react'; +import * as scheduleService from '../services/scheduleService'; + +interface ScheduleItem { + time: string; + title: string; + type: 'medication' | 'meal' | 'activity' | 'other'; +} + +interface ScheduleListProps { + schedules?: scheduleService.Schedule[]; + onClose: () => void; +} + +/** + * 日程列表组件 + * 显示今日所有待办事项 + */ +export const ScheduleList: React.FC = ({ schedules: propSchedules, onClose }) => { + // 使用传入的日程数据,或使用模拟数据 + const mockSchedules: ScheduleItem[] = [ + { time: '08:30', title: '喝水', type: 'other' }, + { time: '09:00', title: '早药时间 - 氯沙坦', type: 'medication' }, + { time: '12:00', title: '午餐', type: 'meal' }, + { time: '12:30', title: '午药时间', type: 'medication' }, + { time: '14:00', title: '午休', type: 'activity' }, + { time: '15:30', title: '下午茶', type: 'meal' }, + { time: '18:00', title: '晚餐', type: 'meal' }, + { time: '18:30', title: '晚药时间', type: 'medication' }, + { time: '21:00', title: '准备睡觉', type: 'activity' }, + ]; + + // 将 API 数据转换为组件使用的格式 + const schedules: ScheduleItem[] = propSchedules + ? scheduleService.sortSchedulesByTime(propSchedules).map((schedule) => ({ + time: scheduleService.formatTime(schedule.schedule_time), + title: schedule.title + (schedule.description ? ` - ${schedule.description}` : ''), + type: (schedule.schedule_type || 'other') as any, + })) + : mockSchedules; + + const getTypeColor = (type: string) => { + switch (type) { + case 'medication': + return 'bg-blue-100 text-blue-700 border-blue-300'; + case 'meal': + return 'bg-orange-100 text-orange-700 border-orange-300'; + case 'activity': + return 'bg-green-100 text-green-700 border-green-300'; + default: + return 'bg-gray-100 text-gray-700 border-gray-300'; + } + }; + + const getTypeIcon = (type: string) => { + switch (type) { + case 'medication': + return '💊'; + case 'meal': + return '🍽️'; + case 'activity': + return '🏃'; + default: + return '📌'; + } + }; + + return ( +
+
+ {/* 标题栏 */} +
+
+ +

今日日程

+
+ +
+ + {/* 日程列表 */} +
+
+ {schedules.map((item, index) => ( +
+
{getTypeIcon(item.type)}
+
+
{item.time}
+
{item.title}
+
+
+ ))} +
+
+ + {/* 底部按钮 */} +
+ +
+
+
+ ); +};