import React from 'react' import { type Meta } from '@storybook/react-vite' import { getEnvironmentName } from '../../services/apiEndpointHelpers' import { DocsTemplate } from '../../../.storybook' export const Example = (): React.JSX.Element => { const environment = getEnvironmentName() // Example with custom detectors const customEnvironment = getEnvironmentName({ customDetectors: [ { name: 'development', matcher: (hostname) => hostname.includes('my-custom-dev.com'), }, ], }) // Example with fallback environment const fallbackEnvironment = getEnvironmentName({ fallbackEnvironment: 'development', }) return (

Default environment detection: {environment}

Custom detector example: {customEnvironment}

Fallback environment example: {fallbackEnvironment}

) } Example.storyName = 'getEnvironmentName' export default { title: 'Helper Functions/getEnvironmentName', component: Example, parameters: { viewMode: 'docs', previewTabs: { canvas: { hidden: true }, }, docs: { page: () => ( <> hostname.includes('my-feature-branch.vercel.app') }, { name: 'demo', matcher: (hostname) => hostname.includes('tenant1.demo.com') } ] }) // Override fallback environment const envWithFallback = getEnvironmentName({ fallbackEnvironment: 'development' }) // Combine custom detectors with fallback const advancedEnv = getEnvironmentName({ customDetectors: [ { name: 'stage', matcher: (hostname) => hostname.includes('temp-staging.com') } ], fallbackEnvironment: 'development' })`} description="A flexible utility function that determines the current environment by analyzing the application's hostname. Now supports extensive customization options for one-off cases, allowing custom environment detection without modifying the core library." infoBullets={[ Core features: , Default environment detection patterns: , Configuration options: , Common use cases: , Benefits of the enhanced approach: , ]} /> ), }, }, } as Meta