fix(cortex): update date handling in API and UI components
- Adjusted date handling in the agenda API to ensure optional parameters for start, end, and label are correctly processed. - Enhanced chat input and action parser to support optional date labels for relative dates. - Updated agenda components to handle date ranges and loading states more effectively. - Improved error handling and loading indicators in the agenda block for better user experience. This commit ensures consistency in date handling across the application, aligning with the new requirements for relative date inputs.
This commit is contained in:
@@ -20,6 +20,7 @@ interface AgendaCalendarProps {
|
||||
events: CalendarEvent[];
|
||||
initialView?: CalendarView;
|
||||
currentView?: CalendarView;
|
||||
currentDate?: Date;
|
||||
onEventClick?: (event: CalendarEvent) => void;
|
||||
onDateSelect?: (start: Date, end: Date) => void;
|
||||
onEventDrop?: (eventId: string, newStart: Date, newEnd: Date | null) => void;
|
||||
@@ -31,6 +32,7 @@ export function AgendaCalendar({
|
||||
events,
|
||||
initialView = 'timeGridWeek',
|
||||
currentView,
|
||||
currentDate,
|
||||
onEventClick,
|
||||
onDateSelect,
|
||||
onEventDrop,
|
||||
@@ -47,7 +49,6 @@ export function AgendaCalendar({
|
||||
if (api.view.type !== currentView) {
|
||||
isChangingViewRef.current = true;
|
||||
api.changeView(currentView);
|
||||
// Reset flag after a short delay to allow the view change to complete
|
||||
setTimeout(() => {
|
||||
isChangingViewRef.current = false;
|
||||
}, 100);
|
||||
@@ -55,6 +56,20 @@ export function AgendaCalendar({
|
||||
}
|
||||
}, [currentView]);
|
||||
|
||||
// Sync date when currentDate prop changes
|
||||
useEffect(() => {
|
||||
if (currentDate && internalRef.current) {
|
||||
const api = internalRef.current.getApi();
|
||||
if (api.getDate().toDateString() !== currentDate.toDateString()) {
|
||||
isChangingViewRef.current = true;
|
||||
api.gotoDate(currentDate);
|
||||
setTimeout(() => {
|
||||
isChangingViewRef.current = false;
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
}, [currentDate]);
|
||||
|
||||
const handleEventClick = useCallback((info: EventClickArg) => {
|
||||
if (onEventClick) {
|
||||
const event = info.event;
|
||||
|
||||
Reference in New Issue
Block a user