'use client'; import { SKILLS_DEF } from '@/lib/game/constants'; import { formatStudyTime } from '@/lib/game/formatting'; import { Button } from '@/components/ui/button'; import { Progress } from '@/components/ui/progress'; import type { StudyTarget } from '@/lib/game/types'; export interface StudyProgressProps { currentStudyTarget: StudyTarget; skills: Record; studySpeedMult: number; cancelStudy: () => void; } export function StudyProgress({ currentStudyTarget, skills, studySpeedMult, cancelStudy }: StudyProgressProps) { const { id, progress, required } = currentStudyTarget; // Get skill name const baseId = id.includes('_t') ? id.split('_t')[0] : id; const skillDef = SKILLS_DEF[baseId]; const skillName = skillDef?.name || id; // Get current level const currentLevel = skills[id] || skills[baseId] || 0; // Calculate progress percentage const progressPercent = Math.min((progress / required) * 100, 100); // Estimated completion const remainingHours = required - progress; const effectiveSpeed = studySpeedMult; const realTimeRemaining = remainingHours / effectiveSpeed; return (
{skillName} Level {currentLevel} → {currentLevel + 1}
{formatStudyTime(progress)} / {formatStudyTime(required)} {progressPercent.toFixed(1)}%
{studySpeedMult > 1 && (
Speed: {(studySpeedMult * 100).toFixed(0)}% • ETA: {formatStudyTime(realTimeRemaining)}
)}
); }