Skip to content

Commit 33d2bfb

Browse files
committed
refactor: remove unused event handling logic from CalendarView renderer
1 parent 33b55cd commit 33d2bfb

File tree

1 file changed

+4
-94
lines changed

1 file changed

+4
-94
lines changed

packages/plugin-calendar/src/calendar-view-renderer.tsx

Lines changed: 4 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
*/
88

99
import { ComponentRegistry } from '@object-ui/core';
10-
import type { CalendarViewSchema, CalendarEvent } from '@object-ui/types';
11-
import { CalendarView } from './CalendarView';
10+
import type { CalendarViewSchema } from '@object-ui/types';
11+
import { CalendarView, type CalendarEvent } from './CalendarView';
1212
import React from 'react';
1313

1414
// Calendar View Renderer - Airtable-style calendar for displaying records as events
@@ -43,7 +43,7 @@ ComponentRegistry.register('calendar-view',
4343
}, [schema.data, schema.titleField, schema.startDateField, schema.endDateField, schema.colorField, schema.allDayField]);
4444

4545
const handleEventClick = (event: CalendarEvent) => {
46-
if (schema.events?.onEventClick) {
46+
if (schema.onEventClick) {
4747
// Dispatch configured action
4848
// This would use the action runner in a real implementation
4949
// For now we just call onAction if provided
@@ -73,97 +73,7 @@ ComponentRegistry.register('calendar-view',
7373
/>
7474
);
7575
}
76-
); const allDayField = schema.allDayField || 'allDay';
77-
78-
const title = record[titleField] || 'Untitled';
79-
const start = record[startField] ? new Date(record[startField]) : new Date();
80-
const end = record[endField] ? new Date(record[endField]) : undefined;
81-
const allDay = record[allDayField] !== undefined ? record[allDayField] : false;
82-
83-
// Handle color mapping
84-
let color = record[colorField];
85-
if (color && schema.colorMapping && schema.colorMapping[color]) {
86-
color = schema.colorMapping[color];
87-
}
88-
89-
return {
90-
id: String(record.id || record._id || index),
91-
title,
92-
start,
93-
end,
94-
allDay,
95-
color,
96-
data: record,
97-
};
98-
});
99-
}, [schema.data, schema.titleField, schema.startDateField, schema.endDateField, schema.colorField, schema.allDayField, schema.colorMapping]);
100-
101-
const handleEventClick = React.useCallback((event: any) => {
102-
if (onAction) {
103-
onAction({
104-
type: 'event_click',
105-
payload: { event: event.data, eventId: event.id }
106-
});
107-
}
108-
if (schema.onEventClick) {
109-
schema.onEventClick(event.data);
110-
}
111-
}, [onAction, schema]);
112-
113-
const handleDateClick = React.useCallback((date: Date) => {
114-
if (onAction) {
115-
onAction({
116-
type: 'date_click',
117-
payload: { date }
118-
});
119-
}
120-
if (schema.onDateClick) {
121-
schema.onDateClick(date);
122-
}
123-
}, [onAction, schema]);
124-
125-
const handleViewChange = React.useCallback((view: "month" | "week" | "day") => {
126-
if (onAction) {
127-
onAction({
128-
type: 'view_change',
129-
payload: { view }
130-
});
131-
}
132-
if (schema.onViewChange) {
133-
schema.onViewChange(view);
134-
}
135-
}, [onAction, schema]);
136-
137-
const handleNavigate = React.useCallback((date: Date) => {
138-
if (onAction) {
139-
onAction({
140-
type: 'navigate',
141-
payload: { date }
142-
});
143-
}
144-
if (schema.onNavigate) {
145-
schema.onNavigate(date);
146-
}
147-
}, [onAction, schema]);
148-
149-
const validView = (schema.view && ['month', 'week', 'day'].includes(schema.view))
150-
? (schema.view as "month" | "week" | "day")
151-
: 'month';
152-
153-
return (
154-
<CalendarView
155-
events={events}
156-
view={validView}
157-
currentDate={schema.currentDate ? new Date(schema.currentDate) : undefined}
158-
onEventClick={handleEventClick}
159-
onDateClick={schema.allowCreate || schema.onDateClick ? handleDateClick : undefined}
160-
onViewChange={handleViewChange}
161-
onNavigate={handleNavigate}
162-
className={className}
163-
{...props}
164-
/>
165-
);
166-
},
76+
,
16777
{
16878
namespace: 'plugin-calendar',
16979
label: 'Calendar View',

0 commit comments

Comments
 (0)