ProSchedulerSign in

Agenda · Templating

Day headers

renderAgendaDay draws each day's heading — here with the number of sessions and hours booked.

Live demo

Move a session, and watch the totals

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

export function AgendaDayHeaderDemo() {
  const { events, handlers } = useEvents(() => studioSessions())
  return (
    <ProScheduler
      data={events}
      resources={studioResources}
      view={{ agenda: { type: "week" } }}
      renderAgendaDay={({ date, events: dayEvents, isToday }) => {
        const hours = dayEvents.reduce(
          (sum, e) => sum + (new Date(e.end ?? e.start).getTime() - new Date(e.start).getTime()) / 3_600_000,
          0,
        )
        return (
          <div className="flex items-baseline justify-between border-b border-border bg-muted/40 px-4 py-2">
            <span className={isToday ? "font-semibold text-primary" : "font-semibold"}>
              {date.toLocaleDateString(undefined, { weekday: "long", day: "numeric", month: "long" })}
            </span>
            <span className="text-xs text-muted-foreground">
              {dayEvents.length} sessions · {Math.round(hours)} h booked
            </span>
          </div>
        )
      }}
      height={560}
      {...handlers}
    />
  )
}

About this demo

renderAgendaDay draws each day's heading — here with the number of sessions and hours booked.

Things to try

  • Move a session, and watch the totals

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

Use ProScheduler in your project