feat: drill hydrogen trends into orders
This commit is contained in:
@@ -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}`;
|
||||
|
||||
Reference in New Issue
Block a user