import React from 'react' import { type Meta } from '@storybook/react-vite' import { DocsTemplate } from '../../../.storybook' import { historicalTimeframes } from '../../services/TimeframeServiceTyped' export const Example = (): React.JSX.Element => { return (

Historical Timeframes:

 {JSON.stringify(historicalTimeframes, null, 2)} 
) } Example.storyName = 'HISTORICAL_TIMEFRAMES' export default { title: 'Helper Variables/HISTORICAL_TIMEFRAMES', component: Example, parameters: { viewMode: 'docs', previewTabs: { canvas: { hidden: true }, }, docs: { page: () => ( <> { console.log('Selected timeframe:', timeframe); console.log('Date range:', startDate.format('L'), 'to', endDate.format('L')); }; const initialTimeframe = { type: 'historical', display: '30D', value: 30, timeValue: 'day' }; // Access specific timeframe const thirtyDayTimeframe = historicalTimeframes.find(t => t.display === '30D'); // Calculate date range for a specific timeframe const timeframe = thirtyDayTimeframe; const startDate = getTimeframeDates(timeframe, 'startDate'); const endDate = getTimeframeDates(timeframe, 'endDate'); // Start date will be 30 days ago from today, at the start of that day console.log(moment(startDate).format('YYYY-MM-DD HH:mm:ss')); // End date will typically be yesterday at end of day console.log(moment(endDate).format('YYYY-MM-DD HH:mm:ss')); `} description='A predefined collection of historical timeframe options used throughout the application for consistent date range filtering and data visualization.' infoBullets={[ Core features:
  • Standardized set of common historical time periods (1D, 1W, 30D, 3M, 6M, 1Y)
  • Designed for use with the Timeframe and{' '} TimeframeFilter components
  • Compatible with date calculation functions like{' '} getTimeframeDates
, Structure and properties:
  • id: Unique identifier
  • display: label shown in UI (e.g., "30D")
  • value: Numeric amount of time (e.g., 30 for 30 days)
  • timeValue: Time unit ("day", "week", "month", "year")
  • type: Always "historical" to distinguish from other timeframe types
, Common use cases:
  • Date range selection in analytics dashboards
  • Filtering data in reports and visualizations
  • Setting default time periods for initial data load
  • Creating consistent time comparison options across features
, Best practices:
  • Use with getTimeframeDates to calculate actual start and end dates
  • Set initialTimeframe to a value from this array for consistent defaults
  • Pass directly to Timeframe component's{' '} historicalTimeframes prop
  • Validate selected timeframes with{' '} checkForCorrectTimeframe before using
, ]} /> ), source: { code: false, }, }, }, } as Meta