Historie: nachträglich reflektieren bis 3 Tage nach dem Tag
ci / quality (push) Failing after 36s
ci / build (push) Has been skipped
deploy / deploy (push) Successful in 55s

Reflexion/ToDo-Bearbeitung war nur bis 06:00 des Folgetags moeglich. Jetzt
3-Tage-Nachfrist (isEditableWithinGrace) und ein Bearbeiten-Weg aus der Historie:

- werktag: isEditableWithinGrace(entryDate, now, 3) + Tests
- submitReflection/editTodoTitle: Sperre auf die 3-Tage-Nachfrist gelockert
- neue Query dayEntry.ownForDate(date): eigener Tageseintrag + editable-Flag
- reflexion.tsx liest ?date= und laedt vergangene Tage; Felder werden mit der
  bestehenden Reflexion vorbefuellt
- historie.tsx: "Bearbeiten"-Button am eigenen Eintrag (wenn <= 3 Tage)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Raffael SheikhandClaude Opus 4.8 committed 2026-06-07 13:13:38 +02:00
1 parent ccd5c42709
commit b340b45110
5 files changed
+172 -50

No files matched your search

+35 -3
View File
@@ -1,12 +1,15 @@
import { useState } from 'react';
import { ChevronLeft, ChevronRight } from 'lucide-react';
import { useNavigate } from 'react-router';
import { ChevronLeft, ChevronRight, Pencil } 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 { Button } from '../components/ui/Button';
import { SkeletonCard } from '../components/ui/SkeletonCard';
import { ErrorState } from '../components/ui/ErrorState';
import { useCurrentUser } from '../hooks/useCurrentUser';
type HistoryPerson = inferRouterOutputs<AppRouter>['dayEntry']['historyForDate']['entries'][number];
@@ -42,8 +45,18 @@ function formatDateLong(iso: string): string {
const todayStr = new Intl.DateTimeFormat('en-CA', { timeZone: 'Europe/Berlin' }).format(new Date());
// Editierbar bis 3 Kalendertage nach dem Tag (Spiegel der Backend-Nachfrist).
function isWithinGraceFE(dateIso: string): boolean {
const cur = new Date(`${dateIso}T12:00:00Z`).getTime();
const today = new Date(`${todayStr}T12:00:00Z`).getTime();
const diffDays = Math.round((today - cur) / 86_400_000);
return diffDays >= 0 && diffDays <= 3;
}
export function HistorieRoute() {
const [date, setDate] = useState<string | undefined>(undefined);
const me = useCurrentUser();
const navigate = useNavigate();
const q = trpc.dayEntry.historyForDate.useQuery({ date });
if (q.isPending) return <SkeletonCard lines={6} />;
@@ -55,6 +68,7 @@ export function HistorieRoute() {
/>
);
const { date: current, prevDate, nextDate, entries, ohneEintrag } = q.data;
const editableDay = isWithinGraceFE(current);
return (
<div className="space-y-6">
@@ -103,7 +117,12 @@ export function HistorieRoute() {
) : (
<div className="space-y-3">
{entries.map((p) => (
<PersonCard key={p.userId} person={p} />
<PersonCard
key={p.userId}
person={p}
canEdit={p.userId === me?.id && editableDay}
onEdit={() => navigate(`/reflexion?date=${current}`)}
/>
))}
</div>
)}
@@ -117,7 +136,15 @@ export function HistorieRoute() {
);
}
function PersonCard({ person: p }: { person: HistoryPerson }) {
function PersonCard({
person: p,
canEdit,
onEdit,
}: {
person: HistoryPerson;
canEdit: boolean;
onEdit: () => void;
}) {
const ampel = p.ampel ? AMPEL_META[p.ampel] : null;
return (
<Card.Root>
@@ -139,6 +166,11 @@ function PersonCard({ person: p }: { person: HistoryPerson }) {
nicht reflektiert
</span>
)}
{canEdit && (
<Button size="sm" variant="ghost" className="ml-auto" onClick={onEdit}>
<Pencil size={13} /> Bearbeiten
</Button>
)}
</div>
{p.todos.length > 0 && (