feat: drill hydrogen trends into orders

This commit is contained in:
kkfluous
2026-08-07 16:29:26 +08:00
parent 263d8c6245
commit a8f7548314
10 changed files with 432 additions and 14 deletions
@@ -11,6 +11,7 @@ export interface HydrogenDrillContext {
vehicleScope: CustomerType;
startDate?: string;
endDate?: string;
selectedDate?: string;
}
interface LocationParts {
@@ -66,8 +67,14 @@ export function parseHydrogenDrillContext(search: string): HydrogenDrillContext
if (context.level === 'customer') context.customerName = customerName;
const startDate = validDate(params.get('hydrogenStart'));
const endDate = validDate(params.get('hydrogenEnd'));
const selectedDate = validDate(params.get('hydrogenDate'));
if (startDate) context.startDate = startDate;
if (endDate) context.endDate = endDate;
const rangeStart = startDate && endDate ? (startDate <= endDate ? startDate : endDate) : undefined;
const rangeEnd = startDate && endDate ? (startDate <= endDate ? endDate : startDate) : undefined;
if (selectedDate && (!rangeStart || !rangeEnd || (selectedDate >= rangeStart && selectedDate <= rangeEnd))) {
context.selectedDate = selectedDate;
}
return context;
}
@@ -85,6 +92,7 @@ export function buildHydrogenDrillUrl(
'hydrogenScope',
'hydrogenStart',
'hydrogenEnd',
'hydrogenDate',
]) {
params.delete(key);
}
@@ -101,6 +109,7 @@ export function buildHydrogenDrillUrl(
params.set('hydrogenScope', context.vehicleScope);
if (context.startDate) params.set('hydrogenStart', context.startDate);
if (context.endDate) params.set('hydrogenEnd', context.endDate);
if (context.selectedDate) params.set('hydrogenDate', context.selectedDate);
const query = params.toString();
return `${location.pathname}${query ? `?${query}` : ''}${location.hash}`;