On-call Schedule

A rotation across a window of days. Shifts are positioned proportionally rather than snapped to a day grid — rotations hand over at 09:00, and rounding shows the wrong person on call for most of two days.

src/components/ui/on-call-schedule.tsx

About

From the component's own source, where it was written.

An on-call rotation across a window of days.

Shifts are positioned proportionally in the window rather than snapped to a day grid. Rotations hand over at 09:00 on a Tuesday, not at midnight, and a calendar that rounds to whole days shows the wrong person as on call for most of two of them.

Who is on call *now* is stated in words above the timeline. That is the only question this component is ever opened to answer, and making someone read it off a bar chart during an incident is a poor trade.

Install

npx astralyx-ui add on-call-schedule

Usage

import { OnCallSchedule } from '@/components/ui/on-call-schedule'

<OnCallSchedule shifts={shifts} start={weekStart} end={weekEnd} />

Composer

Change the props and the source below follows.

On call nowAda LovelaceAda LovelacePrimaryuntil Alan TuringAlan TuringSecondaryuntil
Tue 1Wed 2Thu 3Fri 4Sat 5Sun 6Mon 7
Primary
Ada LovelaceGrace Hopper
Secondary
Alan TuringKatherine Johnson
Props
tsx
<OnCallSchedule shifts={shifts} start={weekStart} end={weekEnd} />

Examples

Rotation

API

Generated from the source, so it cannot fall behind the code. One table per exported component, then hooks, functions and types.

OnCallSchedule

Extends Omit<ComponentProps<'div'>, 'children'>.

PropTypeDefaultDescription
titlestring'On call now'—
shiftsShift[]required{ id, person, start, end, layer?, color? }. Layers become rows.
startDaterequiredThe window. Shifts are clipped to it rather than overflowing.
endDaterequiredThe window. Shifts are clipped to it rather than overflowing.
nowDate—The only question this is ever opened to answer — reading it off a bar chart during an incident is a poor trade.
localestring'en-GB'—
nobodyLabelReactNode'Nobody'Shown when no shift covers the current moment.
untilLabelReactNode'until'Precedes the shift's end time.

Types

Shift

An on-call rotation across a window of days.

FieldTypeDescription
idstring—
personstring—
startDate—
endDate—
layer?stringe.g. "Primary", "Secondary"
color?string—