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
Fullscreenimport { 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>
)
}// data/studio.ts — sample data, relative to the current week or month.
import type { SchedulerResource } from "@andreisaac/pro-scheduler"
export type StudioResource = SchedulerResource & {
id: string
name: string
role: string
color: string
}
export const studioResources: StudioResource[] = [
{ id: "ada", name: "Ada Moreno", role: "Director", color: "#2563eb" },
{ id: "ben", name: "Ben Okafor", role: "Producer", color: "#059669" },
{ id: "chloe", name: "Chloé Martin", role: "Editor", color: "#d97706" },
{ id: "dev", name: "Dev Patel", role: "Colourist", color: "#7c3aed" },
{ id: "elin", name: "Elin Berg", role: "Sound", color: "#db2777" },
{ id: "farah", name: "Farah Haddad", role: "Camera", color: "#0891b2" },
{ id: "gus", name: "Gus Almeida", role: "Motion", color: "#65a30d" },
{ id: "hana", name: "Hana Sato", role: "Designer", color: "#dc2626" },
]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.