"use client"; import { useEffect, useState } from "react"; import { useLocale, useTranslations } from "next-intl"; import { CloudOff } from "lucide-react"; import { fmtDateTime } from "@/lib/field/format"; import { listOutbox, subscribeOffline } from "@/lib/offline/outbox"; import { isPending } from "@/lib/offline/outbox-core"; import type { OutboxEntry } from "@/lib/offline/types"; import { card } from "./ui"; /** * L12 optimistic view: manual time entries and „Für heute beenden" stored on this device but not * yet transmitted (offline outbox) — shown with a pending badge until the server confirms them. */ export function LocalPendingTimes() { const t = useTranslations("field"); const locale = useLocale(); const [ops, setOps] = useState([]); useEffect(() => { let cancelled = false; const load = () => void listOutbox() .then((l) => { if (!cancelled) setOps(l.ops.filter((o) => isPending(o) && (o.opType === "time.add_manual" || o.opType === "time.propose_correction" || o.opType === "session.stop_day"))); }) .catch(() => undefined); load(); const unsubscribe = subscribeOffline(load); return () => { cancelled = true; unsubscribe(); }; }, []); if (!ops.length) return null; return (

{t("myTime.localTitle")}

); }