relativeSelector.tsx 683 B

123456789101112131415161718192021222324252627
  1. import {Fragment} from 'react';
  2. import {DEFAULT_RELATIVE_PERIODS} from 'sentry/constants';
  3. import SelectorItem from './selectorItem';
  4. type Props = {
  5. onClick: (value: string, e?: React.MouseEvent) => void;
  6. selected: string;
  7. relativePeriods?: Record<string, React.ReactNode>;
  8. };
  9. const RelativeSelector = ({onClick, selected, relativePeriods}: Props) => (
  10. <Fragment>
  11. {Object.entries(relativePeriods || DEFAULT_RELATIVE_PERIODS).map(([value, label]) => (
  12. <SelectorItem
  13. key={value}
  14. onClick={onClick}
  15. value={value}
  16. label={label}
  17. selected={selected === value}
  18. />
  19. ))}
  20. </Fragment>
  21. );
  22. export default RelativeSelector;