import React from 'react' import { type Meta, type StoryObj } from '@storybook/react-vite' import { getTimeframeDates } from '../../services/TimeframeServiceTyped' import { DocsTemplate } from '../../../.storybook' const TimeframeDateDisplay = ({ timeframe, dateType, label }) => { const resultDate = getTimeframeDates(timeframe, dateType) return (

{label}

Input Timeframe:
{JSON.stringify(timeframe, null, 2)}
Date Type: {dateType}
Result: {resultDate}
) } export default { title: 'Helper Functions/getTimeframeDates', component: TimeframeDateDisplay, parameters: { viewMode: 'docs', previewTabs: { canvas: { hidden: true }, }, docs: { page: () => ( <> Core features: , Supported timeframe types: , Common use cases: , Best practices: , ]} /> ), source: { code: false, }, }, }, argTypes: { label: { control: 'text', description: 'Label for the timeframe date calculation', }, timeframe: { control: 'object', description: 'Timeframe object to calculate dates from', }, dateType: { control: 'radio', options: ['startDate', 'endDate'], description: 'Whether to get start or end date of the timeframe', }, }, } as Meta type Story = StoryObj const Template: Story = { render: (args) => { return }, } export const Historical30Days: Story = { ...Template, args: { label: 'Historical 30 Days (Start Date)', timeframe: { display: '30D', value: 30, timeValue: 'day', type: 'historical', }, dateType: 'startDate', }, } export const Historical30DaysEnd: Story = { ...Template, args: { label: 'Historical 30 Days (End Date)', timeframe: { display: '30D', value: 30, timeValue: 'day', type: 'historical', }, dateType: 'endDate', }, } export const Trailing24Hours: Story = { ...Template, args: { label: 'Trailing 24 Hours (Start Date)', timeframe: { display: '24HRS', value: 24, timeValue: 'hours', type: 'trailing', }, dateType: 'startDate', }, } export const CurrentMonth: Story = { ...Template, args: { label: 'Current Month (Start Date)', timeframe: { display: 'This Month', timeValue: 'month', type: 'current', }, dateType: 'startDate', }, } export const CurrentMonthEnd: Story = { ...Template, args: { label: 'Current Month (End Date)', timeframe: { display: 'This Month', timeValue: 'month', type: 'current', }, dateType: 'endDate', }, } export const QuarterlyQ1: Story = { ...Template, args: { label: 'Quarterly Q1 2025 (Start Date)', timeframe: { display: '2025 Q1', timeValue: 'quarter', type: 'quarterly', year: '2025', quarter: 1, }, dateType: 'startDate', }, } export const PreviousYear: Story = { ...Template, args: { label: 'Previous Year (Start Date)', timeframe: { display: 'Last Year', timeValue: 'year', type: 'previous', }, dateType: 'startDate', }, } export const CustomTimeframe: Story = { ...Template, args: { label: 'Custom Date Range (Start Date)', timeframe: { display: '2025-01-01 - 2025-01-31', value: 'custom', timeValue: 'day', type: 'historical', }, dateType: 'startDate', }, } export const AllTimeHistorical: Story = { ...Template, args: { label: 'All Time Historical (Start Date)', timeframe: { display: 'All Time', value: 'All', timeValue: 'day', type: 'historical', }, dateType: 'startDate', }, }