From 95bb8c70a98fabae2a60b251489a59065b2978d1 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 15 Feb 2026 17:09:51 +0900 Subject: fix(types): use CardStateType instead of number for card state fields Card and StudyCard interfaces used generic number for state, causing type errors when indexing Record maps. Also adds missing FSRS fields to client Card interface to match API response. Co-Authored-By: Claude Opus 4.6 --- src/client/pages/StudyPage.tsx | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/client/pages/StudyPage.tsx') diff --git a/src/client/pages/StudyPage.tsx b/src/client/pages/StudyPage.tsx index 2649069..9127e39 100644 --- a/src/client/pages/StudyPage.tsx +++ b/src/client/pages/StudyPage.tsx @@ -20,6 +20,7 @@ import { ApiClientError, apiClient } from "../api"; import { studyDataAtomFamily } from "../atoms"; import { EditNoteModal } from "../components/EditNoteModal"; import { ErrorBoundary } from "../components/ErrorBoundary"; +import type { CardStateType } from "../db"; import { queryClient } from "../queryClient"; import { renderCard } from "../utils/templateRenderer"; @@ -40,7 +41,10 @@ const RatingStyles: Record = { 4: "bg-easy hover:bg-easy/90 focus:ring-easy/30", }; -const CardStateBadge: Record = { +const CardStateBadge: Record< + CardStateType, + { label: string; className: string } +> = { 0: { label: "New", className: "bg-info/10 text-info" }, 1: { label: "Learning", className: "bg-warning/10 text-warning" }, 2: { label: "Review", className: "bg-success/10 text-success" }, @@ -448,14 +452,12 @@ function StudySession({ /> {/* Card state badge */} - {CardStateBadge[currentCard.state] && ( - - {CardStateBadge[currentCard.state].label} - - )} + + {CardStateBadge[currentCard.state].label} + {!isFlipped ? ( <>