Saltar al contenido

Planning de habitaciones de hotel

Gotea la ducha de la 104. Recoloca al siguiente cliente, bloquea la habitación para el fontanero y localiza las noches que ya están llenas.

  • Alojamiento
  • Casa Noma
  • Columnas de fila
  • Filas de resumen
  • Minimapa
  • Árbol de recursos
  • Deshacer y rehacer
  • Menú contextual
  • Arrastrar y redimensionar
  • Temas
  • Demo con datos sintéticos

Misión

0 de 3 pasos hechos

Lunes 26 de octubre, mediodía: el cliente que deja la 104 avisa de que gotea la ducha. El fontanero necesita tres noches.

  1. Saca la reserva Varga (llega el martes) de la habitación 104. — Pendiente

    Arrástrala una fila arriba, a la 103, o a la 201 como upgrade. Las habitaciones ocupadas la rechazan.

  2. Alarga el bloqueo por avería de la 104 a tres noches. — Pendiente

    Arrastra su borde derecho hasta el jueves. Las reparaciones terminan a las 14:00, listas para la siguiente entrada.

  3. Encuentra las noches que agota la feria de diseño. — Pendiente

    Quedan más allá de estas dos semanas: pulsa Completo encima del planning, las barras rojas de la franja de ocupación o la flecha de la semana siguiente.

Unos 30 segundos. Los pasos se marcan a medida que los completas.

Teclado: enfoca la rejilla y usa las flechas, Intro y Alt+flechas para mover.

Casa Noma
Doble estándar101Calle102Calle103Patio104PatioDoble superior201Balcón202Balcón203PatioJunior suite301Terraza302TerrazaSuite jardín401JardínHaddad4 nochesNovak2 nochesFerreira3 nochesSato5 nochesO’Neill5 nochesJensen2 nochesDubois3 nochesTanaka3 nochesSilva2 nochesKaya2 nochesOkafor2 nochesBianchi4 nochesPetrov4 nochesVarga3 nochesLaine3 nochesMoreno3 nochesFuera de servicio1 nocheKeller3 nochesNakamura3 nochesFischer2 nochesOrtega4 nochesCosta4 nochesKim2 nochesHaas3 nochesIvanova3 nochesDuarte2 nochesQuinn2 nochesAlbers2 nochesSousa4 nochesVidal3 nochesHart4 nochesEriksen3 nochesNavarro3 nochesSaleh3 nochesRinaldi3 nochesPark2 nochesMercer3 nochesAndersen4 nochesGarcía4 nochesBecker4 noches↘ 1 ↗ 3↘ 2 ↗ 3↘ 2 ↗ 2↘ 1 ↗ 2↘ 3 ↗ 2↘ 3 ↗ 2↘ 1 ↗ 2↘ 1 ↗ 4↘ 1 ↗ 1↘ 1 ↗ 1↘ 2 ↗ 1↘ 1 ↗ 1↘ 1 ↗ 3↘ 0 ↗ 1↘ 4 ↗ 1↘ 6 ↗ 0Llegadas · salidaspor fecha26 oct2 nov9 novlun 26mar 27mié 28jue 29vie 30sáb 31dom 1lun 2mar 3mié 4jue 5vie 6sáb 7dom 8lun 9mar 10mié 11jue 12

Vista previa del primer fotogramaEn vivo: el motor Pro real, funcionando en tu navegadorUnos 30 segundos. Los pasos se marcan a medida que los completas. Teclado: enfoca la rejilla y usa las flechas, Intro y Alt+flechas para mover.

La situación.

Casa Noma es un hotel boutique ficticio de diez habitaciones: cuatro dobles estándar, tres superiores, dos junior suites y una suite jardín. Recepción planifica en un planning con una fila por habitación y una columna por noche. Los clientes entran a las 14:00 y salen a las 11:00, así que el día de rotación una estancia termina y la siguiente empieza en la misma columna sin solaparse.

Las habitaciones se estropean. Cuando una sale de venta, recepción tiene que recolocar a los clientes asignados sin bajarles de categoría, encajar la reparación entre una salida y una entrada y vigilar las noches que ya están completas. Unas barras no distinguen una noche tranquila de una agotada; este planning cuenta las habitaciones libres por tipo y noche.

Qué vas a hacer

Moverás una reserva fuera de una habitación averiada (un upgrade vale, una bajada de categoría se rechaza), alargarás la reparación a tres noches con horas reales de hotel y encontrarás las noches agotadas desde la franja de ocupación.

Dónde termina la librería y empieza tu aplicación.

SuperScheduler aporta

  • Árbol de recursos de tipos y habitaciones con rowHeaderColumns (habitación, vista, pisos); el chip de pisos es un área de la cabecera de fila (action: 'None') que se queda con su clic.
  • Una fila fija arriba (frozen: 'top', cellsDisabled) que onBeforeCellRender llena con las llegadas y salidas de cada fecha; las filas de tipo muestran las habitaciones libres por noche.
  • Estancias a la hora exacta en una escala de noches (useEventBoxes: 'Never') que se mueven por noches completas con eventMoveByCell, con áreas en sus dos extremos: la inicial del huésped en la llegada y una puerta en la salida.
  • Cabeceras de noche escritas con onBeforeTimeHeaderRender (esta noche lleva su propia etiqueta), un separador en el momento de recepción y celdas deshabilitadas para la suite jardín cerrada.
  • Prevención de solapes, redimensionado guiado en onEventResizing, movimientos con teclado y un historial que también registra los pisos (history.push).
  • El minimapa con tu propia serie, niveles de zoom, scrollTo y el tema viewport de super-scheduler/hooks (useSchedulerState, subscribeScheduler) detrás del navegador de fechas.
  • Tarjetas al pasar el ratón y tarjeta de arrastre (super-scheduler/react-render), resaltado de conflictos y un menú contextual con la piel del producto (theme del Menu).

El código de este ejemplo decide

  • Upgrades sí, bajadas de categoría no, capacidad de la habitación y nada de entradas en el pasado: los rechazos en onEventMoving y onEventResizing.
  • Horas de hotel al redimensionar: las estancias acaban a las 11:00, las reparaciones a las 14:00, nunca menos de una noche.
  • El estado de recepción de cada estancia (salida, alojado, llega hoy, confirmada, opción), las cifras de hoy y las llegadas y salidas por fecha.
  • Los pisos (sucia, limpia, revisada) y si un huésped que llega hoy puede ocupar ya la habitación.
  • Ocupación por noche, habitaciones libres por tipo y noche, las noches completas y las acciones: habitación equivalente, upgrade, una noche más, confirmar una opción.

El código de esta demo.

Son los archivos que ejecuta esta página, no una copia simplificada. Compilan contra los exports públicos de SuperScheduler Pro.

tsx.zip

La integración: escala de noches con horas exactas, rowHeaderColumns con el área de pisos, la hoja del día fija, las celdas de disponibilidad, los días cerrados, las cabeceras de noche, la tarjeta al pasar el ratón, el veredicto de arrastre en noches, el menú contextual y los callbacks donde las reglas de recepción rechazan o ajustan un cambio.

/**
 * Casa Noma tape chart: rooms grouped by room type over four weeks, one column per night.
 *
 * Library: resource tree with row-header columns (a housekeeping chip that owns its click as a
 * row-header area), a frozen day-sheet row, exact-time stays (check-in 14:00, check-out 11:00) on
 * a day scale with areas at their ends, night headers written by onBeforeTimeHeaderRender, a
 * separator at the front desk's moment, drag/resize with conflict highlighting, disabled cells,
 * zoom levels, keyboard and history, the event hover card and the drag card
 * (super-scheduler/react-render), and a context menu. Application: upgrades and downgrades,
 * capacity, hotel times for resized edges, the out-of-order room, housekeeping, the free rooms per
 * type and night, and what the cards say in nights. Those rules live in ./rules and run below;
 * ./chart-paint writes the markup.
 */
import { useCallback, useMemo, useState, type RefObject } from 'react'
import { SuperScheduler } from 'super-scheduler'
import type {
  SchedulerBeforeTimeHeaderRenderArgs,
  SchedulerEventsChangeArgs,
} from 'super-scheduler'
import type { SchedulerHistory } from 'super-scheduler/history'
import { SuperSchedulerComponent, type SchedulerRenderProps } from 'super-scheduler/react-render'
import { format, plural } from '../../i18n/format'
import { DAY, civil, parseCivil } from '../../scheduler/civil'
import { createHeaderHook } from '../../scheduler/live-headers'
import { toneClass } from '../../scheduler/tones'
import { createEventMenu, type MenuEntry } from '../kit/context-menu'
import { formatDay } from '../kit/format'
import { useEventHover, type HoverCardModel } from '../kit/hover-card'
import { KEYS } from '../kit/keys'
import { useDropRefusal } from '../kit/use-drop-refusal'
import { skinClass, skinMenuTheme } from '../registry'
import type { DemoCommon } from '../types'
import {
  CHART_GEOMETRY,
  STATUS_TONES,
  SUMMARY_ID,
  isItemEvent,
  isRoomTypeId,
  readItemFields,
  toItem,
  toResources,
  type ItemEvent,
} from './adapter'
import {
  freeHtml,
  housekeepingArea,
  isTonight,
  movementsHtml,
  nightHeader,
  repairHtml,
  roomHtml,
  sheetColumns,
  stateWord,
  stayEnds,
  stayHtml,
  typeHtml,
  viewHtml,
} from './chart-paint'
import {
  BUSINESS_NOW,
  CHART,
  CLOSURES,
  REPAIR_NIGHTS,
  ROOMS,
  type Housekeeping,
  type RoomItem,
} from './model'
import {
  equivalentRoom,
  extendByNight,
  freeByType,
  isClosed,
  isUpgrade,
  moveRefusal,
  movementsByDate,
  nextHousekeeping,
  nightsOf,
  resizeTo,
  roomById,
  statusOf,
  upgradeRoom,
  type Extension,
  type MoveRefusal,
} from './rules'
import { createNightCard, itemCard } from './stay-card'
import type { CasaNomaText, ZoomId } from './text'

/** What the chart asks the demo to do (context menu, keyboard). */
export type ItemAction =
  'details' | 'equivalent' | 'upgrade' | 'extend' | 'confirm' | 'housekeeping'

/** The menu's label for one more night: the new departure, or why it cannot be. */
export function extendLabel(extension: Extension, text: CasaNomaText, tag: string): string {
  if (extension.ok) return format(text.actions.extend, { date: formatDay(extension.end, tag) })
  if (extension.reason === 'taken')
    return format(text.actions.extendTaken, {
      name: extension.by.kind === 'stay' ? extension.by.guest : text.outOfOrder,
    })
  return text.actions.extendClosed
}

export interface CasaNomaSchedulerProps {
  readonly events: ItemEvent[]
  /** The same events as business objects, for the availability cells. */
  readonly items: readonly RoomItem[]
  /** Dates of the sold-out nights (the night pips mark them). */
  readonly soldOut: ReadonlySet<string>
  readonly text: CasaNomaText
  readonly common: DemoCommon
  /** BCP 47 tag for labels, and the scheduler locale id. */
  readonly tag: string
  readonly schedulerLocale: string
  /** Level on mount. Later changes go through control.zoom so the view animates from where it is. */
  readonly initialZoom: ZoomId
  /** The item shown in the side sheet: it gets the selection ring. */
  readonly selected: string | null
  readonly history: SchedulerHistory
  readonly controlRef: RefObject<SuperScheduler.Scheduler | null>
  readonly onEventsChange: (args: SchedulerEventsChangeArgs) => void
  readonly onSelect: (id: string) => void
  readonly onMoved: (id: string) => void
  readonly onResized: (id: string, edge: 'start' | 'end') => void
  readonly onRefused: (id: string, message: string) => void
  readonly onAction: (action: ItemAction, id: string) => void
  readonly onZoomLevel: (level: ZoomId) => void
  /** Housekeeping state of every room, and the click on a room's chip. */
  readonly housekeeping: Readonly<Record<string, Housekeeping>>
  readonly onHousekeeping: (room: string) => void
  /** Narrow stages drop the view column. */
  readonly narrow: boolean
}

/** Weeks over nights. The night format tells the level-of-detail planner how narrow its label is. */
const TIME_HEADERS: SuperScheduler.TimeHeaderData[] = [
  { groupBy: 'Week', height: CHART_GEOMETRY.header.week },
  { groupBy: 'Day', height: CHART_GEOMETRY.header.night, format: 'd' },
]

/** One night per column: two weeks to work in, the whole month to look ahead. */
const ZOOM_LEVELS: SuperScheduler.ZoomLevel[] = [
  {
    id: 'fortnight',
    properties: { scale: 'Day', cellWidth: CHART_GEOMETRY.cellWidth, timeHeaders: TIME_HEADERS },
  },
  { id: 'month', properties: { scale: 'Day', cellWidth: 40, timeHeaders: TIME_HEADERS } },
]

const ZOOM_IDS: readonly ZoomId[] = ['fortnight', 'month']
const CHART_START = parseCivil(CHART.start)
const NOW = parseCivil(BUSINESS_NOW)
const ROOM_COUNT = new Map<SuperScheduler.ResourceId, number>(
  ROOMS.map((room) => [room.type, ROOMS.filter((other) => other.type === room.type).length]),
)

function readItem(data: SuperScheduler.EventData): RoomItem | null {
  return isItemEvent(data) ? toItem(data) : null
}

export function CasaNomaScheduler(props: CasaNomaSchedulerProps) {
  const { events, items, soldOut, text, common, tag, schedulerLocale, initialZoom } = props
  const { selected, history, controlRef, housekeeping, narrow } = props
  const { onEventsChange, onSelect, onMoved, onResized, onRefused, onAction, onZoomLevel } = props
  const { onHousekeeping } = props

  const resources = useMemo(() => toResources(text), [text])

  // Day labels shorten below a cell width. A zoom animation lands after the headers of its last
  // frames were drawn, so each settled level gets a fresh hook: a new hook makes the control label
  // its headers again. Today's column is marked on top of the shared labels.
  const [level, setLevel] = useState<ZoomId>(initialZoom)
  const timeHeaders = useMemo(() => {
    const labels = createHeaderHook(tag)
    return {
      level,
      hook: (args: SchedulerBeforeTimeHeaderRenderArgs) => {
        const header = args.header
        if (header.level !== 1) {
          labels(args)
          header.cssClass = 'cn-th-week'
          return
        }
        const start = header.start.getTime()
        const full = soldOut.has(civil(start).slice(0, 10))
        header.html = nightHeader(start, tag, text, level === 'month', full)
        header.cssClass = isTonight(start) ? 'cn-th-night cn-today' : 'cn-th-night'
        if (full) header.toolTip = text.card.full
      },
    }
  }, [level, tag, text, soldOut]).hook
  const free = useMemo(() => freeByType(items, CLOSURES, CHART.start, CHART.days), [items])
  const movements = useMemo(() => movementsByDate(items, CHART.start, CHART.days), [items])

  // A change refused while dragging (category, capacity, the past, overlap) is said on release.
  const refusal = useDropRefusal(onRefused)

  // Hover card: the nights as front-desk pips, guests, booking, total and the rule that applies.
  const card = useCallback(
    (event: SuperScheduler.Event): HoverCardModel | null => {
      const item = items.find((candidate) => candidate.id === String(event.id()))
      return item === undefined
        ? null
        : itemCard(item, items, soldOut, text, common, tag, housekeeping)
    },
    [items, soldOut, text, common, tag, housekeeping],
  )
  const { eventHover, closeHover, suppressHover } = useEventHover(card)

  // Drag verdict counted in nights: the room, arrival → departure, the nights as pips.
  const dragCard = useMemo(
    () => createNightCard({ items, soldOut, text, common, tag }),
    [items, soldOut, text, common, tag],
  )

  // Context menu: rebuilt when the chart changes, so its labels name the real room and night.
  const contextMenu = useMemo(
    () =>
      createEventMenu({
        theme: skinMenuTheme('hotel-rooms'),
        title: (event) => format(common.kit.menuTitle, { name: event.text() }),
        onOpenChange: (open) => suppressHover(open),
        entries: (event) => {
          const id = String(event.id())
          const item = items.find((candidate) => candidate.id === id)
          if (item === undefined) return []
          const entries: MenuEntry[] = [
            {
              label: common.kit.openDetails,
              icon: 'details',
              keys: KEYS.details,
              run: () => onAction('details', id),
            },
          ]
          const extension = extendByNight(item, items, CLOSURES, BUSINESS_NOW)
          if (item.kind === 'repair') {
            entries.push({
              label: extendLabel(extension, text, tag),
              icon: 'after',
              primary: nightsOf(item.start, item.end) < REPAIR_NIGHTS,
              disabled: !extension.ok,
              run: () => onAction('extend', id),
            })
            return entries
          }
          const status = statusOf(item, BUSINESS_NOW)
          if (status === 'departed') return entries
          // An option is what the front desk acts on first: confirm it.
          if (status === 'option')
            entries.push({
              label: text.actions.confirm,
              icon: 'confirm',
              primary: true,
              run: () => onAction('confirm', id),
            })
          const same = equivalentRoom(item, items, CLOSURES, BUSINESS_NOW)
          const better = upgradeRoom(item, items, CLOSURES, BUSINESS_NOW)
          const betterType = better === null ? undefined : roomById(better)?.type
          entries.push(
            {
              label:
                same === null
                  ? format(text.actions.noEquivalent, { type: text.roomTypes[item.booked] })
                  : format(text.actions.equivalent, { room: same }),
              icon: 'handover',
              disabled: same === null,
              run: () => onAction('equivalent', id),
            },
            {
              label:
                better === null || betterType === undefined
                  ? text.actions.noUpgrade
                  : format(text.actions.upgrade, {
                      room: better,
                      type: text.roomTypes[betterType],
                    }),
              icon: 'layers',
              disabled: better === null,
              run: () => onAction('upgrade', id),
            },
            'separator',
            {
              label: extendLabel(extension, text, tag),
              icon: 'after',
              disabled: !extension.ok,
              run: () => onAction('extend', id),
            },
            {
              label: housekeepingLabel(item.room, housekeeping, text, tag),
              icon: 'confirm',
              run: () => onAction('housekeeping', id),
            },
          )
          return entries
        },
      }),
    [items, common, text, tag, housekeeping, onAction, suppressHover],
  )

  const config = useMemo<SchedulerRenderProps>(() => {
    const refusalText = (reason: MoveRefusal | null) =>
      reason === null ? null : text.rules[reason]
    const overlapText = (conflicts: readonly SuperScheduler.Event[]) => {
      const first = conflicts[0]
      return first === undefined ? null : format(common.kit.overlaps, { name: first.text() })
    }

    return {
      locale: schedulerLocale,
      startDate: CHART.start,
      days: CHART.days,
      // Hotel weeks run Monday to Sunday in every locale (as the static preview draws them).
      weekStarts: 1,
      zoomLevels: ZOOM_LEVELS,
      zoom: initialZoom,
      zoomPosition: 'left',
      // Exact hotel times on a night scale: a stay is drawn from 14:00 to 11:00 and keeps those
      // times when it is dragged by whole nights. Resized edges are snapped by the hotel rules.
      useEventBoxes: 'Never',
      eventMoveByCell: true,
      snapToGridEventResizing: false,
      height: '100%',
      treeEnabled: true,
      treePreventParentUsage: true,
      rowHeaderColumns: narrow
        ? [
            { text: text.columns.room, width: CHART_GEOMETRY.narrowColumns.room },
            { text: text.columns.housekeeping, width: CHART_GEOMETRY.narrowColumns.housekeeping },
          ]
        : [
            { text: text.columns.room, width: CHART_GEOMETRY.roomColumn },
            { text: text.columns.view, width: CHART_GEOMETRY.viewColumn },
            { text: text.columns.housekeeping, width: CHART_GEOMETRY.housekeepingColumn },
          ],
      rowHeaderWidth: narrow
        ? CHART_GEOMETRY.narrowColumns.room + CHART_GEOMETRY.narrowColumns.housekeeping
        : CHART_GEOMETRY.rowHeaderWidth,
      rowHeaderWidthAutoFit: false,
      treeIndent: 12,
      eventHeight: CHART_GEOMETRY.eventHeight,
      rowMarginTop: CHART_GEOMETRY.rowMarginTop,
      rowMarginBottom: CHART_GEOMETRY.rowMarginBottom,
      allowEventOverlap: false,
      conflictHighlight: true,
      // The Casa Noma skin (tokens.css, theme.css) keys on the product's skin class.
      cssClass: skinClass('hotel-rooms'),
      durationBarVisible: false,
      crosshairType: 'Header',
      // The front desk's moment (Monday noon): a fixed instant of the scenario, not the visitor's clock.
      separators: [{ location: BUSINESS_NOW, layer: 'BelowEvents', width: 2, cssClass: 'cn-now' }],
      showToolTip: false,
      keyboardEnabled: true,
      keyboardTarget: 'component',
      keyboardMode: 'Full',
      history,
      controlRef,
      onEventsChange,

      // The day sheet, room types (merged across the columns) and rooms: number, view, housekeeping.
      onBeforeRowHeaderRender: (args) => {
        const row = args.row
        const id = row.id
        if (id === SUMMARY_ID) {
          row.cssClass = 'cn-row cn-row--sheet'
          const keys = sheetColumns(text, narrow)
          row.columns.forEach((column, index) => {
            column.html = keys[index] ?? ''
          })
          return
        }
        const room = roomById(String(id))
        if (room === null) {
          row.cssClass = 'ss-rh--group cn-row cn-row--type'
          row.html = typeHtml(String(row.name), ROOM_COUNT.get(id) ?? 0)
          const first = row.columns[0]
          if (first !== undefined) first.html = row.html
          return
        }
        row.cssClass = 'cn-row cn-row--room'
        const state = housekeeping[room.id] ?? 'dirty'
        const [first, second, third] = row.columns
        if (first !== undefined) first.html = roomHtml(room, text)
        const chip = narrow ? second : third
        if (!narrow && second !== undefined) second.html = viewHtml(room, text)
        if (chip !== undefined) {
          chip.html = ''
          chip.areas = [
            housekeepingArea(room.id, state, nextHousekeeping(state), text, tag, onHousekeeping),
          ]
        }
      },

      // The day sheet counts arrivals and departures; group rows show the rooms still free each
      // night; closed days disable a room's cells; tonight's column is warm.
      onBeforeCellRender: (args) => {
        const { cell } = args
        const day = cell.start.getTime()
        const index = Math.round((day - CHART_START) / DAY)
        const tonight = isTonight(day) ? ' cn-today' : ''
        if (cell.resource === SUMMARY_ID) {
          const counts = movements[index]
          // Narrow nights (Month) stack the two marks.
          const stacked = (args.control.cellWidth ?? CHART_GEOMETRY.cellWidth) < 64
          cell.properties.html = counts === undefined ? '' : movementsHtml(counts, text, stacked)
          cell.properties.cssClass = `cn-sheet-cell${tonight}`
          return
        }
        if (isRoomTypeId(cell.resource)) {
          const count = free[cell.resource][index]
          if (count === undefined) return
          cell.properties.html = freeHtml(count)
          cell.properties.cssClass = `cn-avail${count === 0 ? ' cn-full' : ''}${tonight}`
          return
        }
        if (isClosed(String(cell.resource), day, CLOSURES)) cell.properties.disabled = true
        else if (tonight !== '') cell.properties.cssClass = 'cn-today'
      },

      onBeforeEventRender: (args) => {
        const fields = readItemFields(args.data)
        if (fields === null) return
        const start = args.data.start.value
        const end = args.data.end.value
        const isSelected = String(args.data.id) === selected
        if (fields.kind === 'repair') {
          args.data.html = repairHtml({ start, end }, text, tag)
          args.data.cssClass = `cn-item cn-repair ${toneClass('blocked')}${isSelected ? ' cn-selected' : ''}`
          return
        }
        const status = statusOf(
          { start, end, ...(fields.option === true ? { option: true } : {}) },
          BUSINESS_NOW,
        )
        const room = args.data.resource === undefined ? '' : String(args.data.resource)
        const stay = {
          guest: fields.guest,
          guests: fields.guests,
          start,
          end,
          status,
          upgrade: isUpgrade({ room, booked: fields.booked }),
          housekeeping: status === 'due-in' ? (housekeeping[room] ?? null) : null,
        }
        args.data.html = stayHtml(stay, text, tag)
        args.data.areas = stayEnds(stay, text, tag)
        const classes = ['cn-item', 'cn-stay', `cn-${status}`, toneClass(STATUS_TONES[status])]
        if (stay.upgrade) classes.push('cn-upgraded')
        if (isSelected) classes.push('cn-selected')
        args.data.cssClass = classes.join(' ')
        args.data.ariaLabel = `${fields.guest}, ${text.statuses[status]}, ${plural(text.nights, nightsOf(start, end), tag)}`
      },

      // Categories, capacity and the past are front-desk rules; overlap and closed days are the library's.
      onEventMoving: (args) => {
        const id = String(args.e.id())
        const item = readItem(args.e.data)
        if (item === null) return
        const message = refusalText(
          moveRefusal(item, String(args.resource), BUSINESS_NOW, args.start.getTime()),
        )
        if (message !== null) {
          args.allowed = false
          args.message = message
          refusal.track(id, message)
          return
        }
        refusal.track(id, overlapText(args.conflicts))
      },

      // Final check before the commit (also covers keyboard moves).
      onEventMove: (args) => {
        const item = readItem(args.e.data)
        if (item === null) return
        const message = refusalText(
          moveRefusal(item, String(args.newResource), BUSINESS_NOW, args.newStart.getTime()),
        )
        if (message !== null) {
          args.preventDefault()
          refusal.clear()
          onRefused(String(args.e.id()), message)
        }
      },

      // Edges snap to hotel times: stays end at 11:00 and start at 14:00, repairs the other way round.
      onEventResizing: (args) => {
        const item = readItem(args.e.data)
        if (item === null) return
        const edge = args.what
        const next = resizeTo(item, edge, (edge === 'end' ? args.end : args.start).getTime())
        args.start = new SuperScheduler.Date(next.start)
        args.end = new SuperScheduler.Date(next.end)
        const message = edge === 'start' ? startRefusal(item, next.start, text) : null
        if (message !== null) {
          args.allowed = false
          args.message = message
          refusal.track(String(args.e.id()), message)
          return
        }
        refusal.track(String(args.e.id()), overlapText(args.conflicts))
      },

      onEventResize: (args) => {
        const item = readItem(args.e.data)
        if (item === null) return
        const next = resizeTo(
          item,
          args.what,
          (args.what === 'end' ? args.newEnd : args.newStart).getTime(),
        )
        const message = args.what === 'start' ? startRefusal(item, next.start, text) : null
        if (message !== null) {
          args.preventDefault()
          refusal.clear()
          onRefused(String(args.e.id()), message)
          return
        }
        args.newStart = new SuperScheduler.Date(next.start)
        args.newEnd = new SuperScheduler.Date(next.end)
      },

      onEventMoved: (args) => {
        refusal.clear()
        onMoved(String(args.e.id()))
      },
      onEventResized: (args) => {
        refusal.clear()
        onResized(String(args.e.id()), args.what)
      },
      // A click (or Enter) docks the stay into the side sheet; the hover card steps aside.
      onEventClick: (args) => {
        closeHover()
        onSelect(String(args.e.id()))
      },

      onZoom: (args) => {
        if (args.phase !== 'end') return
        const next = ZOOM_IDS[args.level]
        if (next === undefined) return
        setLevel(next)
        onZoomLevel(next)
      },
    }
  }, [
    history,
    controlRef,
    free,
    movements,
    housekeeping,
    narrow,
    selected,
    common,
    refusal,
    closeHover,
    onEventsChange,
    onMoved,
    onRefused,
    onResized,
    onSelect,
    onZoomLevel,
    onHousekeeping,
    schedulerLocale,
    tag,
    text,
    initialZoom,
  ])

  return (
    <SuperSchedulerComponent
      {...config}
      onBeforeTimeHeaderRender={timeHeaders}
      resources={resources}
      events={events}
      eventHover={eventHover}
      dragCard={dragCard}
      contextMenu={contextMenu}
    />
  )
}

/** The menu's housekeeping action for a stay's room: its next state. */
export function housekeepingLabel(
  room: string,
  states: Readonly<Record<string, Housekeeping>>,
  text: CasaNomaText,
  tag: string,
): string {
  const next = nextHousekeeping(states[room] ?? 'dirty')
  return format(text.housekeeping.mark, {
    room,
    next: stateWord(text.housekeeping.states[next], tag),
  })
}

/** A guest in the house keeps the check-in; a guest still to come cannot check in in the past. */
function startRefusal(item: RoomItem, start: number, text: CasaNomaText): string | null {
  if (item.kind !== 'stay') return null
  const status = statusOf(item, BUSINESS_NOW)
  if (status === 'in-house') return text.rules.checkedIn
  return start < NOW ? text.rules.past : null
}

El archivo contiene los ficheros de este ejemplo y un README. No incluye SuperScheduler Pro ni ninguna clave de descarga.