Skip to content

Commit 4691f1e

Browse files
committed
Enhance RecordDetailView to support both KV object and array formats for fields, and add refresh mechanism on success
1 parent db31f99 commit 4691f1e

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

apps/console/src/App.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export function AppContent() {
8383

8484
const [isDialogOpen, setIsDialogOpen] = useState(false);
8585
const [editingRecord, setEditingRecord] = useState<any>(null);
86+
const [refreshKey, setRefreshKey] = useState(0);
8687

8788
useEffect(() => {
8889
initializeClient();
@@ -179,7 +180,7 @@ export function AppContent() {
179180
/>
180181
} />
181182
<Route path="/:objectName/:recordId" element={
182-
<RecordDetailView dataSource={dataSource} objects={allObjects} onEdit={handleEdit} />
183+
<RecordDetailView key={refreshKey} dataSource={dataSource} objects={allObjects} onEdit={handleEdit} />
183184
} />
184185
<Route path="/dashboard/:dashboardName" element={
185186
<DashboardView />
@@ -208,12 +209,13 @@ export function AppContent() {
208209
recordId: editingRecord?.id,
209210
layout: 'vertical',
210211
columns: 1,
211-
// FIX: fields property should be array of strings, but currentObjectDef.fields might be an object
212-
// Explicitly map all keys to ensure we include all fields
213-
fields: currentObjectDef.fields && !Array.isArray(currentObjectDef.fields)
214-
? Object.keys(currentObjectDef.fields)
215-
: (currentObjectDef.fields || []).map((f: any) => typeof f === 'string' ? f : f.name),
216-
onSuccess: () => { setIsDialogOpen(false); navigate(location.pathname); },
212+
// Support both KV object and array format for fields
213+
fields: currentObjectDef.fields
214+
? (Array.isArray(currentObjectDef.fields)
215+
? currentObjectDef.fields.map((f: any) => typeof f === 'string' ? f : f.name)
216+
: Object.keys(currentObjectDef.fields))
217+
: [],
218+
onSuccess: () => { setIsDialogOpen(false); setRefreshKey(k => k + 1); },
217219
onCancel: () => setIsDialogOpen(false),
218220
showSubmit: true,
219221
showCancel: true,

0 commit comments

Comments
 (0)