Refactor part 2: Electric Boogaloo. Standardize way of passing filter parameters.
This commit is contained in:
18
src/components/hooks/useDateParameters.ts
Normal file
18
src/components/hooks/useDateParameters.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { useDateRange } from './useDateRange';
|
||||
import { useTimezone } from './useTimezone';
|
||||
|
||||
export function useDateParameters(websiteId: string) {
|
||||
const {
|
||||
dateRange: { startDate, endDate, unit },
|
||||
} = useDateRange(websiteId);
|
||||
const { timezone, toUtc } = useTimezone();
|
||||
|
||||
return {
|
||||
startAt: +toUtc(startDate),
|
||||
endAt: +toUtc(endDate),
|
||||
startDate: toUtc(startDate).toISOString(),
|
||||
endDate: toUtc(endDate).toISOString(),
|
||||
unit,
|
||||
timezone,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user