# Dispatch queue

Inspect a pickup, send its van, and work through the delivery run in any order.

[View Dispatch queue on CyberSpec](https://www.cyberspec.dev/sink/dispatch-queue)

## Installation

Use a React 19 project with shadcn configured. Render the installed components inside the Cyber root, and import your global stylesheet in the app entry point.

```sh
bunx --bun shadcn@latest add https://www.cyberspec.dev/r/dispatch-queue.json
```

## Usage

```tsx
import { Cyber } from "@/components/ui/cyber"
import Recipe from "@/components/recipes/dispatch-queue"

export default function App() {
  return (
    <Cyber>
      <Recipe />
    </Cyber>
  )
}
```

## Source

```tsx
"use client"

import { useState } from "react"
import { Truck } from "lucide-react"
import { Button } from "@/components/ui/button"
import { ItemList } from "@/components/ui/item-list"
import { Progress } from "@/components/ui/progress"
import "./recipe-layout.css"

const stops = [
  { value: "dock", label: "West Dock", meta: "09:10", cargo: "Field recorders" },
  { value: "depot", label: "Central Depot", meta: "10:30", cargo: "Spare batteries" },
  { value: "tower", label: "North Tower", meta: "11:45", cargo: "Patch cables" },
]

export default function DispatchQueue() {
  const [sent, setSent] = useState<string[]>([])
  const [selected, setSelected] = useState(stops[0].value)
  const pending = stops.filter(stop => !sent.includes(stop.value))
  const current = pending.find(stop => stop.value === selected) ?? pending[0]
  const last = stops.find(stop => stop.value === sent.at(-1))
  return (
    <div className="sink-stack">
      <Progress label="Vans dispatched" value={sent.length} max={stops.length} />
      {current && <ItemList label="Pickup queue" items={pending} compact value={current.value}
        onValueChange={next => next && setSelected(next)} />}
      <div className="sink-between">
        {current && <div><span className="sink-label">Cargo</span><p>{current.cargo}</p></div>}
        <Button size="sm" onClick={() => {
          if (current) setSent([...sent, current.value])
          else { setSent([]); setSelected(stops[0].value) }
        }}><Truck aria-hidden />{current ? "Dispatch van" : "Start a new run"}</Button>
      </div>
      <p role="status" className="sink-note">{last ? `Dispatched to ${last.label}.` : "All vans are at the loading bay."}</p>
    </div>
  )
}
```

## Components in this recipe

- [Item list](https://www.cyberspec.dev/components/sidebar/item-list.md) — An always-visible list of rows in columns, the selected row a solid signal bar.
- [Progress](https://www.cyberspec.dev/components/sidebar/progress.md) — A segmented bar with a percentage readout, and an indeterminate state.
- [Button](https://www.cyberspec.dev/components/sidebar/button.md) — A cut-corner button with a raised tab, five tones, and a press flash. Enable the cipher prop to scramble the label and briefly tear the frame on hover.

## Resources

- [All kitchen sink recipes](https://www.cyberspec.dev/sink.md)
- [Recipe source on GitHub](https://github.com/agnelnieves/cyberspec/blob/main/registry/cyber/recipes/dispatch-queue.tsx)
- [Recipe layout stylesheet](https://github.com/agnelnieves/cyberspec/blob/main/registry/cyber/recipes/recipe-layout.css)
- [Shadcn registry item](https://www.cyberspec.dev/r/dispatch-queue.json)
