ProSchedulerSign in

Scheduler · Resources

Shared events across resources

An event with resource: ["ada", "ben", "chloe"] belongs to all three and shows in each column. Dragging one copy to another person swaps just that person.

Live demo

Drag the kickoff from Ben's column to Dev's · Move it an hour later

Fullscreen
import { ProScheduler, type SchedulerEvent } from "@andreisaac/pro-scheduler"
import { studioResources } from "./data/studio"
import { Log, useEvents, useLog, when } from "./kit"

export function SharedEventsDemo() {
  const { events, handlers } = useEvents<SchedulerEvent>(() => {
    // Today, whatever day it is, so the day view opens on them.
    const today = new Date()
    const at = (h: number, m = 0) => new Date(today.getFullYear(), today.getMonth(), today.getDate(), h, m)
    return [
      // One event, three people: it shows in each of their columns.
      { id: "m1", title: "Kickoff: Lumen Labs", start: at(9), end: at(10), resource: ["ada", "ben", "chloe"], color: "#0f766e" },
      { id: "m2", title: "Colour review", start: at(11), end: at(12), resource: ["chloe", "dev"], color: "#7c3aed" },
      { id: "s1", title: "Edit", start: at(13), end: at(17), resource: "chloe" },
      { id: "s2", title: "Budget", start: at(14), end: at(15, 30), resource: "ben" },
      { id: "s3", title: "Grade", start: at(9), end: at(11), resource: "dev" },
    ]
  })
  const { lines, log } = useLog()

  return (
    <div className="docs-demo__stack">
      <ProScheduler
        data={events}
        resources={studioResources.slice(0, 4)}
        view={{ scheduler: { type: "day", resources: true, startTime: "08:00", endTime: "18:00" } }}
        onEventUpdated={(event) => {
          log(`"${event.title}" → ${[event.resource].flat().join(", ")}, ${when(event.start)}`)
          handlers.onEventUpdated(event)
        }}
        onEventCreated={handlers.onEventCreated}
        onEventDeleted={handlers.onEventDeleted}
        height={520}
      />
      <Log lines={lines} empty="Drag the kickoff from Ben's column to Dev's…" />
    </div>
  )
}

About this demo

An event with resource: ["ada", "ben", "chloe"] belongs to all three and shows in each column. Dragging one copy to another person swaps just that person.

Things to try

  • Drag the kickoff from Ben's column to Dev's
  • Move it an hour later

The props behind it are explained in Resources.

Use ProScheduler in your project