Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/features/dashboard/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/features/dashboard/components/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default function Dashboard() {
data && (
<div className="flex min-h-0 flex-1 gap-4">
<AnalysisChart stats={data.daily} />
<SpeciesCountPanel />
<SpeciesCountPanel counts={data.speciesCounts} />
</div>
)
)}
Expand Down
17 changes: 13 additions & 4 deletions src/features/dashboard/components/SpeciesCountPanel.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<section className="glass flex w-90 shrink-0 flex-col rounded-xl [--glass-from:0.78] [--glass-to:0.4] px-5.25 py-4.75">
<h2 className="text-title-md mb-2.5">종별 등록 개체 수</h2>
{speciesCounts.map(({ name, count }) => (
{counts.length === 0 && (
<p className="text-body text-fg-tertiary py-1.75">
등록된 개체가 없어요
</p>
)}
{counts.map(({ name, count }) => (
<div key={name} className="flex flex-col gap-1.25 py-1.75">
<div className="text-body flex">
<p className="flex-1">{name}</p>
Expand Down
13 changes: 0 additions & 13 deletions src/features/dashboard/data.ts

This file was deleted.