Role-Based Access

The following example demonstrates how to implement role-based permissions in a calendar by simulating a logged in user. The selected user determines which role and permissions are applied:

  • Project manager (Full access) - can manage all tasks
  • Employees (Limited access) - can only edit their own tasks
  • Clients (Read-only) - can view the schedule without making changes

The demo uses an outside control to simulate logging in as a specific user. Based on the chosen role, the calendar applies the corresponding permissions conditionally.

This approach shows how you could pass the logged in user's role from your authentication system and dynamically configure what actions are allowed in the timeline.

Get started with this example

Demo

Simulate logged in user
const initialEvents = [{
  start: '2026-10-22T11:00',
  end: '2026-10-22T15:00',
  title: 'Task 1',
  resource: 1
}, {
  start: '2026-10-22T14:00',
  end: '2026-10-22T17:00',
  title: 'Task 2',
  resource: 3
}, {
  start: '2026-10-22T12:00',
  end: '2026-10-22T14:00',
  title: 'Task 3',
  resource: 4
}, {
  start: '2026-10-23T10:00',
  end: '2026-10-23T15:00',
  title: 'Task 4',
  resource: 1
}, {
  start: '2026-10-23T11:00',
  end: '2026-10-23T13:00',
  title: 'Task 5',
  resource: 2
}, {
  start: '2026-10-23T14:00',
  end: '2026-10-23T17:00',
  title: 'Task 6',
  resource: 2
}, {
  start: '2026-10-23T12:00',
  end: '2026-10-23T15:00',
  title: 'Task 7',
  resource: 3
}, {
  start: '2026-10-23T17:00',
  end: '2026-10-23T20:00',
  title: 'Task 8',
  resource: 3
}, {
  start: '2026-10-23T08:00',
  end: '2026-10-23T11:30',
  title: 'Task 9',
  resource: 4
}, {
  start: '2026-10-23T12:00',
  end: '2026-10-23T14:00',
  title: 'Task 10',
  resource: 4
}, {
  start: '2026-10-23T10:00',
  end: '2026-10-23T13:00',
  title: 'Task 11',
  resource: 5
}, {
  start: '2026-10-23T14:00',
  end: '2026-10-23T16:00',
  title: 'Task 12',
  resource: 5
}, {      
  start: '2026-10-23T16:30',
  end: '2026-10-23T19:00',
  title: 'Task 13',
  resource: 5
}, {
  start: '2026-10-24T11:00',
  end: '2026-10-24T14:00',
  title: 'Task 14',
  resource: 2
}, {
  start: '2026-10-24T16:00',
  end: '2026-10-24T20:00',
  title: 'Task 15',
  resource: 5
}];

const initialResources = [{
  id: 1,
  name: 'Jude Chester',
  color: '#af2ec3'
}, {
  id: 2,
  name: 'Willis Cane',
  color: '#cccc39'
}, {
  id: 3,
  name: 'Derek Austyn',
  color: '#56ca2c'
}, {
  id: 4,
  name: 'Merv Kenny',
  color: '#af2424'
}, {
  id: 5,
  name: 'Fred Waldez',
  color: '#256ebc'
}]

function App() {
  const user = useMemo(() => ({ 
    
    
    
  }), []);

  const [editEvents, setEditEvents] = useState(false);

  const myView = useMemo(
    () => ({
      timeline: {
        type: 'week',
        startTime: '08:00',
        endTime: '20:00',
      },
    }),
    [],
  );

  const [myEvents, setEvents] = useState(initialEvents);
  const [myResources, setResources] = useState(initialResources);

  const getDefaultEvent = useCallback(
    () => ({
      color: user.role === 'limited' ? '#af2424' : '',
    }),
    [user.role],
  );

  const handleCloseToast = useCallback(() => {
    setToastOpen(false);
  }, []);

  // Simulate login
  useEffect(() => {
    const newTasks = [...initialEvents];
    const newResources = [...initialResources];

    if (user.role === 'readonly') {
      for (const task of newTasks) {
        // Disable editing for all events
        task.editable = false;
        // Make event colors uniform
        task.color = '#af2ec3';
      }
    } else if (user.role === 'limited') {
      for (const task of newTasks) {
        if (task.resource !== user.id) {
          // Disable editing events of other users
          task.editable = false
          // Set disabled event colors to gray
          task.color = '#6a6a6a'
        } else {
          // Make event colors uniform
          task.color = '#af2424'
        }
      }

      for (const res of newResources) {
        if (res.id !== user.id) {
          res.eventCreation = false;
        }
      }
    }

    // Update events, resources and d&d options
    setEvents(newTasks);
    setResources(newResources);
    setEditEvents(user.role !== 'readonly');
  }, [user]);

  return (
    <Eventcalendar
      view={myView}
      data={myEvents}
      resources={myResources}
      clickToCreate={editEvents}
      dragToCreate={editEvents}
      dragToMove={editEvents}
      dragToResize={editEvents}
      eventDelete={editEvents}
      extendDefaultEvent={getDefaultEvent}
    />
);
Implement role-based access in a Timeline: managers edit all tasks, employees edit their own, and clients have read-only access.

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.