From 18ba0a47e19107f71f8a384d60d8c721ed1e9ee4 Mon Sep 17 00:00:00 2001 From: lotherk Date: Fri, 27 Mar 2026 09:28:47 +0000 Subject: [PATCH] feat: add inline edit functionality for unlocked events - EntryList now supports inline editing with pencil icon - Click pencil to edit, Save/Cancel buttons appear - Edit works on Home and Day pages --- frontend/src/components/EntryList.tsx | 83 +++++++++++++++++++++++---- frontend/src/pages/Day.tsx | 9 ++- frontend/src/pages/Home.tsx | 9 ++- 3 files changed, 87 insertions(+), 14 deletions(-) diff --git a/frontend/src/components/EntryList.tsx b/frontend/src/components/EntryList.tsx index 62d6664..be5d527 100644 --- a/frontend/src/components/EntryList.tsx +++ b/frontend/src/components/EntryList.tsx @@ -1,12 +1,17 @@ +import { useState } from 'react'; import type { Event } from '../lib/api'; interface Props { events: Event[]; onDelete: (id: string) => void; + onEdit: (id: string, content: string) => Promise; readOnly?: boolean; } -export default function EntryList({ events, onDelete, readOnly }: Props) { +export default function EntryList({ events, onDelete, onEdit, readOnly }: Props) { + const [editingId, setEditingId] = useState(null); + const [editContent, setEditContent] = useState(''); + const formatTime = (dateStr: string) => { return new Date(dateStr).toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit' }); }; @@ -20,9 +25,26 @@ export default function EntryList({ events, onDelete, readOnly }: Props) { } }; + const startEdit = (event: Event) => { + setEditingId(event.id); + setEditContent(event.content); + }; + + const cancelEdit = () => { + setEditingId(null); + setEditContent(''); + }; + + const saveEdit = async () => { + if (editingId && editContent.trim()) { + await onEdit(editingId, editContent.trim()); + setEditingId(null); + setEditContent(''); + } + }; + return (
- {events.map((event) => (
{formatTime(event.createdAt)} {event.type}
-

{event.content}

- {event.mediaPath && ( + {editingId === event.id ? ( +
+