feat(uat-batch): Group N — dashboard upgrades
N44, N45, N46 from the 2026-05-21 plan.
Shipped:
N44 Pipeline Value tile respects dashboard timeframe. Tile accepts
optional `range` prop and threads it through
/api/v1/dashboard/kpis?range=<slug> + /forecast?range=<slug>.
Service functions accept optional {from,to} bounds and scope
the pipeline-value SQL to interests created within the window.
New parseRangeSlug helper inverts rangeToSlug. Widget registry
forwards the active dashboard range to the tile.
N45 Clients by country widget. New GET
/api/v1/dashboard/clients-by-country groups non-archived
clients by nationality_iso. <ClientsByCountryWidget> renders a
compact ranked list with mini-bars; rows link to
/clients?nationality=<ISO>. Registered as default-visible rail.
N46 Drag-and-drop dashboard widgets. New
preferences.dashboardWidgetOrder?: string[] on user_profiles;
useDashboardWidgets sorts visibleWidgets by the order
(unlisted ids fall through to registry order) and exposes
setOrder(nextOrder) that PATCHes optimistically.
DashboardShell wires @dnd-kit/core + sortable: Rearrange toggle
turns on per-widget grip handles + sortable-context wraps each
group (charts / rails / feed) so drops stay in-group.
PointerSensor 8px activation distance, KeyboardSensor for a11y.
New <SortableWidget> wraps the render — zero footprint when
off.
Verified: tsc clean, vitest 1454/1454.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -45,6 +45,20 @@ export function rangeToSlug(range: DateRange): string {
|
||||
return range;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inverse of rangeToSlug — parses a `?range=<slug>` query-string value
|
||||
* back into a typed DateRange. Returns null on garbage input so callers
|
||||
* can fall through to their "no range" default rather than 400ing.
|
||||
*/
|
||||
export function parseRangeSlug(slug: string): DateRange | null {
|
||||
if (ALL_RANGES.includes(slug as PresetDateRange)) return slug as PresetDateRange;
|
||||
// Custom: `YYYY-MM-DD_YYYY-MM-DD`. Both halves must look like ISO dates;
|
||||
// anything else is malformed.
|
||||
const m = /^(\d{4}-\d{2}-\d{2})_(\d{4}-\d{2}-\d{2})$/.exec(slug);
|
||||
if (!m) return null;
|
||||
return { kind: 'custom', from: m[1]!, to: m[2]! };
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve any DateRange (preset or custom) to a concrete {from, to} pair.
|
||||
* - Preset ranges anchor `to` at "now" and `from` at `now - N days`.
|
||||
|
||||
Reference in New Issue
Block a user