import type { Meta, StoryObj } from '@storybook/nextjs' import { useEffect, useState } from 'react' import TabSlider from '.' const OPTIONS = [ { value: 'models', text: 'Models' }, { value: 'datasets', text: 'Datasets' }, { value: 'plugins', text: 'Plugins' }, ] const TabSliderDemo = ({ initialValue = 'models', }: { initialValue?: string }) => { const [value, setValue] = useState(initialValue) useEffect(() => { const originalFetch = globalThis.fetch?.bind(globalThis) const handler = async (input: RequestInfo | URL, init?: RequestInit) => { const url = typeof input === 'string' ? input : input instanceof URL ? input.toString() : input.url if (url.includes('/workspaces/current/plugin/list')) { return new Response( JSON.stringify({ total: 6, plugins: [], }), { status: 200, headers: { 'Content-Type': 'application/json' }, }, ) } if (originalFetch) return originalFetch(input, init) throw new Error(`Unhandled request for ${url}`) } globalThis.fetch = handler as typeof globalThis.fetch return () => { if (originalFetch) globalThis.fetch = originalFetch } }, []) return (