From ff188284bf815072684e91ee9dde732f23eebfac Mon Sep 17 00:00:00 2001 From: 15945162479 <15945162479@qq.com> Date: Sat, 13 Dec 2025 14:46:20 +0800 Subject: [PATCH] Add File --- src/family/pages/CarePlanDebug.tsx | 84 ++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 src/family/pages/CarePlanDebug.tsx diff --git a/src/family/pages/CarePlanDebug.tsx b/src/family/pages/CarePlanDebug.tsx new file mode 100644 index 0000000..2edb8a3 --- /dev/null +++ b/src/family/pages/CarePlanDebug.tsx @@ -0,0 +1,84 @@ +import React, { useState, useEffect } from 'react'; +import * as scheduleService from '../services/scheduleService'; + +/** + * 简化的调试版本 - 用于排查问题 + */ +export const CarePlanDebug: React.FC = () => { + const [schedules, setSchedules] = useState([]); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + const familyId = 'family_001'; + + useEffect(() => { + loadSchedules(); + }, []); + + const loadSchedules = async () => { + try { + console.log('[DEBUG] 开始加载日程'); + setLoading(true); + setError(null); + + const data = await scheduleService.getFamilySchedules(familyId); + console.log('[DEBUG] 加载成功,数据:', data); + + setSchedules(data); + } catch (err: any) { + console.error('[DEBUG] 加载失败:', err); + setError(err.message || '未知错误'); + } finally { + setLoading(false); + console.log('[DEBUG] 加载完成'); + } + }; + + console.log('[DEBUG] 渲染状态:', { loading, error, schedulesCount: schedules.length }); + + if (loading) { + return ( +
+

加载中...

+
+ ); + } + + if (error) { + return ( +
+

错误

+

{error}

+ +
+ ); + } + + return ( +
+

护理计划调试版

+

日程数量: {schedules.length}

+ +

原始数据:

+
+        {JSON.stringify(schedules, null, 2)}
+      
+ +

日程列表:

+
    + {schedules.map((schedule, index) => ( +
  • + {schedule.title} - {schedule.schedule_time} +
    + 类型: {schedule.schedule_type}, 激活: {schedule.is_active ? '是' : '否'} +
  • + ))} +
+ + +
+ ); +}; + +export default CarePlanDebug;