Scheduler crashed

0 Answers 62 Views
Scheduler
Yiheng
Top achievements
Rank 2
Iron
Iron
Iron
Yiheng asked on 27 Jun 2023, 04:28 PM

Here is my code, and it crashed. 

import {
  AgendaView,
  DayView,
  MonthView,
  Scheduler,
  TimelineView,
  WeekView,
} from '@progress/kendo-react-scheduler';
import * as React from 'react';
import { useState } from 'react';
import { useQuery } from 'react-query';
import { useAppContext } from '../../AppContext';
import { getCalendarEvents } from './getCalendarEvents';

const workDayStart = '09:00';
const workDayEnd = '18:00';
export function Calendar() {
  const { accessToken } = useAppContext();
  const [isMonthView, setIsMonthView] = useState(false);
  const [selectedDate, setSelectedDate] = useState(new Date());

  const { data: events } = useQuery({
    queryKey: ['getCalendarEvents', { selectedDate, isMonthView, accessToken }],
    queryFn: getCalendarEvents,
    initialData: [],
    refetchOnWindowFocus: false,
  });

  const onDateChange = (e) => {
    setSelectedDate(e.value);
    console.log(e.value);
  };
  const onViewChange = (e) => {
    if (e.value === 'month') {
      setIsMonthView(true);
    } else {
      setIsMonthView(false);
    }
  };

  return (
    <Scheduler data={events} onDateChange={onDateChange} onViewChange={onViewChange}>
      <WeekView title='Week' workDayStart={workDayStart} workDayEnd={workDayEnd} />
      <AgendaView />
      <DayView workDayStart={workDayStart} workDayEnd={workDayEnd} />
      <TimelineView workDayStart={workDayStart} workDayEnd={workDayEnd} />
      <MonthView />
    </Scheduler>
  );
}

No answers yet. Maybe you can help?

Tags
Scheduler
Asked by
Yiheng
Top achievements
Rank 2
Iron
Iron
Iron
Share this question
or