diff --git a/src/i18n/messages.ts b/src/i18n/messages.ts index 41db7f5..c497472 100644 --- a/src/i18n/messages.ts +++ b/src/i18n/messages.ts @@ -413,6 +413,15 @@ export type MessageKey = | "pomodoro.startedAt" | "pomodoro.finishedAt" | "pomodoro.duration" + | "pomodoro.focusConsole" + | "pomodoro.current" + | "pomodoro.today" + | "pomodoro.average" + | "pomodoro.sessions" + | "pomodoro.idleHelp" + | "pomodoro.runningSince" + | "pomodoro.lastSession" + | "pomodoro.noRecentSession" | "attempt.title" | "attempt.openRoom" | "attempt.start" @@ -1141,6 +1150,15 @@ const en: Dict = { "pomodoro.startedAt": "Started", "pomodoro.finishedAt": "Finished", "pomodoro.duration": "Duration", + "pomodoro.focusConsole": "Focus console", + "pomodoro.current": "Current focus", + "pomodoro.today": "Today", + "pomodoro.average": "Average", + "pomodoro.sessions": "Sessions", + "pomodoro.idleHelp": "Ready when you are. Start one focused study block.", + "pomodoro.runningSince": "Started {time}", + "pomodoro.lastSession": "Last finished {time}", + "pomodoro.noRecentSession": "No completed session yet.", "attempt.title": "Exam room", "attempt.openRoom": "Open exam room", "attempt.start": "Start exam", @@ -1874,6 +1892,15 @@ const tr: Dict = { "pomodoro.startedAt": "Başlangıç", "pomodoro.finishedAt": "Bitiş", "pomodoro.duration": "Süre", + "pomodoro.focusConsole": "Odak paneli", + "pomodoro.current": "Mevcut odak", + "pomodoro.today": "Bugün", + "pomodoro.average": "Ortalama", + "pomodoro.sessions": "Oturum", + "pomodoro.idleHelp": "Hazır olduğunda tek bir odaklı çalışma bloğu başlat.", + "pomodoro.runningSince": "Başlangıç: {time}", + "pomodoro.lastSession": "Son bitiş: {time}", + "pomodoro.noRecentSession": "Henüz tamamlanmış oturum yok.", "attempt.title": "Sınav odası", "attempt.openRoom": "Sınav odasını aç", "attempt.start": "Sınava başla", diff --git a/src/pages/pomodoro-page.tsx b/src/pages/pomodoro-page.tsx index af9226e..4099af9 100644 --- a/src/pages/pomodoro-page.tsx +++ b/src/pages/pomodoro-page.tsx @@ -10,7 +10,7 @@ import { Alert } from "@/components/ui/alert"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { DataTable } from "@/components/ui/data-table"; -import { IconClock } from "@/components/ui/icons"; +import { IconCheck, IconClock } from "@/components/ui/icons"; import { PageSpinner } from "@/components/ui/page-spinner"; import { createFlash } from "@/lib/flash"; import { createNow } from "@/lib/create-now"; @@ -38,6 +38,19 @@ function PomodoroContent() { const current = running(); return current ? now() - current.started_at : null; }); + const finishedSessions = createMemo(() => (log()?.items ?? []).filter((item) => item.finished_at != null)); + const todayFocus = createMemo(() => { + const start = new Date(now()); + start.setHours(0, 0, 0, 0); + const startMs = start.getTime(); + return finishedSessions().reduce((total, item) => item.started_at >= startMs ? total + (item.duration_ms ?? 0) : total, 0); + }); + const averageFocus = createMemo(() => { + const items = finishedSessions(); + if (items.length === 0) return null; + return Math.round(items.reduce((total, item) => total + (item.duration_ms ?? 0), 0) / items.length); + }); + const lastFinished = createMemo(() => finishedSessions()[0]?.finished_at ?? null); const columns = createMemo>["items"][number]>[]>(() => [ { accessorKey: "started_at", @@ -77,20 +90,6 @@ function PomodoroContent() { eyebrow={t("nav.pomodoro")} title={t("pomodoro.title")} description={t("pomodoro.subtitle")} - actions={ - void run(postPomodoroStart, t("pomodoro.started"))}> - {t("pomodoro.start")} - - } - > - - - } /> @@ -98,38 +97,78 @@ function PomodoroContent() { {error() && {error()}} -
- -

{t("pomodoro.total")}

-

{formatDurationClock(log()?.total_focus_ms)}

- - } - > -
-
- - +
+
+
+
+ + - {t("pomodoro.running")} +
+

{t("pomodoro.focusConsole")}

+

+ + {(session) => t("pomodoro.runningSince", { time: formatDateTime(session().started_at, locale()) })} + +

+
-

{formatDurationClock(runningDuration())}

-
- -
-

{t("attempt.status")}

-
- + {running() ? t("pomodoro.running") : t("pomodoro.idle")}
+ +
+
+

{running() ? t("pomodoro.current") : t("pomodoro.total")}

+

+ {formatDurationClock(running() ? runningDuration() : log()?.total_focus_ms)} +

+
+ void run(postPomodoroStart, t("pomodoro.started"))}> + + {t("pomodoro.start")} + + } + > + + +
+
+ +
+
+

{t("pomodoro.today")}

+

{formatDurationClock(todayFocus())}

+
+
+

{t("pomodoro.average")}

+

{formatDurationClock(averageFocus())}

+
+
+

{t("pomodoro.sessions")}

+

{log()?.total ?? 0}

+
-

{t("pomodoro.history")}

+
+
+

{t("pomodoro.history")}

+

+ + {(at) => t("pomodoro.lastSession", { time: formatDateTime(at(), locale()) })} + +

+
+
}>