'use client'; import { useTimerStore } from '@/lib/store'; import { getRemainingMs } from '@/lib/timer-engine'; import type { Timer } from '@/lib/timer-engine'; import { CountdownRing } from './CountdownRing'; import { formatDuration } from '@/lib/format'; import { Coffee, Pause, Play, X, SkipForward, Trophy } from 'lucide-react'; import { showToast } from './Toast'; interface PomodoroViewProps { timer: Timer; } export function PomodoroView({ timer }: PomodoroViewProps) { const now = useTimerStore((s) => s.now); const { pause, resume, dismiss, advancePom } = useTimerStore(); const remaining = getRemainingMs(timer, now); const duration = timer.duration ?? 1; const progress = Math.max(0, remaining / duration); const pomState = timer.pomodoroState; const config = timer.pomodoroConfig; if (!pomState || !config) return null; const isBreak = pomState.isBreak || pomState.isLongBreak; const isPaused = timer.state === 'paused'; const isFiring = timer.state === 'firing'; const isCompleted = timer.state === 'completed'; const roundLabel = isBreak ? pomState.isLongBreak ? 'Long Break' : 'Break' : `Round ${pomState.currentRound} of ${config.rounds}`; const ringColor = isBreak ? 'var(--cm-accent-secondary)' : 'var(--cm-accent)'; // Session complete celebration if (isCompleted) { const totalMinutes = config.workMinutes * config.rounds + config.breakMinutes * (config.rounds - 1) + config.longBreakMinutes; return (

Session Complete!

{timer.label}

{config.rounds} rounds · ~{totalMinutes} minutes of focused work

{Array.from({ length: config.rounds }).map((_, i) => (
))}
); } return (
{/* Header */}
{timer.label}
{/* Round indicator */}
{Array.from({ length: config.rounds }).map((_, i) => (
))}
{/* Countdown ring */}
{formatDuration(remaining)}
{roundLabel}
{/* Status */} {isPaused && (

Paused

)} {isFiring && (

{isBreak ? 'Break over! Start next round?' : 'Time\'s up! Take a break?'}

)} {/* Actions */}
{(timer.state === 'active' || timer.state === 'warning') && ( )} {isPaused && ( )} {isFiring && ( )}
{/* Stats */}
Completed: {pomState.completedRounds}/{config.rounds} Work: {config.workMinutes}m Break: {config.breakMinutes}m
); }