/* Banyan Pharmacy — Stores (stores-as-projects) */
function SupplierChips({ ids, max = 3 }) {
const app = useApp();
return (
{ids.slice(0, max).map((id) => {
const s = D.supplierById[id];
return { e.stopPropagation(); app.nav({ name: "supplier", id }); }}>{s.name};
})}
);
}
function StoresPage() {
const app = useApp();
const stage = app.stage;
const focusId = app.loopFocus && app.loopFocus.kind === "store" ? app.loopFocus.id : null;
const rows = [...D.stores].sort((a, b) => {
const ra = D.HEALTH_RANK[window.storeStatusAt(a, stage)], rb = D.HEALTH_RANK[window.storeStatusAt(b, stage)];
return ra - rb;
});
return (
Stores
10 stores · 3 hospital · 1 flagship · 6 neighbourhood — each store is its own record
| Store | Format | Region | Manager | Shelf-health |
Open | Primary suppliers | |
{rows.map((s) => {
const status = window.storeStatusAt(s, stage);
const focus = focusId === s.id;
return (
app.nav({ name: "store", id: s.id })}>
|
{s.locality}
{s.id}
|
|
{s.region} |
{s.manager} |
|
{s.openAlerts > 0 ? {s.openAlerts} : —} |
|
|
);
})}
Shelf-health is an estimate; thresholds are tighter for hospital stores.
);
}
function ShelfHealthRow({ item }) {
return (
{window.skuName(item.sku)}
{item.expiry && Expiry}
{item.note}
);
}
function StoreDetail({ route }) {
const app = useApp();
const store = D.storeById[route.id];
if (!store) return Store not found.
;
const stage = app.stage;
const status = window.storeStatusAt(store, stage);
const f = D.FORMAT[store.format];
const orders = (D.ordersByStore[store.id] || []);
const shelf = D.shelf[store.id] || [];
return (
app.nav({ name: "stores" })}>All stores
{store.locality}
{store.name} · {store.region} · Manager: {store.manager} {store.id}
{/* Format frames everything */}
Format · {f.label}
{f.note}
SKU mix & criticality
{f.mix}. {f.crit}
{store.format === "hospital" ? "Tighter thresholds — a ward needs it now." : "Inferred from sales pace, last delivery, and store reports."}
{store.suppliers.map((id) => {
const s = D.supplierById[id];
return (
app.nav({ name: "supplier", id })}>
{s.reliability === "reliable" ? "Reliable" : s.reliability === "watch" ? "Watch" : "Slipping"}
);
})}
| Order | SKU | Supplier | Qty | Due | Status |
{orders.map((o) => (
| {o.id} |
{window.skuName(o.sku)} |
{D.supplierById[o.supplierId].name} |
{o.qty} |
{window.shortDate(o.due)} |
{o.status} |
))}
{!orders.length && | No pending orders. |
}
);
}
window.Pages = window.Pages || {};
window.Pages.Stores = StoresPage;
window.Pages.StoreDetail = StoreDetail;