jquense / react-big-calendar

gcal/outlook like calendar component
http://jquense.github.io/react-big-calendar/examples/index.html
MIT License
7.93k stars 2.24k forks source link

Documenting onDropFromOutside Event Handler for Resource Schedulers #2662

Open Javo2804 opened 1 month ago

Javo2804 commented 1 month ago

Hi everyone!

I've been working with external events in a resource-based calendar and had trouble retrieving the resourceId when dropping an external event using the onDropFromOutside event handler.

I came across this comment by @MALIK-0 in issue #1090 that mentions passing a resource argument, which corresponds to the resourceId. However, this isn't officially documented, which made it difficult to figure out.

Since I couldn't find much information for this use case (external events and resource-based calendar), it would be helpful to include documentation about handling resourceId within onDropFromOutside. I believe this would be beneficial for future users, especially since it’s been challenging (at least for me) to find open-source libraries that support resource scheduling effectively.

Here’s an example of how I managed to get it working:

const onDropFromOutside = useCallback(
  ({ start, end, allDay, resource }) => {
    const event = draggedEvent;
    if (!event) return;

    const newEvent = {
      ...event,
      start,
      end,
      allDay,
      resourceId: resource,
    };

    setEvents((prevEvents) => [...prevEvents, newEvent]);
    setDraggedEvent(null);
  },
  [setEvents, draggedEvent]
);

Thank you very much for the awesome work!! This library has been a lifesaver for my project.

AyendiSimeon1 commented 3 days ago

I want to fix this issue. Can you assign it to me so i can start right away.

cutterbl commented 2 days ago

@AyendiSimeon1 Just file a PR and I'll look at it.