From 0ae766d89892038cb93c015b88422ad49f12b7b8 Mon Sep 17 00:00:00 2001
From: Amr Gaber
Date: Fri, 6 Feb 2026 18:41:45 -0600
Subject: [PATCH 1/2] Unify add/edit item form with marks and notes sections
Remove the create-only restriction on marks and notes sections in
ItemForm, and update EditItemDialog to handle creating marks and notes
after a successful edit.
---
src/components/item-form.tsx | 41 ++++++-------
src/pages/items/item-detail-page.tsx | 86 ++++++++++++++++++++++++++--
2 files changed, 99 insertions(+), 28 deletions(-)
diff --git a/src/components/item-form.tsx b/src/components/item-form.tsx
index 97a3189..b0d3734 100644
--- a/src/components/item-form.tsx
+++ b/src/components/item-form.tsx
@@ -127,7 +127,7 @@ export function ItemForm({
})
const [stagedFiles, setStagedFiles] = useState([])
- // Staged marks & notes (create mode only)
+ // Staged marks & notes
const [stagedMarks, setStagedMarks] = useState([])
const [stagedNotes, setStagedNotes] = useState([])
@@ -144,7 +144,8 @@ export function ItemForm({
"provenance",
...(typeDef && typeDef.fields.length > 0 ? ["typeFields"] : []),
"dimensions",
- ...(!isEdit ? ["marks", "notes"] : []),
+ "marks",
+ "notes",
]
const allExpanded = sectionKeys.every((k) => openSections[k])
const toggleAll = () => {
@@ -517,27 +518,23 @@ export function ItemForm({
- {/* Marks section (create only) */}
- {!isEdit && (
- toggleSection("marks", v)}
- >
-
-
- )}
+ {/* Marks section */}
+ toggleSection("marks", v)}
+ >
+
+
- {/* Notes section (create only) */}
- {!isEdit && (
- toggleSection("notes", v)}
- >
-
-
- )}
+ {/* Notes section */}
+ toggleSection("notes", v)}
+ >
+
+
)}
- {/* Tabs */}
-
-
- Details
- Images
- Provenance
- Dimensions
- Marks
- Notes
-
-
-
- {item.description && (
-
- )}
-
-
-
-
-
- {item.type_fields && typeDef && typeDef.fields.length > 0 && (
- <>
-
-
- {typeDef.label} Details
-
- {typeDef.fields.map((field) => {
- const raw = (
- item.type_fields as Record
- )?.[field.name]
- if (!raw) return null
- let display = String(raw)
- if (field.type === "enum" && field.options) {
- const opt = field.options.find((o) => o.value === raw)
- if (opt) display = opt.label
- }
- return (
-
- )
- })}
- >
- )}
- {!item.description &&
- !item.location &&
- !item.acquisition_date &&
- !item.acquisition_price &&
- !item.estimated_value &&
- !item.acquisition_source &&
- !item.type_fields && (
-
+ {/* Expand / Collapse all */}
+
+
+ {/* Sections */}
+
+
toggleSection("details", v)}
+ >
+
+ {item.description && (
+
)}
-
+
+
+
+
+
+ {item.type_fields && typeDef && typeDef.fields.length > 0 && (
+ <>
+
+
+ {typeDef.label} Details
+
+ {typeDef.fields.map((field) => {
+ const raw = (
+ item.type_fields as Record
+ )?.[field.name]
+ if (!raw) return null
+ let display = String(raw)
+ if (field.type === "enum" && field.options) {
+ const opt = field.options.find((o) => o.value === raw)
+ if (opt) display = opt.label
+ }
+ return (
+
+ )
+ })}
+ >
+ )}
+ {!item.description &&
+ !item.location &&
+ !item.acquisition_date &&
+ !item.acquisition_price &&
+ !item.estimated_value &&
+ !item.acquisition_source &&
+ !item.type_fields && (
+
+ )}
+
+
-
+ toggleSection("images", v)}
+ >
-
-
-
-
-
-
- {(item.artist_maker || item.origin || item.date_era) && (
-
- )}
-
-
-
-
-
-
-
-
-
- {!item.height_cm &&
- !item.width_cm &&
- !item.depth_cm &&
- !item.weight_kg &&
- !item.materials && (
-
+
+
+ toggleSection("provenance", v)}
+ >
+
+
+
+
+ {(item.artist_maker || item.origin || item.date_era) && (
+
)}
-
+
+
+
+
+ toggleSection("dimensions", v)}
+ >
+
+
+
+
+
+
+ {!item.height_cm &&
+ !item.width_cm &&
+ !item.depth_cm &&
+ !item.weight_kg &&
+ !item.materials && (
+
+ )}
+
+
-
+ toggleSection("marks", v)}
+ >
-
+
-
+ toggleSection("notes", v)}
+ >
-
-
+
+
{message}
)
}
+function DetailSection({
+ title,
+ open,
+ onOpenChange,
+ children,
+}: {
+ title: string
+ open: boolean
+ onOpenChange: (open: boolean) => void
+ children: React.ReactNode
+}) {
+ return (
+
+
+
+
+
+ {children}
+
+
+ )
+}
+
function ItemHeaderSkeleton() {
return (