import { Menu, Transition } from '@headlessui/react'; import { ChevronDownIcon } from '@heroicons/react/20/solid' import React, { Fragment, useCallback, useEffect } from 'react'; import classNames from 'classnames' import * as storage from '../../util/storage' import { isKeyPressed } from '../../keybinding.js' export const INTERVAL_LABELS = { 'minute': 'Minutes', 'hour': 'Hours', 'date': 'Days', 'week': 'Weeks', 'month': 'Months' } export const getStoredInterval = function(period, domain) { return storage.getItem(`interval__${period}__${domain}`) } export const storeInterval = function(period, domain, interval) { storage.setItem(`interval__${period}__${domain}`, interval) } function subscribeKeybinding(element) { const handleKeyPress = useCallback((event) => { if (isKeyPressed(event, "i")) element.current?.click() }, []) useEffect(() => { document.addEventListener('keydown', handleKeyPress) return () => document.removeEventListener('keydown', handleKeyPress) }, [handleKeyPress]) } function DropdownItem({ option, currentInterval, updateInterval }) { return (