import React from 'react' import { type Meta } from '@storybook/react-vite' import { getApiUrlPrefix } from '../../services/apiEndpointHelpers' import { DocsTemplate } from '../../../.storybook' export const Example = (): React.JSX.Element => { const apiUrl = getApiUrlPrefix() const customBackendUrl = getApiUrlPrefix('custom-backend') // Example with custom configuration const customMappingUrl = getApiUrlPrefix('api', { customMappings: { development: '/local-{backend}', production: '/prod-{backend}', }, }) // Example with environment override const overrideUrl = getApiUrlPrefix('service', { customEnvironmentName: 'development', }) return (

Default backend URL prefix: {apiUrl}

Custom backend URL prefix: {customBackendUrl}

Custom mapping example: {customMappingUrl}

Environment override example: {overrideUrl}

) } Example.storyName = 'getApiUrlPrefix' export default { title: 'Helper Functions/getApiUrlPrefix', component: Example, parameters: { viewMode: 'docs', previewTabs: { canvas: { hidden: true }, }, docs: { page: () => ( <> hostname.includes('my-dev.com') } ], fallbackEnvironment: 'production' }, customMappings: { 'development': '/dev-{backend}' } })`} description='A flexible utility function that generates environment-aware API URL prefixes for different backend services. It automatically adjusts the URL prefix based on the current environment and supports extensive customization options for one-off cases without modifying the core library.' infoBullets={[ Core features: , Default URL prefix patterns by environment: , Configuration options: , Development features: , Common use cases: , ]} /> ), }, }, } as Meta