From 3a7fe307d63ac415cc26501dea91d5a2f894086d Mon Sep 17 00:00:00 2001 From: s26011-cloud Date: Mon, 23 Nov 2026 12:30:17 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=8C=80=EC=8B=9C=EB=B3=B4=EB=93=9C=20?= =?UTF-8?q?=EC=A2=85=EB=B3=84=20=EB=93=B1=EB=A1=9D=20=EA=B0=9C=EC=B2=B4=20?= =?UTF-8?q?=EC=88=98=EB=A5=BC=20=EC=9A=B4=EC=98=81=20=ED=86=B5=EA=B3=84=20?= =?UTF-8?q?API=20=EA=B0=92=EC=9C=BC=EB=A1=9C=20=EB=B3=B4=EC=97=AC=20?= =?UTF-8?q?=EC=A4=8C=20(#52)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Stats에 speciesCounts를 추가하고 SpeciesCountPanel이 그 값을 보여 준다. 퍼블리싱용 고정 데이터(data.ts)는 지운다. 목록이 비면 안내 문구를 보여 준다. --- src/features/dashboard/api.ts | 2 ++ src/features/dashboard/components/Dashboard.tsx | 2 +- .../dashboard/components/SpeciesCountPanel.tsx | 17 +++++++++++++---- src/features/dashboard/data.ts | 13 ------------- 4 files changed, 16 insertions(+), 18 deletions(-) delete mode 100644 src/features/dashboard/data.ts diff --git a/src/features/dashboard/api.ts b/src/features/dashboard/api.ts index 1134c50..35e8b8b 100644 --- a/src/features/dashboard/api.ts +++ b/src/features/dashboard/api.ts @@ -11,6 +11,8 @@ export type Stats = { aiAnalyses: number; aiFailures: number; }[]; + // 개체 많은 순으로 정렬되어 옴. 직접 입력한 종은 speciesId null, name "직접 입력" + speciesCounts: { speciesId: number | null; name: string; count: number }[]; }; export async function getStats() { diff --git a/src/features/dashboard/components/Dashboard.tsx b/src/features/dashboard/components/Dashboard.tsx index e70b343..f023496 100644 --- a/src/features/dashboard/components/Dashboard.tsx +++ b/src/features/dashboard/components/Dashboard.tsx @@ -66,7 +66,7 @@ export default function Dashboard() { data && (
- +
) )} diff --git a/src/features/dashboard/components/SpeciesCountPanel.tsx b/src/features/dashboard/components/SpeciesCountPanel.tsx index 7db44e3..9b0ec80 100644 --- a/src/features/dashboard/components/SpeciesCountPanel.tsx +++ b/src/features/dashboard/components/SpeciesCountPanel.tsx @@ -1,13 +1,22 @@ -import { speciesCounts } from "../data"; +import type { Stats } from "../api"; // Figma species · 종별 등록 개체 수. 막대 길이는 가장 많은 종 대비 비율 -export default function SpeciesCountPanel() { - const max = Math.max(...speciesCounts.map(({ count }) => count)); +export default function SpeciesCountPanel({ + counts, +}: { + counts: Stats["speciesCounts"]; +}) { + const max = Math.max(1, ...counts.map(({ count }) => count)); return (

종별 등록 개체 수

- {speciesCounts.map(({ name, count }) => ( + {counts.length === 0 && ( +

+ 등록된 개체가 없어요 +

+ )} + {counts.map(({ name, count }) => (

{name}

diff --git a/src/features/dashboard/data.ts b/src/features/dashboard/data.ts deleted file mode 100644 index 2178dff..0000000 --- a/src/features/dashboard/data.ts +++ /dev/null @@ -1,13 +0,0 @@ -// 퍼블리싱용 고정 데이터 (Figma W-2). 서버 응답에 종별 개체 수가 생기면(tail-server#162) 교체한다 -export const speciesCounts = [ - { name: "레오파드 게코", count: 812 }, - { name: "크레스티드 게코", count: 401 }, - { name: "비어디드 드래곤", count: 236 }, - { name: "볼 파이톤", count: 188 }, - { name: "가고일 게코", count: 121 }, - { name: "콘 스네이크", count: 97 }, - { name: "블루텅 스킨크", count: 72 }, - { name: "호그노즈 스네이크", count: 51 }, - { name: "육지 거북", count: 35 }, - { name: "킹 스네이크", count: 18 }, -];