mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 02:30:55 +00:00
feat(warehouse): P1 dashboard analytics — dwell/aging, cycle-time + on-time, live deltas
Adds the operational-performance layer to the warehouse cockpit:
- Dwell time & aging: dwellStats() (avg + 0-3/4-7/8-14/15+ buckets over
in-warehouse items) → DwellAgingCard histogram.
- Cycle time & on-time: cycleStats() (arrived→ready→loaded→dispatched stage
averages + dock-to-dispatch) and onTimeDispatchStats() (share of items that
left before their storage free-days expired, resolved via the fee engine's
own rule matching) → CycleTimeCard.
- Live tiles: opsStats() now returns receivedYesterday; KpiStrip renders an
optional ▲/▼ delta, and the ops strip shows received-today vs yesterday.
New endpoints: GET /warehouse-inventory/{dwell-stats,cycle-stats} and
/warehouse-fees/on-time-dispatch (all guarded). New "Performance" section on
WarehouseDashboardPage. On-time reads N/A when there is no sample / no active
storage rule.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -160,6 +160,30 @@ export function useWarehouseThroughput(granularity: 'week' | 'month' | 'year') {
|
||||
});
|
||||
}
|
||||
|
||||
/** Dwell time of in-warehouse items (average + aging buckets). */
|
||||
export function useWarehouseDwellStats() {
|
||||
return useQuery({
|
||||
queryKey: ['warehouse-inventory', 'dwell-stats'],
|
||||
queryFn: () => warehouseService.dwellStats().then((r) => r.data),
|
||||
});
|
||||
}
|
||||
|
||||
/** Average stage cycle times over recently dispatched items. */
|
||||
export function useWarehouseCycleStats() {
|
||||
return useQuery({
|
||||
queryKey: ['warehouse-inventory', 'cycle-stats'],
|
||||
queryFn: () => warehouseService.cycleStats().then((r) => r.data),
|
||||
});
|
||||
}
|
||||
|
||||
/** On-time dispatch rate (left before storage free-days expired). */
|
||||
export function useOnTimeDispatch() {
|
||||
return useQuery({
|
||||
queryKey: ['warehouse-fees', 'on-time-dispatch'],
|
||||
queryFn: () => warehouseService.onTimeDispatch().then((r) => r.data),
|
||||
});
|
||||
}
|
||||
|
||||
/** Live per-item fee accrual (storage/demurrage) with alerts. */
|
||||
export function useAccrualDashboard(billingCurrency?: 'ETB' | 'USD') {
|
||||
return useQuery({
|
||||
|
||||
Reference in New Issue
Block a user