Files
everythingbutwork/packages/shared/src/schemas/day-entry.ts
T
Raffael SheikhandClaude Opus 4.8 6acf9977ec Historie: Task-Notizen + Link sichtbar, Navigation zu Tagen mit Einträgen
- Notizfeld pro Task in der Reflexion (optional, jeder Status) — nutzt das
  bestehende dropReason-Feld (Limit 200->500). Wird in der Historie bei JEDEM
  Status angezeigt (bisher nur bei "verworfen").
- Optionaler Tages-Link wird in der Historie jetzt angezeigt.
- Historie-Pfeile springen zum naechsten/vorherigen Tag MIT Eintraegen statt
  starr ueber Werktage — Wochenend-Arbeit (z. B. Sa 6.6.) ist nun erreichbar.
  Default-Tag = juengster Tag vor heute mit Eintrag.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-07 13:04:52 +02:00

92 lines
3.0 KiB
TypeScript

import { z } from 'zod';
export const ampelSchema = z.enum(['green', 'amber', 'red']);
export const trendSchema = z.enum(['besser', 'gleich', 'schlechter']);
export const bezugKindSchema = z.enum(['project', 'deal', 'campaign', 'allgemein']);
export const todoStatusSchema = z.enum(['open', 'done', 'dropped']);
export const todoInputSchema = z.object({
title: z.string().min(1).max(200),
bezugKind: bezugKindSchema.optional(),
bezugId: z.string().uuid().optional(),
});
export type TodoInput = z.infer<typeof todoInputSchema>;
export const checkInInput = z.object({
todos: z.array(todoInputSchema).min(1),
date: z
.string()
.regex(/^\d{4}-\d{2}-\d{2}$/)
.optional(), // Default: heute
});
export type CheckInInput = z.infer<typeof checkInInput>;
export const submitReflectionInput = z.object({
dayEntryId: z.string().uuid(),
todos: z
.array(
z.object({
id: z.string().uuid(),
status: todoStatusSchema,
// Optionale Notiz pro Task (frühere „Verworfen-Grund"-Spalte, jetzt für
// jeden Status als freie Beschreibung nutzbar).
dropReason: z.string().max(500).optional(),
}),
)
.default([]),
reflectionText: z.string().max(1000).default(''),
ampel: ampelSchema,
trend: trendSchema.nullable().optional(),
blocker: z
.object({
title: z.string().min(1).max(200),
description: z.string().max(1000).optional(),
})
.optional(),
url: z.string().url().optional(),
});
export type SubmitReflectionInput = z.infer<typeof submitReflectionInput>;
export const todoMutationInput = z.object({
dayEntryId: z.string().uuid(),
todos: z.array(todoInputSchema).min(0),
});
export type TodoMutationInput = z.infer<typeof todoMutationInput>;
export const editTodoTitleInput = z.object({
todoId: z.string().uuid(),
title: z.string().min(1).max(200),
});
export type EditTodoTitleInput = z.infer<typeof editTodoTitleInput>;
// Einzelnes ToDo mitten am Tag zum heutigen Tageseintrag hinzufügen.
export const addTodoInput = z.object({
title: z.string().min(1).max(200),
bezugKind: bezugKindSchema.optional(),
bezugId: z.string().uuid().optional(),
});
export type AddTodoInput = z.infer<typeof addTodoInput>;
// Ungeplant dazugekommenes & bereits erledigtes Item nachtragen (Drive-by).
export const addUnplannedInput = z.object({
title: z.string().min(1).max(200),
bezugKind: bezugKindSchema.optional(),
bezugId: z.string().uuid().optional(),
});
export type AddUnplannedInput = z.infer<typeof addUnplannedInput>;
export const historyForDateInput = z.object({
date: z
.string()
.regex(/^\d{4}-\d{2}-\d{2}$/)
.optional(), // Default: vorheriger Werktag
});
export type HistoryForDateInput = z.infer<typeof historyForDateInput>;
export const markAbsentInput = z.object({
from: z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
to: z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
reason: z.enum(['urlaub', 'krank', 'sonstiges']),
});
export type MarkAbsentInput = z.infer<typeof markAbsentInput>;