ProSchedulerSign in

Scheduler · Use cases

Appointment booking

A clinic's day with a column per doctor (resources: true). Lunch is blocked for everyone and Dr. Weber's afternoon for her alone; with overlaps off, a doctor sees one patient at a time.

Live demo

Drag a patient to another doctor · Book Dr. Weber after 12:00 · Book over lunch

Fullscreen
import { ProScheduler, type PschInvalid } from "@andreisaac/pro-scheduler"
import { clinicDay, doctors, type Appointment } from "./data/bookings"
import { Log, useEvents, useLog, when } from "./kit"

const lunch: PschInvalid[] = [
  { recurring: { repeat: "daily" }, startTime: "12:30", endTime: "13:30", title: "Lunch" },
  // Dr. Weber only sees patients in the morning on this rota.
  { recurring: { repeat: "daily" }, startTime: "12:00", endTime: "24:00", resource: "dr-weber", title: "Surgery" },
]

export function AppointmentBookingDemo() {
  const { events, handlers } = useEvents(clinicDay)
  const { lines, log } = useLog()

  return (
    <div className="docs-demo__stack">
      <ProScheduler
        data={events}
        resources={doctors}
        // One column per doctor for the day.
        view={{ scheduler: { type: "day", resources: true, startTime: "07:30", endTime: "18:00", timeCellStep: 15, dragTimeStep: 15 } }}
        invalid={lunch}
        eventOverlap={false}
        extendDefaultEvent={({ resource }) => ({ title: "New patient", color: doctors.find((d) => d.id === resource)?.color })}
        onEventUpdateFailed={(f) => log(`Can't move ${f.event.title}: ${f.reason === "invalid" ? f.invalid?.title : "that doctor is busy"}`)}
        onEventCreateFailed={(f) => log(`Can't book ${when(f.event.start)}: ${f.reason === "invalid" ? f.invalid?.title : "already booked"}`)}
        renderResource={(doctor) => (
          <div className="grid justify-items-center leading-tight">
            <span className="text-xs font-semibold">{doctor.name}</span>
            <span className="text-[10px] text-muted-foreground">{String(doctor.specialty)}</span>
          </div>
        )}
        renderEventContent={({ original }) => (
          <div className="grid text-[11px] leading-tight">
            <strong className="truncate">{original.title}</strong>
            <span className="truncate opacity-85">{(original as Appointment).reason}</span>
          </div>
        )}
        height={600}
        {...handlers}
      />
      <Log lines={lines} empty="Drag a patient to another doctor, or into lunch…" />
    </div>
  )
}

About this demo

A clinic's day with a column per doctor (resources: true). Lunch is blocked for everyone and Dr. Weber's afternoon for her alone; with overlaps off, a doctor sees one patient at a time.

Things to try

  • Drag a patient to another doctor
  • Book Dr. Weber after 12:00
  • Book over lunch

The props behind it are explained in Resources.

Use ProScheduler in your project