'use client'; import { Button } from '@/components/ui/button'; import { Progress } from '@/components/ui/progress'; import { BookOpen, X } from 'lucide-react'; import { useGameContext } from '../GameContext'; import { formatStudyTime } from '../types'; import { SKILLS_DEF, SPELLS_DEF } from '@/lib/game/constants'; interface StudyProgressProps { target: NonNullable['store']['currentStudyTarget']>; showCancel?: boolean; speedLabel?: string; } export function StudyProgress({ target, showCancel = true, speedLabel }: StudyProgressProps) { const { store, studySpeedMult } = useGameContext(); const progressPct = Math.min(100, (target.progress / target.required) * 100); const isSkill = target.type === 'skill'; const def = isSkill ? SKILLS_DEF[target.id] : SPELLS_DEF[target.id]; const currentLevel = isSkill ? store.skills[target.id] || 0 : 0; const handleCancel = () => { // Calculate retention bonus from knowledge retention skill const retentionBonus = 0.2 * (store.skills.knowledgeRetention || 0); store.cancelStudy(retentionBonus); }; return (
{def?.name} {isSkill && ` Lv.${currentLevel + 1}`}
{showCancel && ( )}
{formatStudyTime(target.progress)} / {formatStudyTime(target.required)} {speedLabel ?? `${studySpeedMult.toFixed(1)}x speed`}
); } StudyProgress.displayName = "StudyProgress";