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 }, -];