useTimeWindowConfig.tsx 524 B

123456789101112131415161718192021
  1. import {useMemo} from 'react';
  2. import {getConfigFromTimeRange} from '../utils/getConfigFromTimeRange';
  3. import {useMonitorDates} from './useMonitorDates';
  4. interface Options {
  5. /**
  6. * The width of the timeline influences how we calculate the rollup value
  7. */
  8. timelineWidth: number;
  9. }
  10. export function useTimeWindowConfig({timelineWidth}: Options) {
  11. const {since, until} = useMonitorDates();
  12. return useMemo(
  13. () => getConfigFromTimeRange(since, until, timelineWidth),
  14. [since, until, timelineWidth]
  15. );
  16. }