import { useState } from 'react'; import { ChevronLeft, ChevronRight } from 'lucide-react'; import { clsx } from 'clsx'; import type { inferRouterOutputs } from '@trpc/server'; import type { AppRouter } from '@cockpit/api/router'; import { trpc } from '../lib/trpc'; import { Card } from '../components/ui/Card'; import { SkeletonCard } from '../components/ui/SkeletonCard'; type HistoryPerson = inferRouterOutputs['dayEntry']['historyForDate']['entries'][number]; const AMPEL_META: Record = { green: { label: 'Im Plan', badge: 'bg-[var(--color-ampel-green-bg)] text-[var(--color-ampel-green-fg)]' }, amber: { label: 'Gefährdet', badge: 'bg-[var(--color-ampel-amber-bg)] text-[var(--color-ampel-amber-fg)]' }, red: { label: 'Blockiert', badge: 'bg-[var(--color-ampel-red-bg)] text-[var(--color-ampel-red-fg)]' }, }; const TREND_LABEL: Record = { besser: '↗ Besser', gleich: '→ Gleich', schlechter: '↘ Schlechter', }; function formatDateLong(iso: string): string { return new Intl.DateTimeFormat('de-DE', { timeZone: 'Europe/Berlin', weekday: 'short', day: 'numeric', month: 'long', year: 'numeric', }).format(new Date(`${iso}T12:00:00Z`)); } const todayStr = new Intl.DateTimeFormat('en-CA', { timeZone: 'Europe/Berlin' }).format(new Date()); export function HistorieRoute() { const [date, setDate] = useState(undefined); const q = trpc.dayEntry.historyForDate.useQuery({ date }); if (q.isPending) return ; if (!q.data) return null; const { date: current, prevDate, nextDate, entries, ohneEintrag } = q.data; return (

Historie

Was hat das Team an einem Tag gemacht — Reflexion & ToDos.

{formatDateLong(current)} setDate(e.target.value || undefined)} className="ml-2 rounded-[var(--radius-md)] border border-[var(--color-border)] bg-white px-2 py-1.5 text-sm" />
{entries.length === 0 ? (

Keine Einträge an diesem Tag.

) : (
{entries.map((p) => ( ))}
)} {ohneEintrag.length > 0 && (

Ohne Eintrag an diesem Tag: {ohneEintrag.join(', ')}

)}
); } function PersonCard({ person: p }: { person: HistoryPerson }) { const ampel = p.ampel ? AMPEL_META[p.ampel] : null; return (

{p.name}

{ampel && ( {ampel.label} )} {p.trend && ( {TREND_LABEL[p.trend] ?? p.trend} )} {p.status === 'begun' && ( nicht reflektiert )}
{p.todos.length > 0 && (
    {p.todos.map((t) => (
  • {t.title} {t.unplanned && ( ungeplant )} {t.status === 'dropped' && t.dropReason && ( — {t.dropReason} )}
  • ))}
)} {p.reflectionText && (

{p.reflectionText}

)} {p.todos.length === 0 && !p.reflectionText && (

Keine Details.

)}
); }