Hello,
on my scheduler, I'm listening for the onBeforeEventDropFinalize event, and i'm calling an API inside. So as the doc says, I use
context.async = true;
inside to tell the event I will resolve it later.
For my API call, I need to know the new startDate and endDate, data I'm taking from context.startDate and context.endDate.
But here come the problem, I've notice that sometimes, the context.startDate I get is not the same than the one displayed inside the tooltip displayed while dragging an event...
const handleEventDropFinalize = useCallback(
async ({ context }: SchedulerOnEventDropProps) => {
// CF. doc, this is intended
context.async = true;
const { id } = context.eventRecord.data;
console.log({ startDate: context.startDate });
const isoStartDate = moment(context.startDate).utc(true).toISOString();
const isoEndDate = moment(context.endDate).utc(true).toISOString();
const finalize = (value: boolean) => () => {
context.finalize(value);
};
await updateSchedulerCampaignDates({
startDate: isoStartDate,
endDate: isoEndDate,
campaignId: id,
onSuccess: finalize(true),
onError: finalize(false),
});
},
[updateSchedulerCampaignDates],
);
In the code above, I'd say 6 or 7/10 times, it works correctly, but the rest of the time, I have a difference between the date in tooltip and the date in the context. This is totally random..
When dragging the date to the right, I may see 17:00 in the drag tooltip, and I get 18:00 in the context.startDate.
And the problem is reversed when dragging to the left: I see 17:00 in the drag tooltip and I get 16:00 in the context.startDate.
I don't know if it help, but I'm in french actually, so timezone is GMT + 1.
Thanks in advance for your help, much appreciate