diff --git a/src/app/page.tsx b/src/app/page.tsx index 25014f8..e4254f3 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -39,6 +39,7 @@ export default function HomePage() { const [events, setEvents] = useState([]); const [dialogOpen, setDialogOpen] = useState(false); const [editingId, setEditingId] = useState(null); + const [dialogSource, setDialogSource] = useState<"manual" | "ai">("manual"); const [isDragOver, setIsDragOver] = useState(false); // Form fields @@ -85,6 +86,7 @@ export default function HomePage() { setEnd(""); setAllDay(false); setEditingId(null); + setDialogSource("manual"); setRecurrenceRule(undefined); }; @@ -257,10 +259,11 @@ export default function HomePage() { if (data.length === 1) { populateEventForm(data[0]); + setDialogSource("ai"); setAiPrompt(""); setDialogOpen(true); handleImagesClear(); - return { message: "Event has been created!" }; + return { message: "Draft event is ready for review." }; } await persistAiEvents(data); @@ -318,6 +321,7 @@ export default function HomePage() { setEnd(eventData.end || ""); setAllDay(eventData.allDay || false); setEditingId(eventData.id); + setDialogSource("manual"); setRecurrenceRule(eventData.recurrenceRule); setDialogOpen(true); }; @@ -344,7 +348,11 @@ export default function HomePage() { summary={summary} summaryUpdated={summaryUpdated} events={events} - onAddEvent={() => setDialogOpen(true)} + onAddEvent={() => { + resetForm(); + setDialogSource("manual"); + setDialogOpen(true); + }} onImport={handleImport} onExport={handleExport} onClearAll={handleClearAll} @@ -356,6 +364,7 @@ export default function HomePage() { open={dialogOpen} onOpenChange={setDialogOpen} editingId={editingId} + dialogSource={dialogSource} title={title} setTitle={setTitle} description={description} diff --git a/src/components/event-dialog.tsx b/src/components/event-dialog.tsx index 4424dab..cc0f9ee 100644 --- a/src/components/event-dialog.tsx +++ b/src/components/event-dialog.tsx @@ -22,6 +22,7 @@ interface EventDialogProps { open: boolean; onOpenChange: (open: boolean) => void; editingId: string | null; + dialogSource: "manual" | "ai"; title: string; setTitle: (title: string) => void; description: string; @@ -46,6 +47,7 @@ export const EventDialog = ({ open, onOpenChange, editingId, + dialogSource, title, setTitle, description, @@ -65,6 +67,19 @@ export const EventDialog = ({ onSave, onReset, }: EventDialogProps) => { + const isAiDraft = dialogSource === "ai" && !editingId; + const titleText = editingId + ? "Edit Event" + : isAiDraft + ? "Review AI Draft" + : "New Event"; + const descriptionText = editingId + ? "Update the event details below. Title and start date are required." + : isAiDraft + ? "AI filled in this event from your prompt. Review each field, then save when it looks right." + : "Create an event manually. Title and start date are required."; + const saveLabel = editingId ? "Update Event" : "Save Event"; + const handleOpenChange = (val: boolean) => { if (!val) onReset(); onOpenChange(val); @@ -94,52 +109,67 @@ export const EventDialog = ({ - - {editingId ? "Edit Event" : "New Event"} - - - Fill in the event details below. Title and start date are required. - + {titleText} + {descriptionText}
- setTitle(e.target.value)} - className="font-medium" - /> + {isAiDraft && ( +
+ This draft was generated from natural language. Double-check + dates, times, location, recurrence, and links before saving. +
+ )} -