ProSchedulerSign in

Scheduler · Drag & drop

Move between schedulers

Two schedulers, both with externalDrag and externalDrop. A session dragged out of one follows the pointer and lands in the other; the source removes it once the target accepts.

Live demo

Drag a session from Studio A into Studio B · Drag it back

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

export function InstanceTransferDemo() {
  const all = studioSessions()
  const a = useEvents(() => all.filter((e) => ["ada", "ben"].includes(e.resource)))
  const b = useEvents(() => all.filter((e) => ["chloe", "dev"].includes(e.resource)))
  const { lines, log } = useLog(4)
  // Each takes events from the other; an accepted drop removes it from the source.
  const panel = (
    side: typeof a,
    people: SchedulerResource[],
    name: string,
  ) => (
    <ProScheduler
      data={side.events}
      resources={people}
      view={{ scheduler: { type: "day", resources: true, startTime: "08:00", endTime: "19:00" } }}
      externalDrag
      externalDrop
      height={520}
      {...side.handlers}
      onEventCreated={(event, info) => {
        side.handlers.onEventCreated(event)
        // Drawn events carry a temporary id; transferred ones keep theirs.
        if (!info && !String(event.id ?? "").startsWith("tmp-")) log(`${name} received “${event.title}”`)
      }}
    />
  )
  return (
    <>
      <div className="grid gap-3 md:grid-cols-2">
        {panel(a, studioResources.slice(0, 2), "Studio A")}
        {panel(b, studioResources.slice(2, 4), "Studio B")}
      </div>
      <Log lines={lines} empty="Drag a session from one studio to the other." />
    </>
  )
}

About this demo

Two schedulers, both with externalDrag and externalDrop. A session dragged out of one follows the pointer and lands in the other; the source removes it once the target accepts.

Things to try

  • Drag a session from Studio A into Studio B
  • Drag it back

The props behind it are explained in Selection, drag and drop, links.

Use ProScheduler in your project