diff --git a/src/components/layout/notification-center.tsx b/src/components/layout/notification-center.tsx index 697d5b3..6a5eb34 100644 --- a/src/components/layout/notification-center.tsx +++ b/src/components/layout/notification-center.tsx @@ -20,11 +20,12 @@ import { getDismissedNotificationIds, type NotificationItem, } from "@/lib/notifications"; -import { useT } from "@/stores/preferences-context"; +import { usePreferences } from "@/stores/preferences-context"; import { useShellFeed } from "@/stores/shell-feed-context"; export function NotificationCenter() { - const t = useT(); + const { t, locale } = usePreferences(); + const dateLocale = () => (locale() === "tr" ? "tr-TR" : "en-US"); const navigate = useNavigate(); const feed = useShellFeed(); const [open, setOpen] = createSignal(false); @@ -76,7 +77,7 @@ export function NotificationCenter() { type: "event", title: e.title, description: e.starts_at - ? new Date(e.starts_at).toLocaleString([], { + ? new Date(e.starts_at).toLocaleString(dateLocale(), { month: "short", day: "numeric", hour: "2-digit", @@ -100,7 +101,7 @@ export function NotificationCenter() { type: "exam", title: ex.title, description: ex.starts_at - ? new Date(ex.starts_at).toLocaleString([], { + ? new Date(ex.starts_at).toLocaleString(dateLocale(), { month: "short", day: "numeric", hour: "2-digit", @@ -123,7 +124,7 @@ export function NotificationCenter() { type: "homework", title: hw.title, description: hw.due_at - ? `${t("homework.dueAt")}: ${new Date(hw.due_at).toLocaleDateString([], { + ? `${t("homework.dueAt")}: ${new Date(hw.due_at).toLocaleDateString(dateLocale(), { month: "short", day: "numeric", })}` @@ -203,8 +204,8 @@ export function NotificationCenter() { "topbar-control relative flex h-9 w-9 shrink-0 cursor-pointer items-center justify-center rounded-xl outline-hidden focus-visible:ring-2 focus-visible:ring-ring", open() && "bg-muted text-foreground" )} - title={t("rightPanel.messagesTitle")} - aria-label="Bildirimler" + title={t("notifications.title")} + aria-label={t("notifications.title")} > 0}> @@ -219,7 +220,7 @@ export function NotificationCenter() {
-

Bildirimler

+

{t("notifications.title")}

0}> {unreadCount()} @@ -234,10 +235,10 @@ export function NotificationCenter() { size="sm" class="h-7 px-2 text-[11px] font-semibold text-muted-foreground hover:text-destructive hover:bg-destructive/10 rounded-lg" onClick={handleDismissAll} - title="Tüm Bildirimleri Temizle" + title={t("notifications.clearAll")} > - Tümünü Sil + {t("notifications.clearAll")}
@@ -259,7 +260,7 @@ export function NotificationCenter() {

- Henüz yeni bir bildiriminiz yok. + {t("notifications.empty")}

} @@ -302,7 +303,7 @@ export function NotificationCenter() { - }> + }> 0} fallback={} diff --git a/src/pages/pomodoro-page.tsx b/src/pages/pomodoro-page.tsx index 338daa7..e7768d3 100644 --- a/src/pages/pomodoro-page.tsx +++ b/src/pages/pomodoro-page.tsx @@ -1,4 +1,4 @@ -import { Show, Suspense, createMemo, createResource, createSignal } from "solid-js"; +import { For, Show, Suspense, createEffect, createMemo, createResource, createSignal } from "solid-js"; import type { ColumnDef } from "@tanstack/solid-table"; import { getPomodoroMe } from "@/api/pomodoro"; import { postPomodoroFinish } from "@/api/pomodoro"; @@ -9,9 +9,9 @@ import { PageHeader } from "@/components/layout/page-header"; 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 { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; import { IconCheck, IconClock } from "@/components/ui/icons"; -import { PageSpinner } from "@/components/ui/page-spinner"; +import { Input } from "@/components/ui/input"; import { createFlash } from "@/lib/flash"; import { createNow } from "@/lib/create-now"; import { triggerConfetti } from "@/lib/confetti"; @@ -19,6 +19,20 @@ import { cn } from "@/lib/cn"; import { formatDateTime, formatDurationClock } from "@/lib/format"; import { usePreferences, useT } from "@/stores/preferences-context"; +const DURATION_KEY = "hezarfen.pomodoro.targetMinutes"; +const PRESET_MINUTES = [15, 25, 45, 60]; +const DEFAULT_MINUTES = 25; +const MAX_MINUTES = 180; + +function readTargetMinutes(): number { + try { + const saved = Number(localStorage.getItem(DURATION_KEY)); + return Number.isFinite(saved) && saved > 0 && saved <= MAX_MINUTES ? saved : DEFAULT_MINUTES; + } catch { + return DEFAULT_MINUTES; + } +} + export default function PomodoroPage() { return ( @@ -40,6 +54,41 @@ function PomodoroContent() { const current = running(); return current ? now() - current.started_at : null; }); + + // Pomodoro-style countdown: purely a client-side display target — the + // backend session is still just an open-ended start/finish stopwatch, so + // this only changes what the clock shows, not what gets recorded. + const [targetMinutes, setTargetMinutes] = createSignal(readTargetMinutes()); + createEffect(() => { + try { + localStorage.setItem(DURATION_KEY, String(targetMinutes())); + } catch { + // Duration just won't be remembered next visit. + } + }); + const targetMs = () => targetMinutes() * 60_000; + const remainingMs = createMemo(() => { + const dur = runningDuration(); + return dur == null ? null : Math.max(0, targetMs() - dur); + }); + const overtimeMs = createMemo(() => { + const dur = runningDuration(); + return dur == null ? 0 : Math.max(0, dur - targetMs()); + }); + const isOvertime = () => overtimeMs() > 0; + + // One flash when the countdown crosses zero, not one per tick. + const [targetNotified, setTargetNotified] = createSignal(false); + createEffect(() => { + if (!running()) { + setTargetNotified(false); + return; + } + if (isOvertime() && !targetNotified()) { + setTargetNotified(true); + setFlash(t("pomodoro.targetReached")); + } + }); const finishedSessions = createMemo(() => (log()?.items ?? []).filter((item) => item.finished_at != null)); const todayFocus = createMemo(() => { const start = new Date(now()); @@ -91,8 +140,7 @@ function PomodoroContent() { const progressPercent = createMemo(() => { const dur = runningDuration(); if (!dur) return 0; - const targetMs = 25 * 60 * 1000; - return Math.min(1, dur / targetMs); + return Math.min(1, dur / targetMs()); }); const dashOffset = createMemo(() => { @@ -157,27 +205,65 @@ function PomodoroContent() {
-

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

-

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

+ {running() ? (isOvertime() ? t("pomodoro.overtime") : t("pomodoro.remaining")) : t("pomodoro.total")} +

+

+ {running() && isOvertime() && "+"} + {formatDurationClock(running() ? (isOvertime() ? overtimeMs() : remainingMs()) : log()?.total_focus_ms)}

- void run(postPomodoroStart, t("pomodoro.started"))}> - - {t("pomodoro.start")} +
+ void run(postPomodoroStart, t("pomodoro.started"))}> + + {t("pomodoro.start")} + + } + > + - } - > - - + + + {/* Session length: like the classic Pomodoro technique, this is + configurable — locked once a session is running so it can't + drift mid-focus. */} +
+ + {(minutes) => ( + + )} + + { + const value = Number(event.currentTarget.value); + if (Number.isFinite(value) && value > 0 && value <= MAX_MINUTES) setTargetMinutes(value); + }} + /> +
+
@@ -208,7 +294,7 @@ function PomodoroContent() {

- }> + }>