Multi-Resource Shared Events

Events can be shared among resources. This can easily be the same resource type, like people in a shared work calendar scenario or different resource types, like aircraft and instructor in a flight training scenario where you'll have to schedule an instructor and an aircraft for a class which is the event.

Shared events will render correctly in the appropriate resource columns with drag & drop, validation across invalid dates and times will work out of the box. All you need to do is to add both resourceIDs to the event.

Get started with this example

Demo

Loading the live demo

Preview in full screen

Schedule event across multiple resources in the Scheduler — for shared work calendars, mixed resource types like instructor and aircraft.

Code

import { Eventcalendar, Input, Popup, Segmented, SegmentedGroup, setOptions  } from '@mobiscroll/react';
import { useCallback, useMemo, useState } from 'react';

setOptions({
  locale:  ,
  theme: ' ',
  themeVariant: ' '
});

function App() {
  const [tempEvent, setTempEvent] = useState(null);
  const [title, setTitle] = useState('New event');
  const [participants, setParticipants] = useState([]);
  const [anchor, setAnchor] = useState(null);
  const [isNewEvent, setIsNewEvent] = useState(false);
  const [isOpen, setOpen] = useState(false);

  const [myEvents, setEvents] = useState([
    {
      start: '2026-10-21T10:00',
      end: '2026-10-21T15:00',
      title: 'Impact Training',
      resource: [2, 3],
      color: '#35bb5a',
    },
    {
      start: '2026-10-22T10:00',
      end: '2026-10-22T15:00',
      title: 'Impact Training',
      resource: [2, 3],
      color: '#35bb5a',
    },
    {
      start: '2026-10-24T08:30',
      end: '2026-10-24T10:00',
      title: 'Quick mtg. with Martin',
      resource: 3,
      color: '#913aa7',
    },
    {
      start: '2026-10-24T12:00',
      end: '2026-10-24T13:00',
      title: 'General orientation',
      resource: [1, 2, 3],
      color: '#a71111',
    },
    {
      start: '2026-10-25T10:00',
      end: '2026-10-25T11:00',
      title: 'Product team mtg.',
      resource: [2, 3],
      color: '#6e7f29',
    },
    {
      start: '2026-10-26T14:00',
      end: '2026-10-26T16:00',
      title: 'Stakeholder mtg.',
      resource: 1,
      color: '#dcd234',
    },
    {
      start: '2026-10-27T10:00',
      end: '2026-10-27T14:00',
      title: 'Innovation mtg.',
      resource: [1, 2],
      color: '#de3d83',
    },
  ]);
  const myView = useMemo(
    () => ({
      scheduler: {
        type: 'week',
        allDay: false,
        startDay: 1,
        endDay: 5,
        startTime: '05:00',
        endTime: '22:00',
      },
    }),
    [],
  );

  const myResources = useMemo(
    () => [
      {
        id: 1,
        name: 'Ryan',
        color: '#f7c4b4',
      },
      {
        id: 2,
        name: 'Kate',
        color: '#c6f1c9',
      },
      {
        id: 3,
        name: 'John',
        color: '#e8d0ef',
      },
    ],
    [],
  );
  const showPopup = useCallback((args) => {
    const event = args.event;
    const resources = Array.isArray(event.resource) ? event.resource : [event.resource];

    // Store temporary event
    setTempEvent(args.event);

    // Fill popup with the current event data
    setTitle(event.title);
    setParticipants(resources);

    // Set anchor for the popup
    setAnchor(args.target ? args.target : args.domEvent.target);
    setOpen(true);
  }, []);

  const handleEventCreated = useCallback(
    (args) => {
      setIsNewEvent(true);
      showPopup(args);
    },
    [showPopup],
  );

  const handleEventDoubleClick = useCallback(
    (args) => {
      setIsNewEvent(false);
      showPopup(args);
    },
    [showPopup],
  );

  const handleEventDeleted = useCallback(
    (args) => {
      setEvents(myEvents.filter((item) => item.id !== args.event.id));
    },
    [myEvents],
  );

  const handleExtendDefaultEvent = useCallback(() => ({ color: '#4a9e42' }), []);

  const popupButtons = useMemo(
    () => [
      'cancel',
      {
        text: 'OK',
        keyCode: 'enter',
        handler: () => {
          const updatedEvent = { ...tempEvent, resource: participants, title };

          if (isNewEvent) {
            setEvents([...myEvents, updatedEvent]);
          } else {
            setEvents(myEvents.map((item) => (item.id === updatedEvent.id ? updatedEvent : item)));
          }

          // Update event with the new properties on OK button click
          setIsNewEvent(false);

          setOpen(false);
        },
        cssClass: 'mbsc-popup-button-primary',
      },
    ],
    [isNewEvent, myEvents, participants, tempEvent, title],
  );

  const popupClose = useCallback(() => {
    if (isNewEvent) {
      setEvents(myEvents.filter((item) => item.id !== tempEvent.id));
    }
    setOpen(false);
  }, [isNewEvent, myEvents, tempEvent]);

  const titleChange = useCallback((ev) => {
    setTitle(ev.target.value);
  }, []);

  const changeParticipants = useCallback(
    (ev) => {
      const value = +ev.target.value;
      let p;

      if (ev.target.checked) {
        p = [...participants, value];
      } else {
        p = participants.filter((item) => item !== value);
      }
      setParticipants(p);
    },
    [participants],
  );

  return (
    <div>
      <Eventcalendar
        data={myEvents}
        resources={myResources}
        view={myView}
        clickToCreate={true}
        dragToCreate={true}
        dragToMove={true}
        dragToResize={true}
        onEventCreated={handleEventCreated}
        onEventDoubleClick={handleEventDoubleClick}
        onEventDeleted={handleEventDeleted}
        extendDefaultEvent={handleExtendDefaultEvent}
      />
      <Popup
        display="anchored"
        contentPadding={false}
        touchUi={false}
        width={350}
        buttons={popupButtons}
        onClose={popupClose}
        isOpen={isOpen}
        anchor={anchor}
      >
        <div className="mbsc-form-group">
          <Input label="Title" value={title} onChange={titleChange} inputStyle="box" labelStyle="stacked" />
          <div className="mbsc-padding">
            <label className="mbsc-txt-muted">Select event participants</label>
          </div>
          <SegmentedGroup select="multiple" value={participants} onChange={changeParticipants}>
            <Segmented value={1}>Ryan</Segmented>
            <Segmented value={2}>Kate</Segmented>
            <Segmented value={3}>John</Segmented>
          </SegmentedGroup>
        </div>
      </Popup>
    </div>
  );
}

export default App;

Duplicate Session

You have signed in on a different machine. To keep everything in sync, you have been signed out of this session.

If you need to invite team members, manage seats and accounts you can do it from the licenses page.

Duplicate Session

We noticed you are logged in on a different machine and have closed your old session.

If you need to invite team members, manage seats and accounts you can do it from the licenses page.