DevExpress / devextreme-reactive

Business React components for Bootstrap and Material-UI
https://devexpress.github.io/devextreme-reactive/
Other
2.08k stars 382 forks source link

(@mui/x-date-pickers: 6.0.3 compatible) TypeError: date.isBefore is not a function #3645

Closed NoerNova closed 1 year ago

NoerNova commented 1 year ago

Is there an existing issue for this?

I'm using ...

React Scheduler

Current Behaviour

On the AppointmentTooltip edit button enable and press throw error: TypeError: date.isBefore is not a function.

working fine on @mui/x-date-pickers: ^5.0.0-beta.5

Screenshot 2566-03-25 at 13 54 47

Expected Behaviour

The AppointmentTooltip method works compatibly with the newer version of @mui/x-date-pickers

Steps to Reproduce

To reproduce:

Environment

shurshilov commented 1 year ago

6.0.4 still error!

jjcroftiv commented 1 year ago

I received this error today. I changed my form field values from strings, "2022-12-01T05:00:00.000Z", to dayjs dates, dayjs("2022-12-01T05:00:00.000Z"), which has resolved the issue for me.

shurshilov commented 1 year ago

its also work for me <DesktopDateTimePicker {...field} value={dayjs(field.value)} format={"DD MM YYYY HH:mm"} slotProps={{ textField: { variant: 'outlined' } }} />}

NoerNova commented 1 year ago

My current issue came from dx-react-scheduler not @mui/x-date-pickers itself, dx-react-scheduler not accept dayjs object but native Date object.

I tried this

const currentDate = dayjs("2023-03-28").toDate();

  const events = mockupEventData?.map(
    ({ title, date, startDate, endDate, type }) => ({
      startDate: dayjs(startDate).toDate(),
      endDate: dayjs(endDate).toDate(),
      title,
      type,
    })
  );

  return (
    <Scheduler data={events}>
      <ViewState currentDate={currentDate} />
      <EditingState onCommitChanges={commitChanges} />
      <IntegratedEditing />
      <DayView startDayHour={8} endDayHour={20} />
      <ConfirmationDialog />
      <Appointments />
      <AppointmentTooltip showOpenButton showDeleteButton />
      <AppointmentForm />
      <Resources data={resources} />
    </Scheduler>

the error will appear when clicking to edit the appointment events

artem-kurchenko commented 1 year ago

Hello,

Reactive Scheduler doesn't support v6 of @mui/x-date-pickers. This package contains a number of breaking changes that we didn't address. The issue you encountered occurs due to changes made to the value property: Update the format of the value prop.

While we're not planning to migrate to v6, your idea to replace an editor is valid. I've modified my example as a starting point: CodeSandBox. Note that I used the AdapterMoment adapter because Reactive Scheduler uses moment.js internally. Anyway, I cannot guarantee that these new editors will work in all cases as we didn't test them. Please keep in mind that more changes may be needed depending on your Scheduler configuration.