diff --git a/frontend/src/pages/ProjectDetail.tsx b/frontend/src/pages/ProjectDetail.tsx index 7a60b86..483373c 100644 --- a/frontend/src/pages/ProjectDetail.tsx +++ b/frontend/src/pages/ProjectDetail.tsx @@ -36,12 +36,13 @@ export default function ProjectDetail() { useEffect(() => { if (!id) return; + const projectId = Number(id); setLoading(true); Promise.all([ - projectApi.get(id), - projectApi.stats(id), - taskApi.list({ project_id: id }), - artifactApi.list({ project_id: id }), + projectApi.get(projectId), + projectApi.stats(projectId), + taskApi.list({ project_id: projectId }), + artifactApi.list({ project_id: projectId }), ]) .then(([p, s, t, a]) => { setProject(p); @@ -65,6 +66,15 @@ export default function ProjectDetail() { return ; } + const taskStatusDist = stats + ? [ + { status: 'pending', count: stats.pending_tasks }, + { status: 'in_progress', count: stats.in_progress_tasks }, + { status: 'review', count: stats.review_tasks }, + { status: 'done', count: stats.done_tasks }, + ].filter((item) => item.count > 0) + : []; + return (
- {project.budget != null ? `¥${project.budget.toFixed(2)}` : '-'} + {project.budget_limit_cents != null + ? `¥${(project.budget_limit_cents / 100).toFixed(2)}` + : '-'} {dayjs(project.created_at).format('YYYY-MM-DD HH:mm')} @@ -133,15 +145,15 @@ export default function ProjectDetail() { @@ -150,7 +162,7 @@ export default function ProjectDetail() { )} - {stats && ( + {stats && taskStatusDist.length > 0 && ( - {Object.entries(stats.tasks_by_status || {}).map(([status, count]) => ( + {taskStatusDist.map(({ status, count }) => ( {count} ))} - {Object.keys(stats.tasks_by_status || {}).length === 0 && ( - 暂无任务数据 - )} )} @@ -210,8 +219,8 @@ export default function ProjectDetail() { renderItem={(art) => ( )}