# Court bookings on a timeline you drag

The front desk of a sports club sees the day as a timeline: a row for each court, a block for each booking and a line for the time now. A booking moves by dragging it to another time or court, or with the arrow keys, and the timeline refuses a place where another booking already is.

Checked 2 December 2026. By Bohuslav Poláček. https://meadowstack.com/screens/court-bookings/

*The Riverside desk's day at 10:24 as the demo shows it, rendered from the kit when the site was built: seven courts, the day's bookings and two closures.*

A live screen, rendered from the kit's components on the page: https://meadowstack.com/screens/court-bookings/

Open it in the live demo: https://meadowstack.com/demo/?lang=en#/riverside/recepce

From the example app [An app for a sports club](https://meadowstack.com/examples/sports-club-court-bookings/).

## What the screen shows

- **The header**: the day and Close a court. The primary action, New booking, sits quiet in the app's top bar, which this frame leaves out.
- **One row under it**: the day's arrows, Today, and the Display button that switches between the timeline and a list.
- **Four figures**: how full the courts are (of the open court time, closed time left out), the bookings without the cancelled ones, how many still pay at the desk, and how many bookings are on court now.
- **The timeline**: a 52px row per court with its surface, 7:00 to 22:00 at 120px an hour, and a block per booking with the member and one word. Confirmed is tinted in the court's colour with a solid edge, unpaid is dashed and pale, a checked-in booking adds a check, a cancelled one is struck through in grey, and closed time (clay maintenance, a lighting repair) is striped grey. The time now is an ink line with its time on it, under the blocks.

## Every booking is a block you can move

The kit's rules ask every planning view (bookings, a rota, machines) to be an editor, not a picture, and this one is:

- Drag a block sideways for another time, up or down for another court, or its right edge to make it longer. Its new times are written on it while it moves; over another booking it turns red with the reason and goes back when let go.
- Drag in an empty stretch to draw a new booking: the booking form opens with that court and time filled in. A click there makes it an hour.
- From the keyboard the blocks are buttons in time order: the arrows move a booking by the 30-minute step, Shift and an arrow by an hour, up and down to another court, and Enter opens it. Every move is announced.
- After a move a toast says where the booking went, with Undo.

A move shows at once and the server answers later, so a held arrow key sends several moves of one booking before the first answer is back. Written into the day as they arrive, an older answer would put the booking back for a moment. The screen takes a turn for each booking (`useTurns`), so only the newest answer lands; the end-to-end test "moves that come faster than the network answers never step the booking back" in `e2e/desk.spec.ts` holds it there.

## Who can move what

The screen asks `can("desk.book")` before it hands the timeline `onMove` and `onCreate`. Without them the timeline draws nothing to drag, so a booking that cannot move simply has no handler. The site manager and the front desk book and move; the court keeper reads the day, closes a court for maintenance and opens it again, but cannot book, move, take a payment or cancel. The rules live in the module's `domain/permissions.ts`, never in a component, and the court keeper's limits have their own end-to-end test.

## On a phone

A 15-hour timeline does not fit 390px usefully. Under 768px the day is a list by court and time with the same words, a booking opens as a sheet from the bottom, and the Display button goes. The four figures stay on top. The screen above does the same at a phone's width.

## What AI coding tools get wrong here

Asked for a booking calendar, a coding assistant usually draws a grid of absolutely positioned divs and adds a drag library: no keyboard, an overlap found only when the server says no, a block that jumps back when two answers cross, and a page that scrolls sideways on a phone.

In Meadowstack the timeline is one kit component, [ResourceTimeline](https://meadowstack.com/components/resource-timeline/), which the kit's manifest names for bookings or machine time across resources within a day, in place of a hand-built timeline grid. The repository's lint stops an app from importing `@dnd-kit` or `motion` itself, and the rule that planning views are editors (drag, quick add, the same from the keyboard) sits in the instructions every coding agent reads. The [planning editor pattern](https://meadowstack.com/patterns/planning-editor/) has the rules; the [workspace pattern](https://meadowstack.com/patterns/workspace/) the screen around them.

## How the demo calls the timeline

*The bookings screen hands the timeline its courts and blocks, and passes onMove and onCreate only to a person who may book.*

From `apps/demo/src/modules/desk/pages/bookings.tsx` in the Meadowstack repository:

```tsx
<ResourceTimeline
  label={`${tx("Rezervace kurtů", "Court bookings")}, ${dayLabel(day)}`}
  resources={view.courts.map((court) => ({
    id: court.id,
    label: court.name,
    hint: court.surface,
    hue: court.hue,
  }))}
  blocks={blocks}
  day={day}
  startHour={7}
  endHour={22}
  selectedId={selectedId}
  onSelect={(id) =>
    view.bookings.some((item) => item.id === id) ? setParam("rezervace", id) : undefined
  }
  onMove={can("desk.book") ? (id, courtId, start, end) => void move(id, courtId, start, end) : undefined}
  onCreate={
    can("desk.book")
      ? (courtId, start, end) =>
          setCreating({
            courtId,
            start,
            minutes: (new Date(end).getTime() - new Date(start).getTime()) / 60_000,
          })
      : undefined
  }
/>
```

## What the kit says about the timeline

*The component's entry in the kit's manifest, read when the site was built.*

| Manifest field | ResourceTimeline |
| --- | --- |
| What it is | Resources (courts, machines, rooms) as rows with blocks over a day's hours, dragged and resized. |
| Use it for | Bookings or machine time across resources within a day. |
| Not for | For a project over weeks (GanttChart); For people by day (ScheduleGrid) |
| It replaces | A hand-built timeline grid |
| Screen types | Workspace |
| Import | `import { ResourceTimeline } from "@meadowstack-studio/kit";` |

Read from the kit's component manifest when the site was built (126 components, packages/kit/src/components.json); the same entry answers an AI coding tool through the kit's MCP server.

## Questions

### Can a booking be moved by dragging?

Yes. Drag it sideways for another time, up or down for another court, or drag its right edge to make it longer. Its new times are written on it while it moves, and a toast with Undo says where it went.

### What stops two bookings on the same court at the same time?

The timeline itself. Over another booking the block turns red with the reason and goes back when let go, and an arrow key refuses the same step. Closed time is a block too, so nothing lands on a court that is shut.

### Can bookings be moved without a mouse?

Yes. Every booking is a button: the arrows move it by half an hour, Shift and an arrow by an hour, up and down to another court, and Enter opens it. Each move is announced to a screen reader.

### What does the booking calendar show on a phone?

A list of the day's bookings by court and time, each with the member and one word for its state. A booking opens as a sheet from the bottom of the screen.

### What happens to the bookings when rain closes the clay courts?

In the demo the assistant proposes moving the clay courts' bookings to the indoor court, at the same time where it is free, with a text to each player. The desk confirms, and the moved bookings show on this timeline with their history.

## Related

- [An app for a sports club](https://meadowstack.com/examples/sports-club-court-bookings/) (Example app)
- [One inbox for every member's message](https://meadowstack.com/screens/shared-inbox/) (Screens)
- [A construction schedule that reads the weather](https://meadowstack.com/screens/construction-schedule/) (Screens)
- [A content calendar for a creator's posts and brand deals](https://meadowstack.com/screens/content-calendar/) (Screens)
- [A dispatch plan that checks driving hours on every drag](https://meadowstack.com/screens/dispatch-plan/) (Screens)
- [A resource capacity plan for an agency](https://meadowstack.com/screens/capacity-planning/) (Screens)
