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

{label}

{JSON.stringify(timeframe, null, 2)}
{isValid ? 'Valid ✓' : 'Invalid ✗'}
) } export default { title: 'Helper Functions/checkForCorrectTimeframe', component: TimeframeValidationDisplay, parameters: { viewMode: 'docs', previewTabs: { canvas: { hidden: true }, }, docs: { page: () => ( <> Core features: , Required properties by timeframe type: , Common use cases: , Best practices: , ]} /> ), source: { code: false, }, }, }, argTypes: { label: { control: 'text', description: 'Label for the timeframe', }, timeframe: { control: 'object', description: 'Timeframe object to validate', }, }, } as Meta type Story = StoryObj const Template: Story = { render: (args) => { return }, } export const ValidHistoricalTimeframe: Story = { ...Template, args: { label: 'Valid Historical Timeframe', timeframe: { display: '30D', value: 30, timeValue: 'day', type: 'historical', }, }, } export const ValidTrailingTimeframe: Story = { ...Template, args: { label: 'Valid Trailing Timeframe', timeframe: { display: '24HRS', value: 24, timeValue: 'hours', type: 'trailing', }, }, } export const ValidCurrentTimeframe: Story = { ...Template, args: { label: 'Valid Current Timeframe', timeframe: { display: 'This Month', timeValue: 'month', type: 'current', }, }, } export const ValidQuarterlyTimeframe: Story = { ...Template, args: { label: 'Valid Quarterly Timeframe', timeframe: { display: '2025 Q1', timeValue: 'quarter', type: 'quarterly', year: '2025', quarter: 1, }, }, } export const InvalidTimeframeMissingTimeValue: Story = { ...Template, args: { label: 'Invalid Timeframe (Missing timeValue)', timeframe: { display: '30D', type: 'historical', value: 30, }, }, } export const InvalidHistoricalTimeframeMissingValue: Story = { ...Template, args: { label: 'Invalid Historical Timeframe (Missing value)', timeframe: { display: '30D', timeValue: 'day', type: 'historical', }, }, } export const NullTimeframe: Story = { ...Template, args: { label: 'Null Timeframe', timeframe: null, }, }