File tree Expand file tree Collapse file tree 6 files changed +36
-8
lines changed
Expand file tree Collapse file tree 6 files changed +36
-8
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import { setupServer } from 'msw/node';
77import { http , HttpResponse } from 'msw' ;
88import React from 'react' ;
99
10- const BASE_URL = 'http://test-api.com ' ;
10+ const BASE_URL = 'http://localhost ' ;
1111
1212// --- Mock Data ---
1313
@@ -32,13 +32,22 @@ const mockEvents = {
3232// --- MSW Setup ---
3333
3434const handlers = [
35+ http . options ( '*' , ( ) => {
36+ return new HttpResponse ( null , { status : 200 } ) ;
37+ } ) ,
38+
3539 http . get ( `${ BASE_URL } /api/v1` , ( ) => {
3640 return HttpResponse . json ( { status : 'ok' , version : '1.0.0' } ) ;
3741 } ) ,
3842
3943 // Data Query: GET /api/v1/data/events
4044 http . get ( `${ BASE_URL } /api/v1/data/events` , ( ) => {
4145 return HttpResponse . json ( mockEvents ) ;
46+ } ) ,
47+
48+ // Metadata Query
49+ http . get ( `${ BASE_URL } /api/v1/metadata/object/events` , ( ) => {
50+ return HttpResponse . json ( { fields : { } } ) ;
4251 } )
4352] ;
4453
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ import { ContactObject } from '../../../examples/crm/src/objects/contact.object'
1313// Register widget renderers
1414registerAllFields ( ) ;
1515
16- const BASE_URL = process . env . OBJECTSTACK_API_URL || 'http://test-api.com ' ;
16+ const BASE_URL = process . env . OBJECTSTACK_API_URL || 'http://localhost ' ;
1717
1818// --- Mock Data ---
1919
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import { ContactObject } from '../../../examples/crm/src/objects/contact.object'
1212
1313registerAllFields ( ) ;
1414
15- const BASE_URL = process . env . OBJECTSTACK_API_URL || 'http://test-api.com ' ;
15+ const BASE_URL = process . env . OBJECTSTACK_API_URL || 'http://localhost ' ;
1616
1717// --- Mock Data ---
1818
Original file line number Diff line number Diff line change @@ -42,9 +42,14 @@ export const ObjectKanban: React.FC<ObjectKanbanProps> = ({
4242 const results = await dataSource . find ( schema . objectName , {
4343 options : { $top : 100 } // Fetch up to 100 cards
4444 } ) ;
45- // Handle { value: [] } OData shape or direct array
46- const data = ( results as any ) . value || results ;
47- console . log ( "ObjectKanban fetched:" , JSON . stringify ( data ) ) ;
45+ // Handle { value: [] } OData shape or { data: [] } shape or direct array
46+ let data = results ;
47+ if ( ( results as any ) . value ) {
48+ data = ( results as any ) . value ;
49+ } else if ( ( results as any ) . data ) {
50+ data = ( results as any ) . data ;
51+ }
52+
4853 if ( Array . isArray ( data ) ) {
4954 setFetchedData ( data ) ;
5055 }
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import { setupServer } from 'msw/node';
77import { http , HttpResponse } from 'msw' ;
88import React from 'react' ;
99
10- const BASE_URL = 'http://test-api.com ' ;
10+ const BASE_URL = 'http://localhost ' ;
1111
1212// --- Mock Data ---
1313
@@ -22,6 +22,14 @@ const mockMilestones = {
2222// --- MSW Setup ---
2323
2424const handlers = [
25+ http . options ( '*' , ( ) => {
26+ return new HttpResponse ( null , { status : 200 } ) ;
27+ } ) ,
28+
29+ http . get ( `${ BASE_URL } /api/v1` , ( ) => {
30+ return HttpResponse . json ( { status : 'ok' , version : '1.0.0' } ) ;
31+ } ) ,
32+
2533 http . get ( `${ BASE_URL } /api/v1/data/milestones` , ( ) => {
2634 return HttpResponse . json ( mockMilestones ) ;
2735 } )
Original file line number Diff line number Diff line change @@ -48,7 +48,13 @@ export const ObjectTimeline: React.FC<ObjectTimelineProps> = ({
4848 const results = await dataSource . find ( schema . objectName , {
4949 options : { $top : 100 }
5050 } ) ;
51- const data = ( results as any ) . value || results ;
51+ let data = results ;
52+ if ( ( results as any ) . value ) {
53+ data = ( results as any ) . value ;
54+ } else if ( ( results as any ) . data ) {
55+ data = ( results as any ) . data ;
56+ }
57+
5258 if ( Array . isArray ( data ) ) {
5359 setFetchedData ( data ) ;
5460 }
You can’t perform that action at this time.
0 commit comments