This commit is contained in:
2025-12-13 14:46:20 +08:00
parent 81306fdc04
commit ff188284bf

View File

@@ -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<any[]>([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(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 (
<div style={{ padding: '20px' }}>
<h1>...</h1>
</div>
);
}
if (error) {
return (
<div style={{ padding: '20px', color: 'red' }}>
<h1></h1>
<p>{error}</p>
<button onClick={loadSchedules}></button>
</div>
);
}
return (
<div style={{ padding: '20px' }}>
<h1></h1>
<p>: {schedules.length}</p>
<h2>:</h2>
<pre style={{ background: '#f5f5f5', padding: '10px', overflow: 'auto' }}>
{JSON.stringify(schedules, null, 2)}
</pre>
<h2>:</h2>
<ul>
{schedules.map((schedule, index) => (
<li key={index}>
<strong>{schedule.title}</strong> - {schedule.schedule_time}
<br />
: {schedule.schedule_type}, : {schedule.is_active ? '是' : '否'}
</li>
))}
</ul>
<button onClick={loadSchedules} style={{ marginTop: '20px', padding: '10px 20px' }}>
</button>
</div>
);
};
export default CarePlanDebug;