@@ -14,6 +14,56 @@ import { ObjectView } from './components/ObjectView';
1414import { DashboardView } from './components/DashboardView' ;
1515import { PageView } from './components/PageView' ;
1616
17+ import { DetailView } from '@object-ui/plugin-detail' ;
18+ import { useParams } from 'react-router-dom' ;
19+
20+ // ... existing imports ...
21+
22+ // Detail View Component
23+ function RecordDetailView ( { dataSource, objects, onEdit } : any ) {
24+ const { objectName, recordId } = useParams ( ) ;
25+ const objectDef = objects . find ( ( o : any ) => o . name === objectName ) ;
26+
27+ if ( ! objectDef ) {
28+ return (
29+ < div className = "flex h-full items-center justify-center p-4" >
30+ < Empty >
31+ < EmptyTitle > Object Not Found</ EmptyTitle >
32+ < p > Object "{ objectName } " definition missing.</ p >
33+ </ Empty >
34+ </ div >
35+ ) ;
36+ }
37+
38+ return (
39+ < div className = "h-full bg-background overflow-auto" >
40+ < DetailView
41+ schema = { {
42+ type : 'detail-view' ,
43+ objectName : objectDef . name ,
44+ resourceId : recordId ,
45+ showBack : true ,
46+ onBack : 'history' ,
47+ showEdit : true ,
48+ sections : [
49+ {
50+ title : 'Details' ,
51+ fields : Object . keys ( objectDef . fields || { } ) . map ( key => ( {
52+ name : key ,
53+ label : objectDef . fields [ key ] . label ,
54+ type : objectDef . fields [ key ] . type
55+ } ) ) ,
56+ columns : 2
57+ }
58+ ]
59+ } }
60+ dataSource = { dataSource }
61+ onEdit = { ( ) => onEdit ( { _id : recordId , id : recordId } ) }
62+ />
63+ </ div >
64+ )
65+ }
66+
1767export function AppContent ( ) {
1868 const [ client , setClient ] = useState < ObjectStackClient | null > ( null ) ;
1969 const [ dataSource , setDataSource ] = useState < ObjectStackDataSource | null > ( null ) ;
@@ -75,6 +125,14 @@ export function AppContent() {
75125 setEditingRecord ( record ) ;
76126 setIsDialogOpen ( true ) ;
77127 } ;
128+
129+ const handleRowClick = ( record : any ) => {
130+ // Check for both string ID and Mongo/ObjectQL _id
131+ const id = record . _id || record . id ;
132+ if ( id && currentObjectDef ) {
133+ navigate ( `/${ currentObjectDef . name } /${ id } ` ) ;
134+ }
135+ } ;
78136
79137 const handleAppChange = ( appName : string ) => {
80138 setActiveAppName ( appName ) ;
@@ -112,7 +170,15 @@ export function AppContent() {
112170 < Navigate to = { findFirstRoute ( activeApp . navigation ) } replace />
113171 } />
114172 < Route path = "/:objectName" element = {
115- < ObjectView dataSource = { dataSource } objects = { allObjects } onEdit = { handleEdit } />
173+ < ObjectView
174+ dataSource = { dataSource }
175+ objects = { allObjects }
176+ onEdit = { handleEdit }
177+ onRowClick = { handleRowClick }
178+ />
179+ } />
180+ < Route path = "/:objectName/:recordId" element = {
181+ < RecordDetailView dataSource = { dataSource } objects = { allObjects } onEdit = { handleEdit } />
116182 } />
117183 < Route path = "/dashboard/:dashboardName" element = {
118184 < DashboardView />
0 commit comments