ProSchedulerSign in

Scheduler · Data

Event data structure

One event of each kind: timed, all-day, multi-day, point-in-time, locked, coloured, and one carrying custom fields. Click any to see its object.

Live demo

Click the custom-fields event · Drag it and click again

Fullscreen
import { useState } from "react"
import { ProScheduler, type SchedulerEvent } from "@andreisaac/pro-scheduler"
import { studioResources, weekStart } from "./data/studio"
import { useEvents } from "./kit"

export function EventDataDemo() {
  const monday = weekStart()
  const at = (day: number, hour: number, minute = 0) =>
    new Date(monday.getFullYear(), monday.getMonth(), monday.getDate() + day, hour, minute)

  const { events, handlers } = useEvents<SchedulerEvent>([
    { id: 1, title: "Timed event", start: at(0, 9), end: at(0, 11) },
    { id: 2, title: "With a resource (its colour)", start: at(1, 10), end: at(1, 12), resource: "ben" },
    { id: 3, title: "Own colour", start: at(2, 13), end: at(2, 15), color: "#e11d48" },
    { id: 4, title: "Locked (editable: false)", start: at(3, 9), end: at(3, 10, 30), editable: false },
    { id: 5, title: "Point in time (no end)", start: at(3, 14) },
    { id: 6, title: "All day", start: at(4, 0), end: at(5, 0), allDay: true },
    { id: 7, title: "Two days (becomes all-day)", start: at(1, 9), end: at(3, 9) },
    { id: 8, title: "Custom fields travel along", start: at(4, 10), end: at(4, 11), room: "B2", budget: 1200 },
  ])
  const [selected, setSelected] = useState<SchedulerEvent | null>(null)

  return (
    <div className="demo-split demo-split--wide">
      <ProScheduler
        data={events}
        resources={studioResources}
        view={{ scheduler: { type: "week", startTime: "08:00", endTime: "17:00" } }}
        showDefaultEditor={false}
        onEventClick={setSelected}
        height={560}
        {...handlers}
      />
      <aside className="demo-side">
        <p className="demo-muted">Click an event to see the object it came from.</p>
        {selected && <pre className="demo-json">{JSON.stringify(selected, null, 2)}</pre>}
      </aside>
    </div>
  )
}

About this demo

One event of each kind: timed, all-day, multi-day, point-in-time, locked, coloured, and one carrying custom fields. Click any to see its object.

Things to try

  • Click the custom-fields event
  • Drag it and click again

The props behind it are explained in API reference.

Use ProScheduler in your project