Timeline · Resources
Resource footers and revenue sidebar
renderSidebar adds a right-hand column per row — days booked and revenue — with a total in the footer corner.
Live demo
Stretch an assignment and watch the revenue
Fullscreenimport { useMemo } from "react"
import { ProScheduler, type SchedulerEvent, type SchedulerResource } from "@andreisaac/pro-scheduler"
import { studioAssignments, studioResources } from "./data/studio"
import { useEvents } from "./kit"
const days = (e: SchedulerEvent) =>
(new Date(e.end!).getTime() - new Date(e.start).getTime()) / 86_400_000
const dayRate: Record<string, number> = { Director: 900, Producer: 700, Editor: 600, Colourist: 650, Sound: 550, Camera: 600, Motion: 600, Designer: 550 }
export function FootersSidebarDemo() {
const { events, handlers } = useEvents(studioAssignments)
const booked = useMemo(() => {
const map = new Map<string, number>()
for (const e of events) map.set(String(e.resource), (map.get(String(e.resource)) ?? 0) + days(e))
return map
}, [events])
const revenue = (r: SchedulerResource) => Math.round((booked.get(String(r.id)) ?? 0) * (dayRate[String(r.role)] ?? 500))
const total = studioResources.reduce((sum, r) => sum + revenue(r), 0)
return (
<ProScheduler
data={events}
resources={studioResources}
view={{ timeline: { type: "month" } }}
// A right-hand column with a cell per row, and its heading.
renderSidebarHeader={() => <span>Booked · revenue</span>}
renderSidebar={(r) => (
<div className="grid w-full text-right text-xs leading-tight tabular-nums">
<span className="font-medium">{Math.round(booked.get(String(r.id)) ?? 0)} days</span>
<span className="text-muted-foreground">€{revenue(r).toLocaleString()}</span>
</div>
)}
renderResourceFooter={() => <span className="tabular-nums">Total €{total.toLocaleString()}</span>}
renderDayFooter={({ events: onDay }) => <span className="text-muted-foreground">{onDay.length || ""}</span>}
styleConfig={{ sidebarWidth: 140 }}
height={560}
{...handlers}
/>
)
}// data/studio.ts — sample data, relative to the current week or month.
import type { SchedulerEvent, SchedulerResource } from "@andreisaac/pro-scheduler"
export type StudioResource = SchedulerResource & {
id: string
name: string
role: string
color: string
}
export type StudioEvent = SchedulerEvent & {
id: string
title: string
start: Date
end?: Date
resource: string
client: string
kind: "Shoot" | "Edit" | "Review" | "Pitch" | "Travel" | "Workshop"
}
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" },
]
/** A date `day` days after this week's Monday, at `hour:minute`. */
function at(base: Date, day: number, hour: number, minute = 0): Date {
return new Date(base.getFullYear(), base.getMonth(), base.getDate() + day, hour, minute)
}
type Template = [
title: string,
client: string,
kind: StudioEvent["kind"],
resource: string,
startDay: number,
startHour: number,
endDay: number,
endHour: number,
]
// Multi-day assignments across the month: what the resource timeline shows.
// Day offsets count from the 1st of the month, so a month timeline is full
// from its first column whatever today's date.
const assignmentTemplates: Template[] = [
["Lumen Labs: design system", "Lumen Labs", "Workshop", "hana", 0, 9, 4, 18],
["Aurora Bank: edit", "Aurora Bank", "Edit", "chloe", 1, 9, 9, 18],
["Harbor Coffee: production", "Harbor Coffee", "Shoot", "ada", 2, 9, 6, 18],
["Kinetic Shoes: shoot", "Kinetic Shoes", "Shoot", "farah", 3, 7, 5, 19],
["Northline TV: grade", "Northline TV", "Edit", "dev", 4, 9, 8, 18],
["Lumen Labs: treatment", "Lumen Labs", "Pitch", "ben", 5, 9, 8, 17],
["Kinetic Shoes: sound", "Kinetic Shoes", "Edit", "elin", 7, 9, 10, 18],
["Harbor Coffee: motion", "Harbor Coffee", "Edit", "gus", 8, 9, 15, 18],
["Kinetic Shoes: design", "Kinetic Shoes", "Workshop", "hana", 10, 9, 13, 17],
["Northline TV: shoot", "Northline TV", "Shoot", "farah", 11, 7, 14, 19],
["Festival travel", "Studio", "Travel", "ada", 13, 7, 16, 20],
["Aurora Bank: versions", "Aurora Bank", "Edit", "chloe", 14, 9, 18, 18],
["Harbor Coffee: delivery", "Harbor Coffee", "Review", "ben", 17, 10, 19, 16],
["Northline TV: finishing", "Northline TV", "Edit", "dev", 18, 9, 22, 18],
["Lumen Labs: launch film", "Lumen Labs", "Shoot", "farah", 20, 8, 24, 18],
["Kinetic Shoes: mix", "Kinetic Shoes", "Edit", "elin", 21, 9, 24, 18],
["Aurora Bank: titles", "Aurora Bank", "Edit", "gus", 22, 9, 26, 18],
["Harbor Coffee: stills", "Harbor Coffee", "Workshop", "hana", 23, 9, 26, 17],
]
function build(templates: Template[], prefix: string, base: Date): StudioEvent[] {
return templates.map(([title, client, kind, resource, sd, sh, ed, eh], index) => ({
id: `${prefix}-${index + 1}`,
title,
client,
kind,
resource,
start: at(base, sd, Math.floor(sh), Math.round((sh % 1) * 60)),
end: at(base, ed, Math.floor(eh), Math.round((eh % 1) * 60)),
}))
}
/** The 1st of the month containing `date`. */
export function monthStart(date = new Date()): Date {
return new Date(date.getFullYear(), date.getMonth(), 1)
}
/**
* Multi-day assignments across the month — the resource timeline. Marked
* all-day, so the time grid lists them in its all-day strip rather than as
* columns running through every hour.
*/
export function studioAssignments(base = monthStart()): StudioEvent[] {
return build(assignmentTemplates, "a", base).map((event) => ({ ...event, allDay: true }))
}About this demo
renderSidebar adds a right-hand column per row — days booked and revenue — with a total in the footer corner.
Things to try
- Stretch an assignment and watch the revenue
The props behind it are explained in Resources.