import React from 'react' import { type Meta } from '@storybook/react-vite' import { DocsTemplate } from '../../../.storybook' import { aggregateDataValues } from '../../services/HelperServiceTyped' export const Example = (args: { /** Data that needs to be aggregated */ data: Record[] /** Name of property to aggregate */ propName: string }): React.JSX.Element => { const result = aggregateDataValues(args.data, args.propName) return <>Aggregated data: {result !== null ? result : 'null'} } Example.storyName = 'aggregateDataValues' Example.args = { data: [{ num: 1 }, { num: 2 }, { num: 3 }], propName: 'num', } export default { title: 'Helper Functions/aggregateDataValues', component: Example, parameters: { viewMode: 'docs', previewTabs: { canvas: { hidden: true }, }, docs: { page: () => ( <> aggregateDataValues is used to sum numeric values from a specific property across an array of objects. , Returns null if the input array is empty or undefined. , ]} /> ), }, }, } as Meta