Your favorite shift management application!
feat: Add event support to notes (color + recurring) (#94)
panteLfb4a40764d0e
diff --git a/README.md b/README.mdindex 43e19ac..b3e136a 100644--- a/README.md+++ b/README.md@@ -37,7 +37,7 @@- **Multiple Calendars** — Unlimited calendars with custom names and colors- **Interactive Month View** — Clean, week-based calendar layout with one-click shift toggles-- **Quick Actions** — Left-click to add/remove shifts, right-click to add notes+- **Quick Actions** — Left-click to add/remove shifts, right-click to add notes or events- **External Calendar Sync** — Subscribe to Google, Outlook or iCal calendars with auto/manual refresh- **Sync Monitoring** — Real-time sync status and error notifications- **Calendar Comparison** — Overlay multiple calendars for easy shift comparisondiff --git a/app/api/notes/[id]/route.ts b/app/api/notes/[id]/route.tsindex 2b8ab4c..6452a6d 100644--- a/app/api/notes/[id]/route.ts+++ b/app/api/notes/[id]/route.ts@@ -68,7 +68,8 @@ export async function PUT(try {const { id } = await params;const body = await request.json();- const { note, password } = body;+ const { note, type, color, recurringPattern, recurringInterval, password } =+ body;if (!note) {return NextResponse.json({ error: "Note is required" }, { status: 400 });@@ -110,10 +111,33 @@ export async function PUT(}}+ // Determine the final type value+ const finalType = type !== undefined ? type : existingNote.type;+const [updated] = await db.update(calendarNotes).set({note,+ type: finalType,+ // Clear event-specific fields when converting to note+ color:+ finalType === "note"+ ? null+ : color !== undefined+ ? color+ : existingNote.color,+ recurringPattern:+ finalType === "note"+ ? "none"+ : recurringPattern !== undefined+ ? recurringPattern+ : existingNote.recurringPattern,+ recurringInterval:+ finalType === "note"+ ? null+ : recurringInterval !== undefined+ ? recurringInterval+ : existingNote.recurringInterval,updatedAt: new Date(),}).where(eq(calendarNotes.id, id))diff --git a/app/api/notes/route.ts b/app/api/notes/route.tsindex 1721e64..5a88dfb 100644--- a/app/api/notes/route.ts+++ b/app/api/notes/route.ts@@ -82,7 +82,16 @@ export async function GET(request: Request) {export async function POST(request: Request) {try {const body = await request.json();- const { calendarId, date, note, password } = body;+ const {+ calendarId,+ date,+ note,+ type,+ color,+ recurringPattern,+ recurringInterval,+ password,+ } = body;if (!calendarId || !date || !note) {return NextResponse.json(@@ -91,6 +100,14 @@ export async function POST(request: Request) {);}+ // Validate type field+ if (type && type !== "note" && type !== "event") {+ return NextResponse.json(+ { error: "Invalid type. Must be 'note' or 'event'" },+ { status: 400 }+ );+ }+// Fetch calendar to check passwordconst [calendar] = await db.select()@@ -120,6 +137,10 @@ export async function POST(request: Request) {calendarId,date: new Date(date),note,+ type: type || "note",+ color: color || null,+ recurringPattern: recurringPattern || "none",+ recurringInterval: recurringInterval || null,}).returning();diff --git a/app/page.tsx b/app/page.tsxindex 44d8858..ac8b9e6 100644--- a/app/page.tsx+++ b/app/page.tsx@@ -45,6 +45,7 @@ import {verifyAndCachePassword,} from "@/lib/password-cache";import { formatDateToLocal } from "@/lib/date-utils";+import { findNotesForDate } from "@/lib/event-utils";import { toast } from "sonner";import { useTranslations } from "next-intl";@@ -146,8 +147,20 @@ function HomeContent() {});// Wrapper for note submit that reloads compare data- const handleNoteSubmit = async (noteText: string) => {- await noteActions.handleNoteSubmit(noteText);+ const handleNoteSubmit = async (+ noteText: string,+ type: "note" | "event",+ color?: string,+ recurringPattern?: string,+ recurringInterval?: number+ ) => {+ await noteActions.handleNoteSubmit(+ noteText,+ type,+ color,+ recurringPattern,+ recurringInterval+ );// Reload notes for the specific calendar in compare modeif (isCompareMode && compareNoteCalendarId) {@@ -199,6 +212,61 @@ function HomeContent() {}};+ // Notes list dialog handlers+ const handleEditNoteFromList = (note: CalendarNote) => {+ dialogStates.setShowNotesListDialog(false);+ noteActions.openNoteDialog(+ dialogStates.selectedDayDate || new Date(),+ note+ );+ };++ const handleDeleteNoteFromList = async (noteId: string) => {+ const success = await deleteNoteHook(noteId, () => {+ dialogStates.setShowPasswordDialog(true);+ });++ if (success) {+ // Update the notes list in the dialog+ const updatedNotes = dialogStates.selectedDayNotes.filter(+ (n) => n.id !== noteId+ );+ dialogStates.setSelectedDayNotes(updatedNotes);++ // If no notes left, close the dialog+ if (updatedNotes.length === 0) {+ dialogStates.setShowNotesListDialog(false);+ }++ // Reload compare mode data if needed+ if (isCompareMode && compareNoteCalendarId) {+ const password = getCachedPassword(compareNoteCalendarId);+ const passwordParam = password ? `&password=${password}` : "";+ try {+ const notesRes = await fetch(+ `/api/notes?calendarId=${compareNoteCalendarId}${passwordParam}`+ );+ const notesData = notesRes.ok ? await notesRes.json() : [];+ setCompareCalendarData((prev) => {+ const updated = new Map(prev);+ const data = updated.get(compareNoteCalendarId);+ if (data) {+ updated.set(compareNoteCalendarId, { ...data, notes: notesData });+ }+ return updated;+ });+ } catch (error) {+ console.error("Failed to reload notes:", error);+ }+ }+ }+ };++ const handleAddNewNoteFromList = () => {+ const date = dialogStates.selectedDayDate || new Date();+ noteActions.openNoteDialog(date, undefined);+ };+// External sync managementconst [compareCalendarData, setCompareCalendarData] = useState<Map<@@ -442,25 +510,49 @@ function HomeContent() {const handleDayRightClick = (e: React.MouseEvent, date: Date) => {e.preventDefault();- const existingNote = notes.find(- (note) => note.date && isSameDay(new Date(note.date), date)- );- noteActions.openNoteDialog(date, existingNote);+ // Get all notes/events for this date (including recurring)+ const allDayNotes = findNotesForDate(notes, date);++ // Always show list dialog when notes exist (to allow adding more)+ if (allDayNotes.length >= 1) {+ dialogStates.setSelectedDayDate(date);+ dialogStates.setSelectedDayNotes(allDayNotes);+ dialogStates.setShowNotesListDialog(true);+ } else {+ // No notes - show note edit dialog to create new+ noteActions.openNoteDialog(date, undefined);+ }};const handleNoteIconClick = (e: React.MouseEvent, date: Date) => {e.stopPropagation();- const existingNote = notes.find(- (note) => note.date && isSameDay(new Date(note.date), date)- );- noteActions.openNoteDialog(date, existingNote);+ // Get all notes/events for this date (including recurring)+ const allDayNotes = findNotesForDate(notes, date);++ // Always show list dialog when notes exist (to allow adding more)+ if (allDayNotes.length >= 1) {+ dialogStates.setSelectedDayDate(date);+ dialogStates.setSelectedDayNotes(allDayNotes);+ dialogStates.setShowNotesListDialog(true);+ } else {+ // No notes - show note edit dialog to create new+ noteActions.openNoteDialog(date, undefined);+ }};const handleLongPressDay = (date: Date) => {- const existingNote = notes.find(- (note) => note.date && isSameDay(new Date(note.date), date)- );- noteActions.openNoteDialog(date, existingNote);+ // Get all notes/events for this date (including recurring)+ const allDayNotes = findNotesForDate(notes, date);++ // Always show list dialog when notes exist (to allow adding more)+ if (allDayNotes.length >= 1) {+ dialogStates.setSelectedDayDate(date);+ dialogStates.setSelectedDayNotes(allDayNotes);+ dialogStates.setShowNotesListDialog(true);+ } else {+ // No notes - show note edit dialog to create new+ noteActions.openNoteDialog(date, undefined);+ }};const handleShowAllShifts = (date: Date, dayShifts: ShiftWithCalendar[]) => {@@ -698,11 +790,20 @@ function HomeContent() {const calendarData = compareCalendarData.get(calendarId);if (!calendarData) return;- const existingNote = calendarData.notes.find(- (note) => note.date && isSameDay(new Date(note.date), date)- );- setCompareNoteCalendarId(calendarId);- noteActions.openNoteDialog(date, existingNote);+ // Get all notes/events for this date (including recurring)+ const allDayNotes = findNotesForDate(calendarData.notes, date);++ // Always show list dialog when notes exist (to allow adding more)+ if (allDayNotes.length >= 1) {+ setCompareNoteCalendarId(calendarId);+ dialogStates.setSelectedDayDate(date);+ dialogStates.setSelectedDayNotes(allDayNotes);+ dialogStates.setShowNotesListDialog(true);+ } else {+ // No notes - show note edit dialog to create new+ setCompareNoteCalendarId(calendarId);+ noteActions.openNoteDialog(date, undefined);+ }};const handleCompareNoteIconClick = (@@ -711,18 +812,43 @@ function HomeContent() {date: Date) => {e.stopPropagation();- handleCompareDayRightClick(calendarId, e, date);+ const calendarData = compareCalendarData.get(calendarId);+ if (!calendarData) return;++ // Get all notes/events for this date (including recurring)+ const allDayNotes = findNotesForDate(calendarData.notes, date);++ // Always show list dialog when notes exist (to allow adding more)+ if (allDayNotes.length >= 1) {+ setCompareNoteCalendarId(calendarId);+ dialogStates.setSelectedDayDate(date);+ dialogStates.setSelectedDayNotes(allDayNotes);+ dialogStates.setShowNotesListDialog(true);+ } else {+ // No notes - show note edit dialog to create new+ setCompareNoteCalendarId(calendarId);+ noteActions.openNoteDialog(date, undefined);+ }};const handleCompareLongPress = (calendarId: string, date: Date) => {const calendarData = compareCalendarData.get(calendarId);if (!calendarData) return;- const existingNote = calendarData.notes.find(- (note) => note.date && isSameDay(new Date(note.date), date)- );- setCompareNoteCalendarId(calendarId);- noteActions.openNoteDialog(date, existingNote);+ // Get all notes/events for this date (including recurring)+ const allDayNotes = findNotesForDate(calendarData.notes, date);++ // Always show list dialog when notes exist (to allow adding more)+ if (allDayNotes.length >= 1) {+ setCompareNoteCalendarId(calendarId);+ dialogStates.setSelectedDayDate(date);+ dialogStates.setSelectedDayNotes(allDayNotes);+ dialogStates.setShowNotesListDialog(true);+ } else {+ // No notes - show note edit dialog to create new+ setCompareNoteCalendarId(calendarId);+ noteActions.openNoteDialog(date, undefined);+ }};const handleCompareShowAllShifts = (@@ -1054,6 +1180,12 @@ function HomeContent() {selectedNoteDate={noteActions.selectedDate}onNoteSubmit={handleNoteSubmit}onNoteDelete={noteActions.selectedNote ? handleNoteDelete : undefined}+ showNotesListDialog={dialogStates.showNotesListDialog}+ onNotesListDialogChange={dialogStates.setShowNotesListDialog}+ selectedDayNotes={dialogStates.selectedDayNotes}+ onEditNoteFromList={handleEditNoteFromList}+ onDeleteNoteFromList={handleDeleteNoteFromList}+ onAddNewNote={handleAddNewNoteFromList}/><AppFooter versionInfo={versionInfo} />@@ -1069,9 +1201,82 @@ function HomeContent() {// Empty stateif (calendars.length === 0) {return (- <EmptyCalendarState- onCreateCalendar={() => dialogStates.setShowCalendarDialog(true)}- />+ <>+ <EmptyCalendarState+ onCreateCalendar={() => dialogStates.setShowCalendarDialog(true)}+ />+ <DialogManager+ showCalendarDialog={dialogStates.showCalendarDialog}+ onCalendarDialogChange={dialogStates.setShowCalendarDialog}+ onCreateCalendar={createCalendarHook}+ showShiftDialog={dialogStates.showShiftDialog}+ onShiftDialogChange={dialogStates.setShowShiftDialog}+ onShiftSubmit={shiftActions.handleShiftSubmit}+ selectedDate={selectedDate}+ selectedCalendar={selectedCalendar || null}+ onPresetsChange={refetchPresets}+ showPasswordDialog={dialogStates.showPasswordDialog}+ onPasswordDialogChange={dialogStates.setShowPasswordDialog}+ calendars={calendars}+ onPasswordSuccess={handlePasswordSuccess}+ showCalendarSettingsDialog={dialogStates.showCalendarSettingsDialog}+ onCalendarSettingsDialogChange={+ dialogStates.setShowCalendarSettingsDialog+ }+ onCalendarSettingsSuccess={refetchCalendars}+ onDeleteCalendar={handleDeleteCalendar}+ showExternalSyncDialog={dialogStates.showExternalSyncDialog}+ onExternalSyncDialogChange={dialogStates.setShowExternalSyncDialog}+ syncErrorRefreshTrigger={syncLogRefreshTrigger}+ onSyncComplete={handleSyncComplete}+ showSyncNotificationDialog={dialogStates.showSyncNotificationDialog}+ onSyncNotificationDialogChange={+ dialogStates.setShowSyncNotificationDialog+ }+ onErrorsMarkedRead={fetchSyncErrorStatus}+ onSyncLogUpdate={() => setSyncLogRefreshTrigger((prev) => prev + 1)}+ showDayShiftsDialog={dialogStates.showDayShiftsDialog}+ onDayShiftsDialogChange={dialogStates.setShowDayShiftsDialog}+ selectedDayDate={dialogStates.selectedDayDate}+ selectedDayShifts={dialogStates.selectedDayShifts}+ locale={locale}+ onDeleteShiftFromDayDialog={handleDeleteShiftFromDayDialog}+ showSyncedShiftsDialog={dialogStates.showSyncedShiftsDialog}+ onSyncedShiftsDialogChange={dialogStates.setShowSyncedShiftsDialog}+ selectedSyncedShifts={dialogStates.selectedSyncedShifts}+ showViewSettingsDialog={dialogStates.showViewSettingsDialog}+ onViewSettingsDialogChange={dialogStates.setShowViewSettingsDialog}+ viewSettings={viewSettings}+ onViewSettingsChange={{+ handleShiftsPerDayChange: viewSettings.handleShiftsPerDayChange,+ handleExternalShiftsPerDayChange:+ viewSettings.handleExternalShiftsPerDayChange,+ handleShowShiftNotesChange: viewSettings.handleShowShiftNotesChange,+ handleShowFullTitlesChange: viewSettings.handleShowFullTitlesChange,+ handleShiftSortTypeChange: viewSettings.handleShiftSortTypeChange,+ handleShiftSortOrderChange: viewSettings.handleShiftSortOrderChange,+ handleCombinedSortModeChange:+ viewSettings.handleCombinedSortModeChange,+ handleHighlightWeekendsChange:+ viewSettings.handleHighlightWeekendsChange,+ handleHighlightedWeekdaysChange:+ viewSettings.handleHighlightedWeekdaysChange,+ handleHighlightColorChange: viewSettings.handleHighlightColorChange,+ }}+ showNoteDialog={noteActions.showNoteDialog}+ onNoteDialogChange={noteActions.handleNoteDialogChange}+ selectedNote={noteActions.selectedNote}+ selectedNoteDate={noteActions.selectedDate}+ onNoteSubmit={handleNoteSubmit}+ onNoteDelete={noteActions.selectedNote ? handleNoteDelete : undefined}+ showNotesListDialog={dialogStates.showNotesListDialog}+ onNotesListDialogChange={dialogStates.setShowNotesListDialog}+ selectedDayNotes={dialogStates.selectedDayNotes}+ onEditNoteFromList={handleEditNoteFromList}+ onDeleteNoteFromList={handleDeleteNoteFromList}+ onAddNewNote={handleAddNewNoteFromList}+ />+ </>);}@@ -1269,6 +1474,12 @@ function HomeContent() {selectedNoteDate={noteActions.selectedDate}onNoteSubmit={handleNoteSubmit}onNoteDelete={noteActions.selectedNote ? handleNoteDelete : undefined}+ showNotesListDialog={dialogStates.showNotesListDialog}+ onNotesListDialogChange={dialogStates.setShowNotesListDialog}+ selectedDayNotes={dialogStates.selectedDayNotes}+ onEditNoteFromList={handleEditNoteFromList}+ onDeleteNoteFromList={handleDeleteNoteFromList}+ onAddNewNote={handleAddNewNoteFromList}/><AppFooter versionInfo={versionInfo} />diff --git a/components/calendar-compare-sheet.tsx b/components/calendar-compare-sheet.tsxindex 5a7a8d7..7b747d7 100644--- a/components/calendar-compare-sheet.tsx+++ b/components/calendar-compare-sheet.tsx@@ -4,6 +4,8 @@ import { useTranslations } from "next-intl";import { CalendarWithCount } from "@/lib/types";import { BaseSheet } from "@/components/ui/base-sheet";import { Checkbox } from "@/components/ui/checkbox";+import { Alert, AlertDescription } from "@/components/ui/alert";+import { Smartphone } from "lucide-react";import { motion } from "motion/react";interface CalendarCompareSheetProps {@@ -42,11 +44,12 @@ export function CalendarCompareSheet({>{/* Mobile Warning */}<div className="lg:hidden mb-3">- <div className="bg-amber-500/10 border border-amber-500/30 rounded-lg p-3">- <p className="text-xs text-amber-600 dark:text-amber-400 text-center">+ <Alert className="border-amber-500/50 bg-amber-50/50 dark:bg-amber-950/20">+ <Smartphone className="h-4 w-4 text-amber-600 dark:text-amber-500" />+ <AlertDescription className="text-sm text-amber-800 dark:text-amber-200">{t("calendar.mobileNotOptimized")}- </p>- </div>+ </AlertDescription>+ </Alert></div><div className="space-y-3">diff --git a/components/calendar-compare-view.tsx b/components/calendar-compare-view.tsxindex 5b5d684..659936c 100644--- a/components/calendar-compare-view.tsx+++ b/components/calendar-compare-view.tsx@@ -7,7 +7,8 @@ import { Button } from "@/components/ui/button";import { CalendarContent } from "@/components/calendar-content";import { PresetSelector } from "@/components/preset-selector";import { LockedCalendarView } from "@/components/locked-calendar-view";-import { X, Link } from "lucide-react";+import { Alert, AlertDescription } from "@/components/ui/alert";+import { X, Link, Smartphone } from "lucide-react";import { getCachedPassword } from "@/lib/password-cache";import { motion } from "motion/react";import { Locale } from "date-fns";@@ -154,11 +155,12 @@ export function CalendarCompareView(props: CalendarCompareViewProps) {{/* Mobile Warning */}<div className="lg:hidden mx-3 mt-3 mb-1">- <div className="bg-amber-500/10 border border-amber-500/30 rounded-lg p-3">- <p className="text-xs text-amber-600 dark:text-amber-400 text-center">+ <Alert className="border-amber-500/50 bg-amber-50/50 dark:bg-amber-950/20">+ <Smartphone className="h-4 w-4 text-amber-600 dark:text-amber-500" />+ <AlertDescription className="text-sm text-amber-800 dark:text-amber-200">{t("calendar.mobileNotOptimized")}- </p>- </div>+ </AlertDescription>+ </Alert></div>{/* Calendars Grid */}diff --git a/components/calendar-grid.tsx b/components/calendar-grid.tsxindex e279346..647bfe0 100644--- a/components/calendar-grid.tsx+++ b/components/calendar-grid.tsx@@ -1,5 +1,5 @@import { motion } from "motion/react";-import { StickyNote, RefreshCw } from "lucide-react";+import { RefreshCw } from "lucide-react";import { ShiftWithCalendar } from "@/lib/types";import { CalendarNote, ExternalSync } from "@/lib/db/schema";import { isToday } from "date-fns";@@ -7,6 +7,7 @@ import { useTranslations } from "next-intl";import { useRef, useEffect } from "react";import { formatDateToLocal } from "@/lib/date-utils";import { CalendarShiftCard } from "./calendar-shift-card";+import { findNotesForDate } from "@/lib/event-utils";interface CalendarGridProps {calendarDays: Date[];@@ -128,9 +129,19 @@ export function CalendarGrid({))}{calendarDays.map((day, idx) => {const dayShifts = getShiftsForDate(day);- const dayNote = notes.find(- (note) => note.date && isSameDay(new Date(note.date), day)- );++ // Find all notes/events for this day (including recurring)+ const allDayNotes = findNotesForDate(notes, day);++ // Count events and regular notes separately+ const dayEvents = allDayNotes.filter((n) => n.type === "event");+ const dayRegularNotes = allDayNotes.filter((n) => n.type !== "event");+ const totalNotesCount = allDayNotes.length;++ // Get first event and note for display+ const dayEvent = dayEvents[0];+ const dayNote = dayRegularNotes[0];+const isCurrentMonth = day.getMonth() === currentDate.getMonth();const isTodayDate = isToday(day);@@ -157,6 +168,17 @@ export function CalendarGrid({highlightedWeekdays.length > 0 &&highlightedWeekdays.includes(day.getDay());+ // Create gradient border for multiple events+ // Note: borderImage doesn't support border-radius, so we use a different approach+ const hasMultiEventBorder = dayEvents.length > 1 && !isTodayDate;+ const eventBorderStyle =+ dayEvents.length === 1 && !isTodayDate+ ? {+ borderColor: dayEvents[0].color || "#3b82f6",+ borderWidth: "2px",+ }+ : {};+return (<motion.buttonkey={idx}@@ -181,6 +203,17 @@ export function CalendarGrid({backgroundColor: `${highlightColor}15`,borderColor: `${highlightColor}40`,}),+ // Event border styling (overrides highlight if both present)+ ...eventBorderStyle,+ // Multi-event gradient border using background trick to support border-radius+ ...(hasMultiEventBorder && {+ backgroundImage: `linear-gradient(var(--background), var(--background)), linear-gradient(to right, ${dayEvents+ .map((e) => e.color || "#3b82f6")+ .join(", ")})`,+ backgroundOrigin: "border-box",+ backgroundClip: "padding-box, border-box",+ border: "2px solid transparent",+ }),}}className={`min-h-25 sm:min-h-28 px-1 py-1.5 sm:p-2.5 rounded-md sm:rounded-lg text-sm transition-all relative flex flex-col border sm:border-2@@ -188,6 +221,8 @@ export function CalendarGrid({${isTodayDate? "border-primary shadow-lg shadow-primary/20 bg-primary/5 ring-2 ring-primary/20"+ : dayEvent+ ? "" // Event border is handled by inline style: "border-border/30 sm:border-border/50"}${@@ -202,28 +237,73 @@ export function CalendarGrid({`}><div- className={`text-sm sm:text-sm font-semibold mb-1 flex items-center justify-between ${+ className={`text-sm sm:text-sm font-semibold mb-1 flex items-center justify-between gap-1 ${isTodayDate ? "text-primary" : ""}`}>- <span>{day.getDate()}</span>- {dayNote && onNoteIconClick && (- <motion.div- className="group/note relative"- onClick={(e) => onNoteIconClick(e, day)}- title={dayNote.note}- whileHover={{ scale: 1.1 }}- whileTap={{ scale: 0.9 }}- >- <StickyNote className="h-3.5 w-3.5 text-orange-500 cursor-pointer hover:text-orange-600 transition-colors" />- <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>- </motion.div>- )}+ <span className="shrink-0">{day.getDate()}</span>+ <div className="flex items-center gap-1 min-w-0">+ {/* Multi-indicator badge when multiple notes/events exist */}+ {totalNotesCount > 1 && (+ <span+ className={`inline-flex items-center justify-center text-[9px] sm:text-[10px] font-bold px-1.5 py-0.5 rounded-full bg-primary/20 text-primary border border-primary/30 ${+ !selectedPresetId && onNoteIconClick+ ? "cursor-pointer hover:bg-primary/30 transition-colors"+ : ""+ }`}+ title={t("note.multipleEntries", {+ count: totalNotesCount,+ })}+ onClick={(e) => {+ if (!selectedPresetId && onNoteIconClick) {+ e.stopPropagation();+ onNoteIconClick(e, day);+ }+ }}+ >+ {totalNotesCount}+ </span>+ )}+ {/* Display first event title - clickable if no preset selected */}+ {dayEvent && totalNotesCount === 1 && (+ <span+ className={`text-[10px] sm:text-xs font-medium truncate opacity-75 min-w-0 ${+ !selectedPresetId && onNoteIconClick+ ? "cursor-pointer hover:opacity-100 transition-opacity"+ : ""+ }`}+ style={{ color: dayEvent.color || "#3b82f6" }}+ title={dayEvent.note}+ onClick={(e) => {+ if (!selectedPresetId && onNoteIconClick) {+ e.stopPropagation();+ onNoteIconClick(e, day);+ }+ }}+ >+ {dayEvent.note}+ </span>+ )}+ {/* Display first note title if no event and only one entry - clickable if no preset selected */}+ {!dayEvent && dayNote && totalNotesCount === 1 && (+ <span+ className={`text-[10px] sm:text-xs font-medium text-orange-500 truncate opacity-75 min-w-0 ${+ !selectedPresetId && onNoteIconClick+ ? "cursor-pointer hover:opacity-100 transition-opacity"+ : ""+ }`}+ title={dayNote.note}+ onClick={(e) => {+ if (!selectedPresetId && onNoteIconClick) {+ e.stopPropagation();+ onNoteIconClick(e, day);+ }+ }}+ >+ {dayNote.note}+ </span>+ )}+ </div></div><div className="flex-1 space-y-0.5 sm:space-y-1 overflow-hidden">{(() => {diff --git a/components/calendar-sheet.tsx b/components/calendar-sheet.tsxindex cce9759..0a66d83 100644--- a/components/calendar-sheet.tsx+++ b/components/calendar-sheet.tsx@@ -17,7 +17,7 @@ interface CalendarSheetProps {color: string,password?: string,isLocked?: boolean- ) => void;+ ) => void | Promise<void>;}export function CalendarSheet({diff --git a/components/dialog-manager.tsx b/components/dialog-manager.tsxindex b79c63e..62efc45 100644--- a/components/dialog-manager.tsx+++ b/components/dialog-manager.tsx@@ -7,6 +7,7 @@ import { SyncNotificationDialog } from "@/components/sync-notification-dialog";import { ShiftsOverviewDialog } from "@/components/shifts-overview-dialog";import { ViewSettingsSheet } from "@/components/view-settings-sheet";import { NoteSheet } from "@/components/note-sheet";+import { NotesListDialog } from "@/components/notes-list-dialog";import { CalendarWithCount, ShiftWithCalendar } from "@/lib/types";import { CalendarNote } from "@/lib/db/schema";@@ -100,8 +101,22 @@ interface DialogManagerProps {onNoteDialogChange: (open: boolean) => void;selectedNote: CalendarNote | undefined;selectedNoteDate?: Date;- onNoteSubmit: (text: string) => void;+ onNoteSubmit: (+ note: string,+ type: "note" | "event",+ color?: string,+ recurringPattern?: string,+ recurringInterval?: number+ ) => void;onNoteDelete?: () => void;++ // Notes List Dialog+ showNotesListDialog: boolean;+ onNotesListDialogChange: (open: boolean) => void;+ selectedDayNotes: CalendarNote[];+ onEditNoteFromList: (note: CalendarNote) => void;+ onDeleteNoteFromList: (noteId: string) => void;+ onAddNewNote: () => void;}export function DialogManager(props: DialogManagerProps) {@@ -239,6 +254,17 @@ export function DialogManager(props: DialogManagerProps) {}/>+ {props.selectedDayDate && (+ <NotesListDialog+ open={props.showNotesListDialog}+ onOpenChange={props.onNotesListDialogChange}+ date={props.selectedDayDate}+ notes={props.selectedDayNotes}+ onEditNote={props.onEditNoteFromList}+ onDeleteNote={props.onDeleteNoteFromList}+ onAddNew={props.onAddNewNote}+ />+ )}<NoteSheetopen={props.showNoteDialog}onOpenChange={props.onNoteDialogChange}diff --git a/components/note-sheet.tsx b/components/note-sheet.tsxindex 81e99c0..d3f9bf9 100644--- a/components/note-sheet.tsx+++ b/components/note-sheet.tsx@@ -6,14 +6,32 @@ import { BaseSheet } from "@/components/ui/base-sheet";import { Button } from "@/components/ui/button";import { Label } from "@/components/ui/label";import { Textarea } from "@/components/ui/textarea";+import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";+import {+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from "@/components/ui/select";+import { Input } from "@/components/ui/input";import { CalendarNote } from "@/lib/db/schema";import { format } from "date-fns";import { getDateLocale } from "@/lib/locales";+import { PRESET_COLORS } from "@/lib/constants";+import { Check, AlertCircle } from "lucide-react";+import { Alert, AlertDescription } from "@/components/ui/alert";interface NoteSheetProps {open: boolean;onOpenChange: (open: boolean) => void;- onSubmit: (note: string) => void;+ onSubmit: (+ note: string,+ type: "note" | "event",+ color?: string,+ recurringPattern?: string,+ recurringInterval?: number+ ) => void;onDelete?: () => void;selectedDate?: Date;note?: CalendarNote;@@ -31,26 +49,94 @@ export function NoteSheet({const locale = useLocale();const dateLocale = getDateLocale(locale);const [noteText, setNoteText] = useState("");+ const [type, setType] = useState<"note" | "event">("note");+ const [color, setColor] = useState<string>("#3b82f6");+ const [recurringPattern, setRecurringPattern] = useState<string>("none");+ const [recurringInterval, setRecurringInterval] = useState<number>(1);+ const [recurringUnit, setRecurringUnit] = useState<string>("months");const [isSaving, setIsSaving] = useState(false);- const initialNoteTextRef = useRef<string>("");+ const initialStateRef = useRef<{+ text: string;+ type: "note" | "event";+ color: string;+ recurringPattern: string;+ recurringInterval: number;+ recurringUnit: string;+ }>({+ text: "",+ type: "note",+ color: "#3b82f6",+ recurringPattern: "none",+ recurringInterval: 1,+ recurringUnit: "months",+ });// Reset state when dialog opens/closes or note changesuseEffect(() => {if (open) {const initialText = note?.note || "";+ const initialType = (note?.type as "note" | "event") || "note";+ const initialColor = note?.color || "#3b82f6";++ // Set recurring pattern from note+ const initialPattern = note?.recurringPattern || "none";+ const initialInterval = note?.recurringInterval || 1;++ // Extract unit from pattern: "custom-weeks" or "custom-months"+ let displayPattern = initialPattern;+ let initialUnit = "months";++ if (initialPattern?.startsWith("custom-")) {+ displayPattern = "custom";+ initialUnit = initialPattern.split("-")[1] || "months";+ }+setNoteText(initialText);+ setType(initialType);+ setColor(initialColor);+ setRecurringPattern(displayPattern);+ setRecurringInterval(initialInterval);+ setRecurringUnit(initialUnit);+if (note) {- initialNoteTextRef.current = initialText;+ initialStateRef.current = {+ text: initialText,+ type: initialType,+ color: initialColor,+ recurringPattern: displayPattern,+ recurringInterval: initialInterval,+ recurringUnit: initialUnit,+ };}} else {- initialNoteTextRef.current = "";+ // Reset to defaults when closing+ setType("note");+ setColor("#3b82f6");+ setRecurringPattern("none");+ setRecurringInterval(1);+ setRecurringUnit("months");+ initialStateRef.current = {+ text: "",+ type: "note",+ color: "#3b82f6",+ recurringPattern: "none",+ recurringInterval: 1,+ recurringUnit: "months",+ };}}, [open, note]);const hasChanges = () => {if (note) {- // Edit mode: check if text changed from initial- return noteText !== initialNoteTextRef.current;+ // Edit mode: check if anything changed from initial+ return (+ noteText !== initialStateRef.current.text ||+ type !== initialStateRef.current.type ||+ color !== initialStateRef.current.color ||+ recurringPattern !== initialStateRef.current.recurringPattern ||+ recurringInterval !== initialStateRef.current.recurringInterval ||+ recurringUnit !== initialStateRef.current.recurringUnit+ );} else {// Create mode: check if any text was enteredreturn noteText.trim() !== "";@@ -62,7 +148,21 @@ export function NoteSheet({setIsSaving(true);try {- onSubmit(noteText);+ // Build pattern with unit: "custom-weeks" or "custom-months"+ const finalPattern =+ recurringPattern === "custom"+ ? `custom-${recurringUnit}`+ : recurringPattern;++ onSubmit(+ noteText,+ type,+ type === "event" ? color : undefined,+ type === "event" ? finalPattern : undefined,+ type === "event" && recurringPattern === "custom"+ ? recurringInterval+ : undefined+ );onOpenChange(false);} finally {setIsSaving(false);@@ -136,27 +236,169 @@ export function NoteSheet({</div>);+ const getSheetTitle = () => {+ const itemType =+ type === "event" ? t("note.typeEvent") : t("note.typeNote");+ if (note) {+ return t("note.edit", { item: itemType });+ }+ return t("note.create", { item: itemType });+ };+return (<BaseSheetopen={open}onOpenChange={onOpenChange}- title={note ? t("note.edit") : t("note.create")}+ title={getSheetTitle()}description={formattedDate}footer={customFooter}hasUnsavedChanges={hasChanges()}maxWidth="md">- <div className="space-y-3">- <Label htmlFor="note-text" className="text-sm font-medium">- {t("note.note")}- </Label>- <Textarea- id="note-text"- value={noteText}- onChange={(e) => setNoteText(e.target.value)}- placeholder={t("note.placeholder")}- className="min-h-[300px] resize-none focus-visible:ring-primary/30 border-border/50"- />+ <div className="space-y-6">+ {/* Recurring Event Warning */}+ {note &&+ type === "event" &&+ note.recurringPattern &&+ note.recurringPattern !== "none" && (+ <Alert className="border-amber-500/50 bg-amber-50/50 dark:bg-amber-950/20">+ <AlertCircle className="h-4 w-4 text-amber-600 dark:text-amber-500" />+ <AlertDescription className="text-sm text-amber-800 dark:text-amber-200">+ {t("note.recurringEditWarning")}+ </AlertDescription>+ </Alert>+ )}++ {/* Type Selection */}+ <div className="space-y-3">+ <Label className="text-sm font-medium">{t("note.type")}</Label>+ <RadioGroup+ value={type}+ onValueChange={(value) => setType(value as "note" | "event")}+ className="flex gap-4"+ >+ <div className="flex items-center space-x-2">+ <RadioGroupItem value="note" id="type-note" />+ <Label htmlFor="type-note" className="cursor-pointer font-normal">+ {t("note.typeNote")}+ </Label>+ </div>+ <div className="flex items-center space-x-2">+ <RadioGroupItem value="event" id="type-event" />+ <Label+ htmlFor="type-event"+ className="cursor-pointer font-normal"+ >+ {t("note.typeEvent")}+ </Label>+ </div>+ </RadioGroup>+ </div>++ {/* Event Options */}+ {type === "event" && (+ <div className="space-y-4 pl-6 border-l-2 border-border/50">+ {/* Color Selection */}+ <div className="space-y-2">+ <Label className="text-sm font-medium">+ {t("note.eventColor")}+ </Label>+ <div className="flex flex-wrap gap-2">+ {PRESET_COLORS.map((presetColor) => (+ <button+ key={presetColor.value}+ type="button"+ onClick={() => setColor(presetColor.value)}+ className="relative w-10 h-10 rounded-lg border-2 border-border/30 hover:border-border transition-colors focus:outline-none focus:ring-2 focus:ring-primary/30"+ style={{ backgroundColor: presetColor.value }}+ aria-label={presetColor.name}+ >+ {color === presetColor.value && (+ <Check className="absolute inset-0 m-auto h-5 w-5 text-white drop-shadow-md" />+ )}+ </button>+ ))}+ </div>+ </div>++ {/* Recurring Pattern */}+ <div className="space-y-2">+ <Label className="text-sm font-medium">+ {t("note.recurring")}+ </Label>+ <Select+ value={recurringPattern}+ onValueChange={setRecurringPattern}+ >+ <SelectTrigger className="w-full">+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ <SelectItem value="none">+ {t("note.recurringNone")}+ </SelectItem>+ <SelectItem value="custom">+ {t("note.recurringCustom")}+ </SelectItem>+ </SelectContent>+ </Select>+ </div>++ {/* Custom Interval */}+ {recurringPattern === "custom" && (+ <div className="space-y-2">+ <Label className="text-sm font-medium">+ {t("note.customInterval")}+ </Label>+ <div className="flex items-center gap-2">+ <span className="text-sm text-muted-foreground whitespace-nowrap">+ {t("note.every")}+ </span>+ <Input+ type="number"+ min={1}+ max={52}+ value={recurringInterval}+ onChange={(e) =>+ setRecurringInterval(parseInt(e.target.value) || 1)+ }+ className="w-20"+ />+ <Select+ value={recurringUnit}+ onValueChange={setRecurringUnit}+ >+ <SelectTrigger className="flex-1">+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ <SelectItem value="weeks">{t("note.weeks")}</SelectItem>+ <SelectItem value="months">{t("note.months")}</SelectItem>+ </SelectContent>+ </Select>+ </div>+ </div>+ )}+ </div>+ )}++ {/* Note Text */}+ <div className="space-y-3">+ <Label htmlFor="note-text" className="text-sm font-medium">+ {type === "event" ? t("note.eventTitle") : t("note.note")}+ </Label>+ <Textarea+ id="note-text"+ value={noteText}+ onChange={(e) => setNoteText(e.target.value)}+ placeholder={+ type === "event"+ ? t("note.eventPlaceholder")+ : t("note.placeholder")+ }+ className="min-h-[200px] resize-none focus-visible:ring-primary/30 border-border/50"+ />+ </div></div></BaseSheet>);diff --git a/components/notes-list-dialog.tsx b/components/notes-list-dialog.tsxnew file mode 100644index 0000000..5495135--- /dev/null+++ b/components/notes-list-dialog.tsx@@ -0,0 +1,219 @@+"use client";++import { CalendarNote } from "@/lib/db/schema";+import { useTranslations, useLocale } from "next-intl";+import { format } from "date-fns";+import { getDateLocale } from "@/lib/locales";+import {+ Dialog,+ DialogContent,+ DialogHeader,+ DialogTitle,+ DialogDescription,+} from "@/components/ui/dialog";+import { Button } from "@/components/ui/button";+import { Pencil, Trash2, Plus, Calendar } from "lucide-react";+import { Badge } from "@/components/ui/badge";++interface NotesListDialogProps {+ open: boolean;+ onOpenChange: (open: boolean) => void;+ date: Date;+ notes: CalendarNote[];+ onEditNote: (note: CalendarNote) => void;+ onDeleteNote: (noteId: string) => void;+ onAddNew: () => void;+}++export function NotesListDialog({+ open,+ onOpenChange,+ date,+ notes,+ onEditNote,+ onDeleteNote,+ onAddNew,+}: NotesListDialogProps) {+ const t = useTranslations();+ const locale = useLocale();+ const dateLocale = getDateLocale(locale);++ const formattedDate = format(date, "EEEE, dd. MMMM yyyy", {+ locale: dateLocale,+ });++ const events = notes.filter((n) => n.type === "event");+ const regularNotes = notes.filter((n) => n.type !== "event");++ const getRecurringLabel = (note: CalendarNote) => {+ if (!note.recurringPattern || note.recurringPattern === "none") {+ return null;+ }++ if (note.recurringPattern === "custom-weeks") {+ return t("note.recurringEveryWeeks", {+ count: note.recurringInterval || 1,+ });+ }++ if (note.recurringPattern === "custom-months") {+ return t("note.recurringEveryMonths", {+ count: note.recurringInterval || 1,+ });+ }++ return null;+ };++ return (+ <Dialog open={open} onOpenChange={onOpenChange}>+ <DialogContent className="max-w-2xl max-h-[85vh] flex flex-col p-0 gap-0 border border-border/50 bg-gradient-to-b from-background via-background to-muted/30 backdrop-blur-xl shadow-2xl">+ <DialogHeader className="border-b border-border/50 bg-gradient-to-r from-primary/10 via-primary/5 to-transparent p-6 pb-5 space-y-1.5">+ <DialogTitle className="text-xl font-semibold bg-gradient-to-r from-foreground to-foreground/70 bg-clip-text">+ {t("note.typeNote")} & {t("note.typeEvent")}+ </DialogTitle>+ <DialogDescription className="text-sm text-muted-foreground">+ {formattedDate}+ </DialogDescription>+ </DialogHeader>++ <div className="space-y-6 overflow-y-auto flex-1 p-6">+ {/* Events Section */}+ {events.length > 0 && (+ <div className="space-y-3">+ <h3 className="text-xs font-semibold text-muted-foreground uppercase tracking-wider">+ {t("note.typeEvent")} ({events.length})+ </h3>+ <div className="space-y-2">+ {events.map((event) => (+ <div+ key={event.id}+ className="p-4 rounded-xl border border-border/50 bg-muted/20 hover:bg-muted/30 transition-all"+ style={{+ borderLeftColor: event.color || "#3b82f6",+ borderLeftWidth: 4,+ }}+ >+ <div className="flex items-start justify-between gap-3">+ <div className="flex-1 min-w-0">+ <div className="flex items-center gap-2">+ <div+ className="w-1 h-4 rounded-full"+ style={{+ backgroundColor: event.color || "#3b82f6",+ }}+ />+ <h4 className="font-semibold text-base truncate">+ {event.note}+ </h4>+ {getRecurringLabel(event) && (+ <Badge+ variant="secondary"+ className="text-xs shrink-0"+ >+ {getRecurringLabel(event)}+ </Badge>+ )}+ </div>+ </div>+ <div className="flex gap-1.5 shrink-0 ml-auto">+ <Button+ variant="ghost"+ size="icon"+ onClick={() => onEditNote(event)}+ className="h-8 w-8 hover:bg-background/50"+ >+ <Pencil className="h-4 w-4" />+ </Button>+ <Button+ variant="ghost"+ size="icon"+ onClick={() => onDeleteNote(event.id)}+ className="h-8 w-8 hover:bg-destructive/10 hover:text-destructive"+ >+ <Trash2 className="h-4 w-4" />+ </Button>+ </div>+ </div>+ </div>+ ))}+ </div>+ </div>+ )}++ {/* Notes Section */}+ {regularNotes.length > 0 && (+ <div className="space-y-3">+ <h3 className="text-xs font-semibold text-muted-foreground uppercase tracking-wider">+ {t("note.typeNote")} ({regularNotes.length})+ </h3>+ <div className="space-y-2">+ {regularNotes.map((note) => (+ <div+ key={note.id}+ className="p-4 rounded-xl border border-border/50 bg-muted/20 hover:bg-muted/30 transition-all"+ >+ <div className="flex items-start justify-between gap-3">+ <div className="flex-1 min-w-0">+ <p className="text-sm text-foreground whitespace-pre-wrap break-words">+ {note.note}+ </p>+ </div>+ <div className="flex gap-1.5 shrink-0 ml-auto">+ <Button+ variant="ghost"+ size="icon"+ onClick={() => onEditNote(note)}+ className="h-8 w-8"+ >+ <Pencil className="h-4 w-4" />+ </Button>+ <Button+ variant="ghost"+ size="icon"+ onClick={() => onDeleteNote(note.id)}+ className="h-8 w-8 hover:bg-destructive/10 hover:text-destructive"+ >+ <Trash2 className="h-4 w-4" />+ </Button>+ </div>+ </div>+ </div>+ ))}+ </div>+ </div>+ )}++ {/* Empty State */}+ {notes.length === 0 && (+ <div className="text-center py-12 text-muted-foreground">+ <Calendar className="h-12 w-12 mx-auto mb-3 opacity-30" />+ <p className="text-sm">{t("note.noEntries")}</p>+ </div>+ )}+ </div>++ {/* Footer with Add Button */}+ <div className="flex justify-between items-center gap-3 p-6 pt-4 border-t border-border/50 bg-gradient-to-r from-muted/20 via-muted/10 to-transparent">+ <Button+ variant="outline"+ onClick={() => onOpenChange(false)}+ className="border-border/50"+ >+ {t("common.cancel")}+ </Button>+ <Button+ onClick={() => {+ onOpenChange(false);+ onAddNew();+ }}+ className="bg-gradient-to-r from-primary to-primary/90 hover:from-primary/90 hover:to-primary/80 shadow-lg shadow-primary/25"+ >+ <Plus className="h-4 w-4 mr-2" />+ {t("common.add")}+ </Button>+ </div>+ </DialogContent>+ </Dialog>+ );+}diff --git a/components/ui/alert.tsx b/components/ui/alert.tsxnew file mode 100644index 0000000..9b60947--- /dev/null+++ b/components/ui/alert.tsx@@ -0,0 +1,58 @@+import * as React from "react";+import { cva, type VariantProps } from "class-variance-authority";+import { cn } from "@/lib/utils";++const alertVariants = cva(+ "relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",+ {+ variants: {+ variant: {+ default: "bg-background text-foreground",+ destructive:+ "border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",+ },+ },+ defaultVariants: {+ variant: "default",+ },+ }+);++const Alert = React.forwardRef<+ HTMLDivElement,+ React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof alertVariants>+>(({ className, variant, ...props }, ref) => (+ <div+ ref={ref}+ role="alert"+ className={cn(alertVariants({ variant }), className)}+ {...props}+ />+));+Alert.displayName = "Alert";++const AlertTitle = React.forwardRef<+ HTMLParagraphElement,+ React.HTMLAttributes<HTMLHeadingElement>+>(({ className, ...props }, ref) => (+ <h5+ ref={ref}+ className={cn("mb-1 font-medium leading-none tracking-tight", className)}+ {...props}+ />+));+AlertTitle.displayName = "AlertTitle";++const AlertDescription = React.forwardRef<+ HTMLParagraphElement,+ React.HTMLAttributes<HTMLParagraphElement>+>(({ className, ...props }, ref) => (+ <div+ ref={ref}+ className={cn("text-sm [&_p]:leading-relaxed", className)}+ {...props}+ />+));+AlertDescription.displayName = "AlertDescription";++export { Alert, AlertTitle, AlertDescription };diff --git a/components/ui/badge.tsx b/components/ui/badge.tsxnew file mode 100644index 0000000..9ec9a1a--- /dev/null+++ b/components/ui/badge.tsx@@ -0,0 +1,36 @@+import * as React from "react";+import { cva, type VariantProps } from "class-variance-authority";++import { cn } from "@/lib/utils";++const badgeVariants = cva(+ "inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",+ {+ variants: {+ variant: {+ default:+ "border-transparent bg-primary text-primary-foreground hover:bg-primary/80",+ secondary:+ "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",+ destructive:+ "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",+ outline: "text-foreground",+ },+ },+ defaultVariants: {+ variant: "default",+ },+ }+);++export interface BadgeProps+ extends React.HTMLAttributes<HTMLDivElement>,+ VariantProps<typeof badgeVariants> {}++function Badge({ className, variant, ...props }: BadgeProps) {+ return (+ <div className={cn(badgeVariants({ variant }), className)} {...props} />+ );+}++export { Badge, badgeVariants };diff --git a/components/ui/radio-group.tsx b/components/ui/radio-group.tsxnew file mode 100644index 0000000..c8cfcf4--- /dev/null+++ b/components/ui/radio-group.tsx@@ -0,0 +1,44 @@+"use client";++import * as React from "react";+import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";+import { Circle } from "lucide-react";++import { cn } from "@/lib/utils";++const RadioGroup = React.forwardRef<+ React.ElementRef<typeof RadioGroupPrimitive.Root>,+ React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>+>(({ className, ...props }, ref) => {+ return (+ <RadioGroupPrimitive.Root+ className={cn("grid gap-2", className)}+ {...props}+ ref={ref}+ />+ );+});+RadioGroup.displayName = RadioGroupPrimitive.Root.displayName;++const RadioGroupItem = React.forwardRef<+ React.ElementRef<typeof RadioGroupPrimitive.Item>,+ React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>+>(({ className, ...props }, ref) => {+ return (+ <RadioGroupPrimitive.Item+ ref={ref}+ className={cn(+ "aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",+ className+ )}+ {...props}+ >+ <RadioGroupPrimitive.Indicator className="flex items-center justify-center">+ <Circle className="h-2.5 w-2.5 fill-current text-current" />+ </RadioGroupPrimitive.Indicator>+ </RadioGroupPrimitive.Item>+ );+});+RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;++export { RadioGroup, RadioGroupItem };diff --git a/drizzle/0012_confused_nico_minoru.sql b/drizzle/0012_confused_nico_minoru.sqlnew file mode 100644index 0000000..da2d78e--- /dev/null+++ b/drizzle/0012_confused_nico_minoru.sql@@ -0,0 +1,4 @@+ALTER TABLE `calendar_notes` ADD `type` text DEFAULT 'note' NOT NULL;--> statement-breakpoint+ALTER TABLE `calendar_notes` ADD `color` text;--> statement-breakpoint+ALTER TABLE `calendar_notes` ADD `recurring_pattern` text DEFAULT 'none' NOT NULL;--> statement-breakpoint+ALTER TABLE `calendar_notes` ADD `recurring_interval` integer;\ No newline at end of filediff --git a/drizzle/meta/0012_snapshot.json b/drizzle/meta/0012_snapshot.jsonnew file mode 100644index 0000000..800fe85--- /dev/null+++ b/drizzle/meta/0012_snapshot.json@@ -0,0 +1,727 @@+{+ "version": "6",+ "dialect": "sqlite",+ "id": "2c15a455-784b-48ee-b191-1feef86ebaed",+ "prevId": "14b7ff8f-884d-4bbf-b0d8-fe65ea2750ae",+ "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+ },+ "type": {+ "name": "type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'note'"+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "recurring_pattern": {+ "name": "recurring_pattern",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'none'"+ },+ "recurring_interval": {+ "name": "recurring_interval",+ "type": "integer",+ "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": {+ "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+ },+ "is_locked": {+ "name": "is_locked",+ "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": {},+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "external_syncs": {+ "name": "external_syncs",+ "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+ },+ "name": {+ "name": "name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "sync_type": {+ "name": "sync_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'icloud'"+ },+ "calendar_url": {+ "name": "calendar_url",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "color": {+ "name": "color",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'#3b82f6'"+ },+ "display_mode": {+ "name": "display_mode",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'normal'"+ },+ "is_hidden": {+ "name": "is_hidden",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "hide_from_stats": {+ "name": "hide_from_stats",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "auto_sync_interval": {+ "name": "auto_sync_interval",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "is_one_time_import": {+ "name": "is_one_time_import",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "last_synced_at": {+ "name": "last_synced_at",+ "type": "integer",+ "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": {+ "external_syncs_calendar_id_calendars_id_fk": {+ "name": "external_syncs_calendar_id_calendars_id_fk",+ "tableFrom": "external_syncs",+ "tableTo": "calendars",+ "columnsFrom": [+ "calendar_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "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+ },+ "hide_from_stats": {+ "name": "hide_from_stats",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "order": {+ "name": "order",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "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+ },+ "external_event_id": {+ "name": "external_event_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "external_sync_id": {+ "name": "external_sync_id",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "synced_from_external": {+ "name": "synced_from_external",+ "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"+ },+ "shifts_external_sync_id_external_syncs_id_fk": {+ "name": "shifts_external_sync_id_external_syncs_id_fk",+ "tableFrom": "shifts",+ "tableTo": "external_syncs",+ "columnsFrom": [+ "external_sync_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ }+ },+ "compositePrimaryKeys": {},+ "uniqueConstraints": {},+ "checkConstraints": {}+ },+ "sync_logs": {+ "name": "sync_logs",+ "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+ },+ "external_sync_id": {+ "name": "external_sync_id",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "external_sync_name": {+ "name": "external_sync_name",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "status": {+ "name": "status",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false+ },+ "error_message": {+ "name": "error_message",+ "type": "text",+ "primaryKey": false,+ "notNull": false,+ "autoincrement": false+ },+ "shifts_created": {+ "name": "shifts_created",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "shifts_updated": {+ "name": "shifts_updated",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "shifts_deleted": {+ "name": "shifts_deleted",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": 0+ },+ "sync_type": {+ "name": "sync_type",+ "type": "text",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "'auto'"+ },+ "is_read": {+ "name": "is_read",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": false+ },+ "synced_at": {+ "name": "synced_at",+ "type": "integer",+ "primaryKey": false,+ "notNull": true,+ "autoincrement": false,+ "default": "CURRENT_TIMESTAMP"+ }+ },+ "indexes": {},+ "foreignKeys": {+ "sync_logs_calendar_id_calendars_id_fk": {+ "name": "sync_logs_calendar_id_calendars_id_fk",+ "tableFrom": "sync_logs",+ "tableTo": "calendars",+ "columnsFrom": [+ "calendar_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "onUpdate": "no action"+ },+ "sync_logs_external_sync_id_external_syncs_id_fk": {+ "name": "sync_logs_external_sync_id_external_syncs_id_fk",+ "tableFrom": "sync_logs",+ "tableTo": "external_syncs",+ "columnsFrom": [+ "external_sync_id"+ ],+ "columnsTo": [+ "id"+ ],+ "onDelete": "cascade",+ "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 776afde..9c58b29 100644--- a/drizzle/meta/_journal.json+++ b/drizzle/meta/_journal.json@@ -85,6 +85,13 @@"when": 1765917907080,"tag": "0011_loose_bloodaxe","breakpoints": true+ },+ {+ "idx": 12,+ "version": "6",+ "when": 1766343608483,+ "tag": "0012_confused_nico_minoru",+ "breakpoints": true}]}\ No newline at end of filediff --git a/hooks/useDialogStates.ts b/hooks/useDialogStates.tsindex 72b021a..8541e4c 100644--- a/hooks/useDialogStates.ts+++ b/hooks/useDialogStates.ts@@ -1,5 +1,6 @@import { useState } from "react";import { ShiftWithCalendar } from "@/lib/types";+import { CalendarNote } from "@/lib/db/schema";export function useDialogStates() {const [showCalendarDialog, setShowCalendarDialog] = useState(false);@@ -15,6 +16,7 @@ export function useDialogStates() {const [showDayShiftsDialog, setShowDayShiftsDialog] = useState(false);const [showSyncedShiftsDialog, setShowSyncedShiftsDialog] = useState(false);const [showViewSettingsDialog, setShowViewSettingsDialog] = useState(false);+ const [showNotesListDialog, setShowNotesListDialog] = useState(false);const [selectedDayDate, setSelectedDayDate] = useState<Date | null>(null);const [selectedDayShifts, setSelectedDayShifts] = useState<@@ -23,6 +25,7 @@ export function useDialogStates() {const [selectedSyncedShifts, setSelectedSyncedShifts] = useState<ShiftWithCalendar[]>([]);+ const [selectedDayNotes, setSelectedDayNotes] = useState<CalendarNote[]>([]);return {showCalendarDialog,@@ -45,11 +48,15 @@ export function useDialogStates() {setShowSyncedShiftsDialog,showViewSettingsDialog,setShowViewSettingsDialog,+ showNotesListDialog,+ setShowNotesListDialog,selectedDayDate,setSelectedDayDate,selectedDayShifts,setSelectedDayShifts,selectedSyncedShifts,setSelectedSyncedShifts,+ selectedDayNotes,+ setSelectedDayNotes,};}diff --git a/hooks/useNoteActions.ts b/hooks/useNoteActions.tsindex a405a9a..9e7af50 100644--- a/hooks/useNoteActions.ts+++ b/hooks/useNoteActions.ts@@ -5,12 +5,20 @@ interface UseNoteActionsProps {createNote: (text: string,date: Date,- onPasswordRequired: () => void+ onPasswordRequired: () => void,+ type?: "note" | "event",+ color?: string,+ recurringPattern?: string,+ recurringInterval?: number) => Promise<boolean>;updateNote: (id: string,text: string,- onPasswordRequired: () => void+ onPasswordRequired: () => void,+ type?: "note" | "event",+ color?: string,+ recurringPattern?: string,+ recurringInterval?: number) => Promise<boolean>;deleteNote: (id: string, onPasswordRequired: () => void) => Promise<boolean>;onPasswordRequired: (action: () => Promise<void>) => void;@@ -27,21 +35,59 @@ export function useNoteActions({const [showNoteDialog, setShowNoteDialog] = useState(false);const handleNoteSubmit = useCallback(- async (noteText: string) => {+ async (+ noteText: string,+ type?: "note" | "event",+ color?: string,+ recurringPattern?: string,+ recurringInterval?: number+ ) => {const handlePasswordRequired = () => {onPasswordRequired(async () => {if (selectedNote) {- await updateNote(selectedNote.id, noteText, handlePasswordRequired);+ await updateNote(+ selectedNote.id,+ noteText,+ handlePasswordRequired,+ type,+ color,+ recurringPattern,+ recurringInterval+ );} else if (selectedDate) {- await createNote(noteText, selectedDate, handlePasswordRequired);+ await createNote(+ noteText,+ selectedDate,+ handlePasswordRequired,+ type,+ color,+ recurringPattern,+ recurringInterval+ );}});};if (selectedNote) {- await updateNote(selectedNote.id, noteText, handlePasswordRequired);+ await updateNote(+ selectedNote.id,+ noteText,+ handlePasswordRequired,+ type,+ color,+ recurringPattern,+ recurringInterval+ );} else if (selectedDate) {- await createNote(noteText, selectedDate, handlePasswordRequired);+ await createNote(+ noteText,+ selectedDate,+ handlePasswordRequired,+ type,+ color,+ recurringPattern,+ recurringInterval+ );}},[selectedNote, selectedDate, createNote, updateNote, onPasswordRequired]diff --git a/hooks/useNotes.ts b/hooks/useNotes.tsindex 5071a96..9a79f1d 100644--- a/hooks/useNotes.ts+++ b/hooks/useNotes.ts@@ -43,7 +43,11 @@ export function useNotes(calendarId: string | undefined) {const createNote = async (noteText: string,date: Date,- onPasswordRequired?: () => void+ onPasswordRequired?: () => void,+ type?: "note" | "event",+ color?: string,+ recurringPattern?: string,+ recurringInterval?: number) => {if (!calendarId) return false;@@ -57,6 +61,10 @@ export function useNotes(calendarId: string | undefined) {calendarId: calendarId,date: formatDateToLocal(date),note: noteText,+ type: type,+ color: color,+ recurringPattern: recurringPattern,+ recurringInterval: recurringInterval,password,}),});@@ -78,11 +86,13 @@ export function useNotes(calendarId: string | undefined) {const newNote = await response.json();setNotes((prev) => [...prev, newNote]);- toast.success(t("common.created", { item: t("note.note") }));+ const itemType = type === "event" ? t("note.typeEvent") : t("note.note");+ toast.success(t("common.created", { item: itemType }));return true;} catch (error) {console.error("Failed to create note:", error);- toast.error(t("common.createError", { item: t("note.note") }));+ const itemType = type === "event" ? t("note.typeEvent") : t("note.note");+ toast.error(t("common.createError", { item: itemType }));return false;}};@@ -90,7 +100,11 @@ export function useNotes(calendarId: string | undefined) {const updateNote = async (noteId: string,noteText: string,- onPasswordRequired?: () => void+ onPasswordRequired?: () => void,+ type?: "note" | "event",+ color?: string,+ recurringPattern?: string,+ recurringInterval?: number) => {try {const password = getCachedPassword(calendarId);@@ -98,7 +112,14 @@ export function useNotes(calendarId: string | undefined) {const response = await fetch(`/api/notes/${noteId}`, {method: "PUT",headers: { "Content-Type": "application/json" },- body: JSON.stringify({ note: noteText, password }),+ body: JSON.stringify({+ note: noteText,+ type: type,+ color: color,+ recurringPattern: recurringPattern,+ recurringInterval: recurringInterval,+ password,+ }),});if (response.status === 401) {@@ -118,11 +139,13 @@ export function useNotes(calendarId: string | undefined) {const updatedNote = await response.json();setNotes((prev) => prev.map((n) => (n.id === noteId ? updatedNote : n)));- toast.success(t("common.updated", { item: t("note.note") }));+ const itemType = type === "event" ? t("note.typeEvent") : t("note.note");+ toast.success(t("common.updated", { item: itemType }));return true;} catch (error) {console.error("Failed to update note:", error);- toast.error(t("common.updateError", { item: t("note.note") }));+ const itemType = type === "event" ? t("note.typeEvent") : t("note.note");+ toast.error(t("common.updateError", { item: itemType }));return false;}};diff --git a/lib/db/schema.ts b/lib/db/schema.tsindex 7771d84..68f84a3 100644--- a/lib/db/schema.ts+++ b/lib/db/schema.ts@@ -118,6 +118,10 @@ export const calendarNotes = sqliteTable("calendar_notes", {.references(() => calendars.id, { onDelete: "cascade" }),date: integer("date", { mode: "timestamp" }).notNull(),note: text("note").notNull(),+ type: text("type").notNull().default("note"), // note or event+ color: text("color"), // for events only+ recurringPattern: text("recurring_pattern").notNull().default("none"), // none, custom-weeks, custom-months+ recurringInterval: integer("recurring_interval"), // for custom pattern (e.g., every 3 months)createdAt: integer("created_at", { mode: "timestamp" }).notNull().default(sql`CURRENT_TIMESTAMP`),diff --git a/lib/event-utils.ts b/lib/event-utils.tsnew file mode 100644index 0000000..374fd32--- /dev/null+++ b/lib/event-utils.ts@@ -0,0 +1,145 @@+import { CalendarNote } from "./db/schema";++export function matchesRecurringEvent(+ eventDate: Date,+ targetDate: Date,+ recurringPattern?: string | null,+ recurringInterval?: number | null+): boolean {+ if (!recurringPattern || recurringPattern === "none") {+ return false;+ }++ const eventMonth = eventDate.getMonth();+ const eventDay = eventDate.getDate();+ const eventDayOfWeek = eventDate.getDay();+ const eventYear = eventDate.getFullYear();+ const targetMonth = targetDate.getMonth();+ const targetDay = targetDate.getDate();+ const targetDayOfWeek = targetDate.getDay();+ const targetYear = targetDate.getFullYear();++ switch (recurringPattern) {+ case "custom-weeks": {+ // Custom weekly interval (e.g., every 2 weeks)+ if (!recurringInterval || recurringInterval <= 0) return false;+ if (eventDayOfWeek !== targetDayOfWeek) return false;+ if (targetDate < eventDate) return false;++ // Normalize dates to midnight to avoid time component issues+ const eventMidnight = new Date(eventDate);+ eventMidnight.setHours(0, 0, 0, 0);+ const targetMidnight = new Date(targetDate);+ targetMidnight.setHours(0, 0, 0, 0);++ const daysDiff = Math.floor(+ (targetMidnight.getTime() - eventMidnight.getTime()) /+ (1000 * 60 * 60 * 24)+ );+ return daysDiff % (7 * recurringInterval) === 0;+ }++ case "custom-months": {+ // Custom monthly interval (e.g., every 3 months)+ if (!recurringInterval || recurringInterval <= 0) return false;+ if (targetDate < eventDate) return false;++ // Calculate total months from a common reference point to handle year boundaries+ const eventTotalMonths = eventYear * 12 + eventMonth;+ const targetTotalMonths = targetYear * 12 + targetMonth;+ const monthsDiff = targetTotalMonths - eventTotalMonths;++ // Check if the month interval matches+ if (monthsDiff % recurringInterval !== 0) return false;++ // Handle day matching with edge case for months with fewer days+ // E.g., event on Jan 31 should match Feb 28/29, Apr 30, etc.+ const lastDayOfTargetMonth = new Date(+ targetYear,+ targetMonth + 1,+ 0+ ).getDate();+ const expectedDay = Math.min(eventDay, lastDayOfTargetMonth);++ return targetDay === expectedDay;+ }++ default:+ return false;+ }+}++// Find all events for a specific date (including recurring)+export function findEventsForDate(+ notes: CalendarNote[],+ date: Date+): CalendarNote[] {+ return notes.filter((note) => {+ if (note.type !== "event" || !note.date) return false;+ const noteDate = new Date(note.date);++ // Exact date match+ if (+ noteDate.getFullYear() === date.getFullYear() &&+ noteDate.getMonth() === date.getMonth() &&+ noteDate.getDate() === date.getDate()+ ) {+ return true;+ }++ // Recurring match+ return matchesRecurringEvent(+ noteDate,+ date,+ note.recurringPattern,+ note.recurringInterval+ );+ });+}++// Find all notes for a specific date (both notes and events, including recurring)+export function findNotesForDate(+ notes: CalendarNote[],+ date: Date+): CalendarNote[] {+ return notes.filter((note) => {+ if (!note.date) return false;+ const noteDate = new Date(note.date);++ // Exact date match+ if (+ noteDate.getFullYear() === date.getFullYear() &&+ noteDate.getMonth() === date.getMonth() &&+ noteDate.getDate() === date.getDate()+ ) {+ return true;+ }++ // Recurring match (only for events)+ if (note.type === "event") {+ return matchesRecurringEvent(+ noteDate,+ date,+ note.recurringPattern,+ note.recurringInterval+ );+ }++ return false;+ });+}++// Legacy functions for backwards compatibility - return first match+export function findEventForDate(+ notes: CalendarNote[],+ date: Date+): CalendarNote | undefined {+ return findEventsForDate(notes, date)[0];+}++export function findNoteForDate(+ notes: CalendarNote[],+ date: Date+): CalendarNote | undefined {+ return findNotesForDate(notes, date)[0];+}diff --git a/messages/de.json b/messages/de.jsonindex 688e9e7..0d29525 100644--- a/messages/de.json+++ b/messages/de.json@@ -118,12 +118,30 @@"unlockCalendar": "Kalender entsperren"},"note": {- "create": "Neue Notiz",- "edit": "Notiz bearbeiten",+ "create": "{item} erstellen",+ "edit": "{item} bearbeiten","note": "Notiz","placeholder": "z.B. Frühdienst weil nachmittags Termin...",- "hintMobile": "Langes Drücken auf einen Tag öffnet Notizen. Das Notiz-Icon zeigt vorhandene Notizen an.",- "hintDesktop": "Rechtsklick auf einen Tag öffnet Notizen. Das Notiz-Icon zeigt vorhandene Notizen an."+ "hintMobile": "Um eine Notiz oder ein Event hinzuzufügen oder zu bearbeiten, drücke lange auf einen Tag im Kalender.",+ "hintDesktop": "Um eine Notiz oder ein Event hinzuzufügen oder zu bearbeiten, mache einen Rechtsklick auf einen Tag im Kalender.",+ "type": "Typ",+ "typeNote": "Notizen",+ "typeEvent": "Events",+ "eventColor": "Event-Farbe",+ "eventTitle": "Event-Name",+ "eventPlaceholder": "z.B. Weihnachten, Geburtstag...",+ "recurring": "Wiederholen",+ "recurringNone": "Nicht wiederholen",+ "recurringCustom": "Benutzerdefiniert",+ "recurringEveryWeeks": "Alle {count} Wochen",+ "recurringEveryMonths": "Alle {count} Monate",+ "customInterval": "Intervall",+ "every": "Alle",+ "weeks": "Wochen",+ "months": "Monate",+ "multipleEntries": "{count} Einträge",+ "noEntries": "Keine Notizen oder Events vorhanden",+ "recurringEditWarning": "Dies ist ein wiederkehrendes Event. Änderungen wirken sich auf alle Wiederholungen aus."},"shift": {"create": "Neue Schicht",diff --git a/messages/en.json b/messages/en.jsonindex 99a9c38..1bc3a97 100644--- a/messages/en.json+++ b/messages/en.json@@ -118,12 +118,30 @@"unlockCalendar": "Unlock Calendar"},"note": {- "create": "New Note",- "edit": "Edit Note",+ "create": "Create {item}",+ "edit": "Edit {item}","note": "Note","placeholder": "e.g., Early shift because appointment in the afternoon...",- "hintMobile": "Long press on a day to open notes. The note icon shows existing notes.",- "hintDesktop": "Right-click on a day to open notes. The note icon shows existing notes."+ "hintMobile": "To add or edit a note or event, long press on a day in the calendar.",+ "hintDesktop": "To add or edit a note or event, right-click on a day in the calendar.",+ "type": "Type",+ "typeNote": "Notes",+ "typeEvent": "Events",+ "eventColor": "Event Color",+ "eventTitle": "Event Name",+ "eventPlaceholder": "e.g., Christmas, Birthday...",+ "recurring": "Repeat",+ "recurringNone": "Don't repeat",+ "recurringCustom": "Custom",+ "recurringEveryWeeks": "Every {count} weeks",+ "recurringEveryMonths": "Every {count} months",+ "customInterval": "Interval",+ "every": "Every",+ "weeks": "weeks",+ "months": "months",+ "multipleEntries": "{count} entries",+ "noEntries": "No notes or events available",+ "recurringEditWarning": "This is a recurring event. Changes will affect all occurrences."},"shift": {"create": "New Shift",diff --git a/messages/it.json b/messages/it.jsonindex 03f1924..f64e8eb 100644--- a/messages/it.json+++ b/messages/it.json@@ -118,12 +118,30 @@"unlockCalendar": "Sblocca Calendario"},"note": {- "create": "Nuova Nota",- "edit": "Modifica Nota",+ "create": "Crea {item}",+ "edit": "Modifica {item}","note": "Nota","placeholder": "es., Turno mattutino perché ho un appuntamento nel pomeriggio...",- "hintMobile": "Premi a lungo su un giorno per aprire le note. L'icona della nota indica le note esistenti.",- "hintDesktop": "Fai clic con il pulsante destro del mouse su un giorno per aprire le note. L'icona della nota indica le note esistenti."+ "hintMobile": "Per aggiungere o modificare una nota o un evento, premi a lungo su un giorno nel calendario.",+ "hintDesktop": "Per aggiungere o modificare una nota o un evento, fai clic destro su un giorno nel calendario.",+ "type": "Tipo",+ "typeNote": "Note",+ "typeEvent": "Eventi",+ "eventColor": "Colore Evento",+ "eventTitle": "Nome Evento",+ "eventPlaceholder": "es., Natale, Compleanno...",+ "recurring": "Ripeti",+ "recurringNone": "Non ripetere",+ "recurringCustom": "Personalizzato",+ "recurringEveryWeeks": "Ogni {count} settimane",+ "recurringEveryMonths": "Ogni {count} mesi",+ "customInterval": "Intervallo",+ "every": "Ogni",+ "weeks": "settimane",+ "months": "mesi",+ "multipleEntries": "{count} voci",+ "noEntries": "Nessuna nota o evento disponibile",+ "recurringEditWarning": "Questo è un evento ricorrente. Le modifiche interesseranno tutte le occorrenze."},"shift": {"create": "Nuovo Turno",@@ -285,7 +303,7 @@"autoSyncLabel": "Sincronizzazione Automatica","autoSyncHint": "Scegli la frequenza con cui questo calendario deve essere sincronizzato automaticamente","autoSyncManual": "Manuale",- "autoSync24hShort": "24 ore"+ "autoSync24hShort": "24 h"},"syncNotifications": {"title": "Notifiche di Sincronizzazione",@@ -297,7 +315,7 @@"noChanges": "Nessuna modifica","errorMessage": "Messaggio di errore","filterAll": "Mostra tutto",- "filterSuccess": "Solo successo",+ "filterSuccess": "Solo riuscita","filterError": "Solo errori","deleteAll": "Elimina tutto","deleteConfirm": "Sei sicuro di voler eliminare tutti i log di sincronizzazione?",diff --git a/package-lock.json b/package-lock.jsonindex 6e3d0c2..3d8f9c9 100644--- a/package-lock.json+++ b/package-lock.json@@ -15,6 +15,7 @@"@radix-ui/react-checkbox": "^1.3.3","@radix-ui/react-dialog": "^1.1.15","@radix-ui/react-label": "^2.1.8",+ "@radix-ui/react-radio-group": "^1.3.8","@radix-ui/react-select": "^2.2.6","@radix-ui/react-slider": "^1.3.6","@radix-ui/react-slot": "^1.2.4",@@ -3068,6 +3069,69 @@}}},+ "node_modules/@radix-ui/react-radio-group": {+ "version": "1.3.8",+ "resolved": "https://registry.npmjs.org/@radix-ui/react-radio-group/-/react-radio-group-1.3.8.tgz",+ "integrity": "sha512-VBKYIYImA5zsxACdisNQ3BjCBfmbGH3kQlnFVqlWU4tXwjy7cGX8ta80BcrO+WJXIn5iBylEH3K6ZTlee//lgQ==",+ "license": "MIT",+ "dependencies": {+ "@radix-ui/primitive": "1.1.3",+ "@radix-ui/react-compose-refs": "1.1.2",+ "@radix-ui/react-context": "1.1.2",+ "@radix-ui/react-direction": "1.1.1",+ "@radix-ui/react-presence": "1.1.5",+ "@radix-ui/react-primitive": "2.1.3",+ "@radix-ui/react-roving-focus": "1.1.11",+ "@radix-ui/react-use-controllable-state": "1.2.2",+ "@radix-ui/react-use-previous": "1.1.1",+ "@radix-ui/react-use-size": "1.1.1"+ },+ "peerDependencies": {+ "@types/react": "*",+ "@types/react-dom": "*",+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"+ },+ "peerDependenciesMeta": {+ "@types/react": {+ "optional": true+ },+ "@types/react-dom": {+ "optional": true+ }+ }+ },+ "node_modules/@radix-ui/react-roving-focus": {+ "version": "1.1.11",+ "resolved": "https://registry.npmjs.org/@radix-ui/react-roving-focus/-/react-roving-focus-1.1.11.tgz",+ "integrity": "sha512-7A6S9jSgm/S+7MdtNDSb+IU859vQqJ/QAtcYQcfFC6W8RS4IxIZDldLR0xqCFZ6DCyrQLjLPsxtTNch5jVA4lA==",+ "license": "MIT",+ "dependencies": {+ "@radix-ui/primitive": "1.1.3",+ "@radix-ui/react-collection": "1.1.7",+ "@radix-ui/react-compose-refs": "1.1.2",+ "@radix-ui/react-context": "1.1.2",+ "@radix-ui/react-direction": "1.1.1",+ "@radix-ui/react-id": "1.1.1",+ "@radix-ui/react-primitive": "2.1.3",+ "@radix-ui/react-use-callback-ref": "1.1.1",+ "@radix-ui/react-use-controllable-state": "1.2.2"+ },+ "peerDependencies": {+ "@types/react": "*",+ "@types/react-dom": "*",+ "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",+ "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"+ },+ "peerDependenciesMeta": {+ "@types/react": {+ "optional": true+ },+ "@types/react-dom": {+ "optional": true+ }+ }+ },"node_modules/@radix-ui/react-select": {"version": "2.2.6","resolved": "https://registry.npmjs.org/@radix-ui/react-select/-/react-select-2.2.6.tgz",diff --git a/package.json b/package.jsonindex de175da..a52a056 100644--- a/package.json+++ b/package.json@@ -25,6 +25,7 @@"@radix-ui/react-checkbox": "^1.3.3","@radix-ui/react-dialog": "^1.1.15","@radix-ui/react-label": "^2.1.8",+ "@radix-ui/react-radio-group": "^1.3.8","@radix-ui/react-select": "^2.2.6","@radix-ui/react-slider": "^1.3.6","@radix-ui/react-slot": "^1.2.4",