5.8. Ramp status and quantity in details
When you move a loading in the details dialog, it helps to see which ramps are already busy. The ramp can count its loadings:
src/store/Ramp.ts
export class Ramp {
// ...
get quantity(): number {
return this.loadings.length;
}
}
In Details.tsx, replace the intent of the ramp buttons and add the number:
src/components/Details.tsx
{ramps.map((r) => <Button key={r.id} className="ramp-button" outlined
active={r === loading.ramp} onClick={() => loading.setRamp(r)}
intent={r.isEmpty ? Intent.NONE
: r === loading.ramp ? Intent.PRIMARY : Intent.DANGER}>
{r.description}
<sup>{r.quantity > 0 && r.quantity}</sup>
</Button>)}
Every ramp with loadings shows how many it has. The loading's own ramp is blue, other busy ramps are red, and empty ones stay neutral:
And that's the job done. All the logic we added lives in the stores: the view in UI, and the loadings, status and quantity in Ramp. The components only show it.
Before you call it finished, run the build. It runs tsc first, so it catches the type errors that the dev server lets through:
pnpm dlx pnpm@8 build
