Your favorite shift management application!
feat: add calendar notes feature with CRUD operations and UI integration
panteLx6988f795e2eb
diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.mdnew file mode 100644index 0000000..17891c8--- /dev/null+++ b/.github/copilot-instructions.md@@ -0,0 +1,166 @@+# BetterShift AI Coding Assistant Instructions++## Architecture Overview++**BetterShift** is a Next.js 16 App Router shift management application with SQLite database, designed for managing work schedules across multiple calendars.++### Core Architecture++- **Frontend**: Next.js 16 App Router (`app/` directory), React 19, client-side state management+- **Backend**: Next.js API Routes (`app/api/`) with server-side logic+- **Database**: SQLite via Drizzle ORM, file-based at `./data/sqlite.db`+- **i18n**: next-intl with German/English support, cookie-based preference + browser detection+- **Styling**: Tailwind CSS 4 with shadcn/ui components (`components/ui/`)++### Data Model (lib/db/schema.ts)++Four main tables with cascade delete relationships:++- `calendars` → `shifts` (via calendarId), `shiftPresets`, `calendarNotes`+- `shiftPresets` → `shifts` (via presetId, set null on delete)+- All IDs use `crypto.randomUUID()`, timestamps stored as integers+- Password hashing uses SHA-256 (see `lib/password-utils.ts`)++## Critical Development Patterns++### Database Workflow++```bash+# After schema changes in lib/db/schema.ts:+npm run db:generate # Creates migration in drizzle/+npm run db:migrate # Runs pending migrations+```++**Important**: Migrations are committed to git. Schema changes require both updating `lib/db/schema.ts` AND running migrations.++### API Route Patterns++All API routes follow this structure (see `app/api/shifts/route.ts`):++```typescript+// GET with optional query params for filtering+export async function GET(request: Request) {+ const { searchParams } = new URL(request.url);+ const calendarId = searchParams.get("calendarId");+ // Always validate required params+ if (!calendarId) return NextResponse.json({ error: "..." }, { status: 400 });+}++// Dynamic routes use async params (Next.js 16)+export async function PUT(+ request: Request,+ { params }: { params: Promise<{ id: string }> }+) {+ const { id } = await params; // Must await!+}+```++### Password Protection Flow++Calendars can be password-protected. The workflow is:++1. Check localStorage for `calendar_password_${calendarId}`+2. Verify via `/api/calendars/[id]/verify-password` POST endpoint+3. On 401, show `PasswordDialog`, store password in localStorage+4. Use `pendingAction` state pattern to retry after password entry++Example in `app/page.tsx`:++```typescript+setPendingAction({ type: "edit", shiftId: id, formData });+setShowPasswordDialog(true);+// After password success, execute pending action+```++### Client Component State Management++Main page (`app/page.tsx`) uses:++- `useState` for local state (shifts, presets, notes, calendars)+- `useEffect` for data fetching on calendar/date changes+- URL sync via `useRouter().replace()` for selected calendar+- Refresh triggers: `statsRefreshTrigger` counter incremented after mutations++### i18n Implementation++Uses next-intl with auto-detection:++1. Cookie `NEXT_LOCALE` overrides browser preference (see `lib/i18n.ts`)+2. Translation keys in `messages/{de,en}.json`+3. Access via `const t = useTranslations()` then `t("shift.create")`+4. Date formatting requires locale-specific formatters: `locale === "de" ? de : enUS`++### Component Patterns++- **Dialog components** (e.g., `components/note-dialog.tsx`): Control open state via props, reset internal state on close+- **Form submission**: Prevent default, validate, call parent callback, close dialog+- **Preset colors**: Use `PRESET_COLORS` constant array for consistent color picker options+- **Date handling**: Use `formatDateToLocal()` helper for consistent YYYY-MM-DD format++### Calendar Interaction Patterns++- **Left-click day**: Toggle shift using selected preset (requires preset selection)+- **Right-click day**: Open note dialog (`onContextMenu` handler with `e.preventDefault()`)+- **Shift toggle logic**: Check if matching shift exists, delete if present, create if not+- **Notes indicator**: Display `<StickyNote>` icon when day has note++## Docker & Production++### Local Development++```bash+npm install+npm run db:migrate # One-time setup+npm run dev # http://localhost:3000+```++### Docker Deployment++```bash+cp docker-compose.override.yml.example docker-compose.override.yml+docker-compose up -d --build+docker compose exec bettershift npm run db:migrate # Run migrations in container+```++**Critical**: The Dockerfile uses multi-stage build with `next/standalone` output. The `drizzle.config.ts` must be copied to runner stage for migrations to work in production.++## Common Gotchas++1. **Next.js 16 Breaking Change**: Dynamic route params are now async Promises - always `await params`+2. **SQLite Timestamps**: Use `{ mode: "timestamp" }` for date fields, stored as integers, auto-converted to Date objects+3. **Cascade Deletes**: Deleting calendar deletes all shifts/presets/notes via `onDelete: "cascade"`+4. **Preset Auto-Save**: Shift dialog has auto-save-as-preset enabled by default (`saveAsPreset` state)+5. **Color Format**: Always store hex colors (e.g., `#3b82f6`), use 20% opacity for backgrounds (`${color}20`)+6. **Mobile vs Desktop**: Separate calendar selector UIs - mobile uses dialog (`showMobileCalendarDialog`)++## Adding New Features++### New Database Table++1. Add table definition to `lib/db/schema.ts` with relationships+2. Export types: `export type TableName = typeof tableName.$inferSelect;`+3. Run `npm run db:generate && npm run db:push`+4. Create API routes: `app/api/tablename/route.ts` and `app/api/tablename/[id]/route.ts`+5. Add translations to `messages/de.json` and `messages/en.json`++### New Component with Dialog++1. Create in `components/` using shadcn/ui Dialog+2. Props: `open`, `onOpenChange`, `onSubmit`, optional `onDelete`+3. Use `useTranslations()` for all text+4. Reset local state when `open` changes to false+5. Import and integrate in `app/page.tsx`++## Testing & Debugging++- Database GUI: `npm run db:studio` (opens Drizzle Studio)+- Build validation: `npm run build` (checks TypeScript errors)+- Production test: Use Docker locally before deploying+- Check console errors for API failures - all errors logged with `console.error()`++## Important Infos++- Never run `db:push` or suggest running it.+- All code, comments, variable names, and messages must always be in English.+- Prefer safe migrations (db:generate + manual review).+- Never write German code comments.diff --git a/README.md b/README.mdindex 7120f2b..f530ab4 100644--- a/README.md+++ b/README.md@@ -8,6 +8,7 @@ A modern shift management application built with Next.js and SQLite. BetterShift- ⏰ **Shift Management**: Add, edit, and delete shifts with start/end times- 🎨 **Color Coding**: Assign colors to calendars for better visualization- 📋 **Shift Presets**: Create reusable shift templates for faster scheduling+- 📝 **Calendar Notes**: Add custom notes to any day (e.g., "Morning shift because afternoon hairdresser")- 🗓️ **Calendar View**: Interactive monthly calendar with week-based layout- 🔒 **Password Protection**: Secure calendars with optional passwords- 🌐 **Internationalization (i18n)**: Supports multiple languages with automatic detection and manual switchingdiff --git a/app/api/notes/[id]/route.ts b/app/api/notes/[id]/route.tsnew file mode 100644index 0000000..48f85e6--- /dev/null+++ b/app/api/notes/[id]/route.ts@@ -0,0 +1,103 @@+import { NextResponse } from "next/server";+import { db } from "@/lib/db";+import { calendarNotes } from "@/lib/db/schema";+import { eq } from "drizzle-orm";++// GET single calendar note+export async function GET(+ request: Request,+ { params }: { params: Promise<{ id: string }> }+) {+ try {+ const { id } = await params;+ const result = await db+ .select()+ .from(calendarNotes)+ .where(eq(calendarNotes.id, id));++ if (!result[0]) {+ return NextResponse.json(+ { error: "Calendar note not found" },+ { status: 404 }+ );+ }++ return NextResponse.json(result[0]);+ } catch (error) {+ console.error("Failed to fetch calendar note:", error);+ return NextResponse.json(+ { error: "Failed to fetch calendar note" },+ { status: 500 }+ );+ }+}++// PUT update calendar note+export async function PUT(+ request: Request,+ { params }: { params: Promise<{ id: string }> }+) {+ try {+ const { id } = await params;+ const body = await request.json();+ const { note } = body;++ if (!note) {+ return NextResponse.json({ error: "Note is required" }, { status: 400 });+ }++ const [updated] = await db+ .update(calendarNotes)+ .set({+ note,+ updatedAt: new Date(),+ })+ .where(eq(calendarNotes.id, id))+ .returning();++ if (!updated) {+ return NextResponse.json(+ { error: "Calendar note not found" },+ { status: 404 }+ );+ }++ return NextResponse.json(updated);+ } catch (error) {+ console.error("Failed to update calendar note:", error);+ return NextResponse.json(+ { error: "Failed to update calendar note" },+ { status: 500 }+ );+ }+}++// DELETE calendar note+export async function DELETE(+ request: Request,+ { params }: { params: Promise<{ id: string }> }+) {+ try {+ const { id } = await params;++ const result = await db+ .delete(calendarNotes)+ .where(eq(calendarNotes.id, id))+ .returning();++ if (!result[0]) {+ return NextResponse.json(+ { error: "Calendar note not found" },+ { status: 404 }+ );+ }++ return NextResponse.json({ success: true });+ } catch (error) {+ console.error("Failed to delete calendar note:", error);+ return NextResponse.json(+ { error: "Failed to delete calendar note" },+ { status: 500 }+ );+ }+}diff --git a/app/api/notes/route.ts b/app/api/notes/route.tsnew file mode 100644index 0000000..5c3eace--- /dev/null+++ b/app/api/notes/route.ts@@ -0,0 +1,84 @@+import { NextResponse } from "next/server";+import { db } from "@/lib/db";+import { calendarNotes } from "@/lib/db/schema";+import { eq, and, gte, lte } from "drizzle-orm";++// GET calendar notes for a calendar (with optional date filter)+export async function GET(request: Request) {+ try {+ const { searchParams } = new URL(request.url);+ const calendarId = searchParams.get("calendarId");+ const date = searchParams.get("date");++ if (!calendarId) {+ return NextResponse.json(+ { error: "Calendar ID is required" },+ { status: 400 }+ );+ }++ let query = db+ .select()+ .from(calendarNotes)+ .where(eq(calendarNotes.calendarId, calendarId));++ if (date) {+ const targetDate = new Date(date);+ const startOfDay = new Date(targetDate.setHours(0, 0, 0, 0));+ const endOfDay = new Date(targetDate.setHours(23, 59, 59, 999));++ const result = await db+ .select()+ .from(calendarNotes)+ .where(+ and(+ eq(calendarNotes.calendarId, calendarId),+ gte(calendarNotes.date, startOfDay),+ lte(calendarNotes.date, endOfDay)+ )+ );+ return NextResponse.json(result);+ }++ const result = await query;+ return NextResponse.json(result);+ } catch (error) {+ console.error("Failed to fetch calendar notes:", error);+ return NextResponse.json(+ { error: "Failed to fetch calendar notes" },+ { status: 500 }+ );+ }+}++// POST create new calendar note+export async function POST(request: Request) {+ try {+ const body = await request.json();+ const { calendarId, date, note } = body;++ if (!calendarId || !date || !note) {+ return NextResponse.json(+ { error: "Missing required fields" },+ { status: 400 }+ );+ }++ const [calendarNote] = await db+ .insert(calendarNotes)+ .values({+ calendarId,+ date: new Date(date),+ note,+ })+ .returning();++ return NextResponse.json(calendarNote);+ } catch (error) {+ console.error("Failed to create calendar note:", error);+ return NextResponse.json(+ { error: "Failed to create calendar note" },+ { status: 500 }+ );+ }+}diff --git a/app/page.tsx b/app/page.tsxindex 0f37d40..2704a1c 100644--- a/app/page.tsx+++ b/app/page.tsx@@ -13,6 +13,7 @@ import { PasswordDialog } from "@/components/password-dialog";import { ManagePasswordDialog } from "@/components/manage-password-dialog";import { LanguageSwitcher } from "@/components/language-switcher";import { ShiftStats } from "@/components/shift-stats";+import { NoteDialog } from "@/components/note-dialog";import { Button } from "@/components/ui/button";import {Dialog,@@ -26,6 +27,7 @@ import {ChevronLeft,ChevronRight,Calendar as CalendarIcon,+ StickyNote,} from "lucide-react";import {format,@@ -40,7 +42,7 @@ import {endOfWeek,} from "date-fns";import { de, enUS } from "date-fns/locale";-import { ShiftPreset } from "@/lib/db/schema";+import { ShiftPreset, CalendarNote } from "@/lib/db/schema";import { formatDateToLocal } from "@/lib/date-utils";function HomeContent() {@@ -67,6 +69,9 @@ function HomeContent() {useState(false);const [showMobileCalendarDialog, setShowMobileCalendarDialog] =useState(false);+ const [showNoteDialog, setShowNoteDialog] = useState(false);+ const [selectedNote, setSelectedNote] = useState<CalendarNote | undefined>();+ const [notes, setNotes] = useState<CalendarNote[]>([]);const [pendingAction, setPendingAction] = useState<{type: "delete" | "edit";shiftId?: string;@@ -93,9 +98,11 @@ function HomeContent() {if (selectedCalendar) {fetchShifts();fetchPresets();+ fetchNotes();} else {setShifts([]);setPresets([]);+ setNotes([]);}}, [selectedCalendar]);@@ -153,6 +160,18 @@ function HomeContent() {}};+ const fetchNotes = async () => {+ if (!selectedCalendar) return;++ try {+ const response = await fetch(`/api/notes?calendarId=${selectedCalendar}`);+ const data = await response.json();+ setNotes(data);+ } catch (error) {+ console.error("Failed to fetch notes:", error);+ }+ };+const createCalendar = async (name: string,color: string,@@ -297,6 +316,99 @@ function HomeContent() {setShowPasswordDialog(true);};+ const createNote = async (noteText: string, date: Date) => {+ if (!selectedCalendar) return;++ try {+ const response = await fetch("/api/notes", {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({+ calendarId: selectedCalendar,+ date: formatDateToLocal(date),+ note: noteText,+ }),+ });+ const newNote = await response.json();+ setNotes([...notes, newNote]);+ } catch (error) {+ console.error("Failed to create note:", error);+ }+ };++ const updateNote = async (noteId: string, noteText: string) => {+ try {+ const response = await fetch(`/api/notes/${noteId}`, {+ method: "PUT",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({ note: noteText }),+ });+ const updatedNote = await response.json();+ setNotes(notes.map((n) => (n.id === noteId ? updatedNote : n)));+ } catch (error) {+ console.error("Failed to update note:", error);+ }+ };++ const deleteNote = async (noteId: string) => {+ try {+ await fetch(`/api/notes/${noteId}`, { method: "DELETE" });+ setNotes(notes.filter((n) => n.id !== noteId));+ } catch (error) {+ console.error("Failed to delete note:", error);+ }+ };++ const handleNoteSubmit = (noteText: string) => {+ if (selectedNote) {+ updateNote(selectedNote.id, noteText);+ } else if (selectedDate) {+ createNote(noteText, selectedDate);+ }+ };++ const handleNoteDelete = () => {+ if (selectedNote) {+ deleteNote(selectedNote.id);+ }+ };++ const handleDayRightClick = (e: React.MouseEvent, date: Date) => {+ e.preventDefault();+ setSelectedDate(date);+ const existingNote = notes.find(+ (note) => note.date && isSameDay(new Date(note.date), date)+ );+ setSelectedNote(existingNote);+ setShowNoteDialog(true);+ };++ const handleNoteIconClick = (e: React.MouseEvent, date: Date) => {+ e.stopPropagation();+ setSelectedDate(date);+ const existingNote = notes.find(+ (note) => note.date && isSameDay(new Date(note.date), date)+ );+ setSelectedNote(existingNote);+ setShowNoteDialog(true);+ };++ const handleLongPress = (date: Date) => {+ setSelectedDate(date);+ const existingNote = notes.find(+ (note) => note.date && isSameDay(new Date(note.date), date)+ );+ setSelectedNote(existingNote);+ setShowNoteDialog(true);+ };++ const handleNoteDialogChange = (open: boolean) => {+ setShowNoteDialog(open);+ if (!open) {+ setSelectedNote(undefined);+ }+ };+const handleShiftSubmit = (formData: ShiftFormData) => {createShift(formData);};@@ -593,14 +705,35 @@ function HomeContent() {))}{calendarDays.map((day, idx) => {const dayShifts = getShiftsForDate(day);+ const dayNote = notes.find(+ (note) => note.date && isSameDay(new Date(note.date), day)+ );const isCurrentMonth = day.getMonth() === currentDate.getMonth();const isTodayDate = isToday(day);+ // Long press handling for mobile+ let pressTimer: NodeJS.Timeout | null = null;+ const handleTouchStart = (e: React.TouchEvent) => {+ pressTimer = setTimeout(() => handleLongPress(day), 500);+ };+ const handleTouchEnd = () => {+ if (pressTimer) clearTimeout(pressTimer);+ };+return (<buttonkey={idx}onClick={() => handleAddShift(day)}- disabled={!selectedPresetId}+ onContextMenu={(e) => handleDayRightClick(e, day)}+ onTouchStart={handleTouchStart}+ onTouchEnd={handleTouchEnd}+ onTouchMove={handleTouchEnd}+ disabled={false}+ style={{+ WebkitUserSelect: "none",+ userSelect: "none",+ WebkitTouchCallout: "none",+ }}className={`min-h-24 sm:min-h-24 px-0.5 py-1 sm:p-2 rounded-md text-sm transition-all relative flex flex-col border-2${@@ -614,19 +747,37 @@ function HomeContent() {: "border-transparent"}${- selectedPresetId && isCurrentMonth+ isCurrentMonth? "hover:bg-accent cursor-pointer active:bg-accent/80"- : "cursor-not-allowed"+ : selectedPresetId+ ? "cursor-not-allowed"+ : "cursor-pointer"}${!isCurrentMonth ? "opacity-50" : ""}`}><div- className={`text-xs sm:text-xs font-medium mb-0.5 ${+ className={`text-xs sm:text-xs font-medium mb-0.5 flex items-center justify-between ${isTodayDate ? "text-primary font-bold" : ""}`}>- {day.getDate()}+ <span>{day.getDate()}</span>+ {dayNote && (+ <div+ className="group/note relative"+ onClick={(e) => handleNoteIconClick(e, day)}+ title={dayNote.note}+ >+ <StickyNote className="h-3 w-3 text-amber-500 cursor-pointer hover:text-amber-600 transition-colors" />+ {/* Tooltip for desktop */}+ <div className="hidden sm:block absolute z-50 bottom-full right-0 mb-1 invisible group-hover/note:visible opacity-0 group-hover/note:opacity-100 transition-opacity duration-200">+ <div className="bg-popover text-popover-foreground text-xs rounded-md shadow-lg border p-2 max-w-[200px] whitespace-normal break-words">+ {dayNote.note}+ <div className="absolute top-full right-2 -mt-1 border-4 border-transparent border-t-popover"></div>+ </div>+ </div>+ </div>+ )}</div><div className="flex-1 space-y-0.5 overflow-hidden">{dayShifts.slice(0, 2).map((shift) => (@@ -719,6 +870,9 @@ function HomeContent() {? t("shift.createPresetFirst"): t("shift.noShiftsDescription")}</p>+ <p className="text-xs text-muted-foreground/70 mt-2">+ 💡 {t("note.rightClick")}+ </p></div></div>) : (@@ -826,6 +980,14 @@ function HomeContent() {}}/>)}+ <NoteDialog+ open={showNoteDialog}+ onOpenChange={handleNoteDialogChange}+ onSubmit={handleNoteSubmit}+ onDelete={selectedNote ? handleNoteDelete : undefined}+ selectedDate={selectedDate}+ note={selectedNote}+ />{/* Footer */}<div className="border-t bg-background mt-auto">diff --git a/components/note-dialog.tsx b/components/note-dialog.tsxnew file mode 100644index 0000000..123c4a4--- /dev/null+++ b/components/note-dialog.tsx@@ -0,0 +1,115 @@+"use client";++import { useState, useEffect } from "react";+import { useTranslations } from "next-intl";+import {+ Dialog,+ DialogContent,+ DialogHeader,+ DialogTitle,+ DialogDescription,+} from "@/components/ui/dialog";+import { Button } from "@/components/ui/button";+import { Label } from "@/components/ui/label";+import { Textarea } from "@/components/ui/textarea";+import { CalendarNote } from "@/lib/db/schema";+import { formatDateToLocal } from "@/lib/date-utils";+import { format } from "date-fns";+import { de, enUS } from "date-fns/locale";+import { useLocale } from "next-intl";++interface NoteDialogProps {+ open: boolean;+ onOpenChange: (open: boolean) => void;+ onSubmit: (note: string) => void;+ onDelete?: () => void;+ selectedDate?: Date;+ note?: CalendarNote;+}++export function NoteDialog({+ open,+ onOpenChange,+ onSubmit,+ onDelete,+ selectedDate,+ note,+}: NoteDialogProps) {+ const t = useTranslations();+ const locale = useLocale();+ const [noteText, setNoteText] = useState("");++ useEffect(() => {+ if (open) {+ setNoteText(note?.note || "");+ }+ }, [open, note]);++ const handleSubmit = (e: React.FormEvent) => {+ e.preventDefault();+ if (noteText.trim()) {+ onSubmit(noteText);+ setNoteText("");+ onOpenChange(false);+ }+ };++ const handleDelete = () => {+ if (onDelete) {+ onDelete();+ onOpenChange(false);+ }+ };++ const dateLocale = locale === "de" ? de : enUS;+ const formattedDate = selectedDate+ ? format(selectedDate, "PPP", { locale: dateLocale })+ : "";++ return (+ <Dialog open={open} onOpenChange={onOpenChange}>+ <DialogContent>+ <DialogHeader>+ <DialogTitle>{note ? t("note.edit") : t("note.create")}</DialogTitle>+ <DialogDescription>{formattedDate}</DialogDescription>+ </DialogHeader>+ <form onSubmit={handleSubmit} className="space-y-4">+ <div className="space-y-2">+ <Label htmlFor="note">{t("note.note")}</Label>+ <Textarea+ id="note"+ value={noteText}+ onChange={(e) => setNoteText(e.target.value)}+ placeholder={t("note.notePlaceholder")}+ className="min-h-[100px]"+ required+ />+ </div>+ <div className="flex justify-between">+ <div>+ {note && onDelete && (+ <Button+ type="button"+ variant="destructive"+ onClick={handleDelete}+ >+ {t("common.delete")}+ </Button>+ )}+ </div>+ <div className="flex gap-2">+ <Button+ type="button"+ variant="outline"+ onClick={() => onOpenChange(false)}+ >+ {t("common.cancel")}+ </Button>+ <Button type="submit">{t("common.save")}</Button>+ </div>+ </div>+ </form>+ </DialogContent>+ </Dialog>+ );+}diff --git a/drizzle/0003_serious_wolfpack.sql b/drizzle/0003_serious_wolfpack.sqlnew file mode 100644index 0000000..3332bfa--- /dev/null+++ b/drizzle/0003_serious_wolfpack.sql@@ -0,0 +1,9 @@+CREATE TABLE `calendar_notes` (+ `id` text PRIMARY KEY NOT NULL,+ `calendar_id` text NOT NULL,+ `date` integer NOT NULL,+ `note` text NOT NULL,+ `created_at` integer DEFAULT CURRENT_TIMESTAMP NOT NULL,+ `updated_at` integer DEFAULT CURRENT_TIMESTAMP NOT NULL,+ FOREIGN KEY (`calendar_id`) REFERENCES `calendars`(`id`) ON UPDATE no action ON DELETE cascade+);diff --git a/drizzle/meta/0003_snapshot.json b/drizzle/meta/0003_snapshot.jsonnew file mode 100644index 0000000..107d955--- /dev/null+++ b/drizzle/meta/0003_snapshot.json@@ -0,0 +1,380 @@+{+ "version": "6",+ "dialect": "sqlite",+ "id": "bf43fc23-219f-45cc-b9b0-0773af4656b0",+ "prevId": "dff81306-32b6-4fc5-b401-c8be4259b65f",+ "tables": {+ "calendar_notes": {+ "name": "calendar_notes",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "calendar_id": {+ "name": "calendar_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "date": {+ "name": "date",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "note": {+ "name": "note",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "calendar_notes_calendar_id_calendars_id_fk": {+ "name": "calendar_notes_calendar_id_calendars_id_fk",+ "tableFrom": "calendar_notes",+ "tableTo": "calendars",+ "columnsFrom": [+ "calendar_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "calendars": {+ "name": "calendars",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'#3b82f6'"+ },+ "password_hash": {+ "name": "password_hash",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {},+ "foreignKeys": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "shift_presets": {+ "name": "shift_presets",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "calendar_id": {+ "name": "calendar_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "start_time": {+ "name": "start_time",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "end_time": {+ "name": "end_time",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'#3b82f6'"+ },+ "notes": {+ "name": "notes",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "is_secondary": {+ "name": "is_secondary",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "is_all_day": {+ "name": "is_all_day",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "shift_presets_calendar_id_calendars_id_fk": {+ "name": "shift_presets_calendar_id_calendars_id_fk",+ "tableFrom": "shift_presets",+ "tableTo": "calendars",+ "columnsFrom": [+ "calendar_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "shifts": {+ "name": "shifts",+ "columns": {+ "id": {+ "name": "id",+ "type": "text",+ "primaryKey": true,+ "notNull": true,+ "autoincrement": false+ },+ "calendar_id": {+ "name": "calendar_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "preset_id": {+ "name": "preset_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "date": {+ "name": "date",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "start_time": {+ "name": "start_time",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "end_time": {+ "name": "end_time",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "title": {+ "name": "title",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'#3b82f6'"+ },+ "notes": {+ "name": "notes",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "is_all_day": {+ "name": "is_all_day",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "is_secondary": {+ "name": "is_secondary",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "created_at": {+ "name": "created_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ },+ "updated_at": {+ "name": "updated_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "shifts_calendar_id_calendars_id_fk": {+ "name": "shifts_calendar_id_calendars_id_fk",+ "tableFrom": "shifts",+ "tableTo": "calendars",+ "columnsFrom": [+ "calendar_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "shifts_preset_id_shift_presets_id_fk": {+ "name": "shifts_preset_id_shift_presets_id_fk",+ "tableFrom": "shifts",+ "tableTo": "shift_presets",+ "columnsFrom": [+ "preset_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "set null",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ }+ },+ "views": {},+ "enums": {},+ "_meta": {+ "schemas": {},+ "tables": {},+ "columns": {}+ },+ "internal": {+ "indexes": {}+ }+}\ No newline at end of filediff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.jsonindex 2ec17fb..9bcc7c7 100644--- a/drizzle/meta/_journal.json+++ b/drizzle/meta/_journal.json@@ -22,6 +22,13 @@"when": 1763776413411,"tag": "0002_illegal_purple_man","breakpoints": true+ },+ {+ "idx": 3,+ "version": "6",+ "when": 1763857902681,+ "tag": "0003_serious_wolfpack",+ "breakpoints": true}]}\ No newline at end of filediff --git a/lib/db/schema.ts b/lib/db/schema.tsindex ca68180..1a585ff 100644--- a/lib/db/schema.ts+++ b/lib/db/schema.ts@@ -68,9 +68,28 @@ export const shiftPresets = sqliteTable("shift_presets", {.default(sql`CURRENT_TIMESTAMP`),});+export const calendarNotes = sqliteTable("calendar_notes", {+ id: text("id")+ .primaryKey()+ .$defaultFn(() => crypto.randomUUID()),+ calendarId: text("calendar_id")+ .notNull()+ .references(() => calendars.id, { onDelete: "cascade" }),+ date: integer("date", { mode: "timestamp" }).notNull(),+ note: text("note").notNull(),+ createdAt: integer("created_at", { mode: "timestamp" })+ .notNull()+ .default(sql`CURRENT_TIMESTAMP`),+ updatedAt: integer("updated_at", { mode: "timestamp" })+ .notNull()+ .default(sql`CURRENT_TIMESTAMP`),+});+export type Calendar = typeof calendars.$inferSelect;export type NewCalendar = typeof calendars.$inferInsert;export type Shift = typeof shifts.$inferSelect;export type NewShift = typeof shifts.$inferInsert;export type ShiftPreset = typeof shiftPresets.$inferSelect;export type NewShiftPreset = typeof shiftPresets.$inferInsert;+export type CalendarNote = typeof calendarNotes.$inferSelect;+export type NewCalendarNote = typeof calendarNotes.$inferInsert;diff --git a/messages/de.json b/messages/de.jsonindex a3ce7dc..a85c21e 100644--- a/messages/de.json+++ b/messages/de.json@@ -52,6 +52,15 @@"errorIncorrect": "Falsches Passwort","unlock": "Entsperren"},+ "note": {+ "title": "Notizen",+ "create": "Neue Notiz",+ "edit": "Notiz bearbeiten",+ "delete": "Notiz löschen",+ "note": "Notiz",+ "notePlaceholder": "z.B. Frühdienst weil nachmittags Friseur...",+ "rightClick": "Rechtsklick / Langes Drücken auf einen Tag oder Klick auf das Notiz-Icon"+ },"shift": {"title": "Schichten","create": "Neue Schicht",diff --git a/messages/en.json b/messages/en.jsonindex d362f97..f5ee72a 100644--- a/messages/en.json+++ b/messages/en.json@@ -52,6 +52,15 @@"errorIncorrect": "Incorrect password","unlock": "Unlock"},+ "note": {+ "title": "Notes",+ "create": "New Note",+ "edit": "Edit Note",+ "delete": "Delete Note",+ "note": "Note",+ "notePlaceholder": "e.g., Morning shift because afternoon hairdresser...",+ "rightClick": "Right-click / Long press on a day or click the note icon"+ },"shift": {"title": "Shifts","create": "New Shift",