ProSchedulerSign in

Agenda · Templating

Empty state

renderAgendaEmpty replaces the plain “No events” when the page is empty.

Live demo

Pick someone with a free day

Fullscreen
import { useMemo, useState } from "react"
import { ProScheduler } from "@andreisaac/pro-scheduler"
import { studioResources, studioSessions } from "./data/studio"
import { Choice, Toolbar, useEvents } from "./kit"

export function AgendaEmptyStateDemo() {
  const { events, handlers } = useEvents(() => studioSessions())
  // Start on someone with nothing booked today, so the empty state shows.
  const [person, setPerson] = useState(() => {
    const today = new Date().toDateString()
    const busy = new Set(events.filter((e) => new Date(e.start).toDateString() === today).map((e) => e.resource))
    return studioResources.find((r) => !busy.has(r.id))?.id ?? studioResources[0].id
  })
  const shown = useMemo(() => events.filter((e) => e.resource === person), [events, person])
  return (
    <>
      <Toolbar label="Person">
        {studioResources.slice(0, 8).map((r) => (
          <Choice key={r.id} active={person === r.id} onClick={() => setPerson(r.id)}>
            {r.name.split(" ")[0]}
          </Choice>
        ))}
      </Toolbar>
      <ProScheduler
        data={shown}
        resources={studioResources}
        view={{ agenda: { type: "day" } }}
        renderAgendaEmpty={() => (
          <div className="flex flex-col items-center gap-2 py-10 text-center">
            <span className="text-3xl" aria-hidden>
              ☀️
            </span>
            <span className="font-medium text-foreground">Nothing booked today</span>
            <span className="text-sm text-muted-foreground">Use the arrows to look at another day.</span>
          </div>
        )}
        height={420}
        {...handlers}
      />
    </>
  )
}

About this demo

renderAgendaEmpty replaces the plain “No events” when the page is empty.

Things to try

  • Pick someone with a free day

The props behind it are explained in Recurrence, time zones and order.

Use ProScheduler in your project