Smithable websitedocsGitHub
Menu

Book a person's time

Some apps book places: a yoga class at 09:00 has twelve, and each booking takes one (the booking starter). Others book a person's time: a haircut takes thirty minutes of one barber's day, and that barber can't cut two people's hair at once. This page is about the second kind, on the barbers starter.

smithable new my-shop --starter barbers

1. Whose time is booked: schedule

models:
  Barber:
    fields: { name: string!, bio: text, portrait: picture }
    schedule:
      hours: { mon-fri: "09:00-17:00", sat: "10:00-14:00" }
      breaks: "12:00-12:30"
      gap: 10                  # minutes kept free after each appointment
      away: TimeOff            # days or hours away
  TimeOff:
    fields: { barber: Barber!, from: datetime!, until: datetime!, note: string }

In words: "Barbers have opening hours 9 to 17 on weekdays", then "the barbers are open 10-14 on saturdays" (each keeps the other days, the breaks and the gap).

2. What takes it: occupies

models:
  Appointment:
    fields:
      service: Service!
      barber: Barber!
      startsAt: datetime!
      name: string!
      status: { type: requested | confirmed | cancelled, by: app }
    occupies:
      resource: barber           # whose time
      starts: startsAt
      duration: service.minutes  # the service's length, one reference away
      while: { status: [requested, confirmed] }
      cancelUntil: 12h

In words: "An appointment takes its barber's time". The start and the length are found by shape: the model's one date-and-time field, and its one whole-number field (or one on a record it refers to). When there are more, say them in the file, or ask in your own words.

3. What the app does

From the command line:

smithable op setSchedule Barber "mon-fri 09:00-17:00, sat 10:00-14:00" --breaks 12:00-12:30 --gap 10 --away TimeOff
smithable op setOccupies Appointment barber startsAt service.minutes status="requested | confirmed" --cancel-until 12h

The spec reference has every key: One person's time.