diff --git a/packages/sanity/src/core/store/bundles/__workshop__/BundlesStoreStory.tsx b/packages/sanity/src/core/store/bundles/__workshop__/BundlesStoreStory.tsx new file mode 100644 index 00000000000..cd554fe5b86 --- /dev/null +++ b/packages/sanity/src/core/store/bundles/__workshop__/BundlesStoreStory.tsx @@ -0,0 +1,110 @@ +import {Card, Flex, Stack, Text} from '@sanity/ui' +import {type ComponentType, type FormEvent, useCallback, useState} from 'react' + +import {Button} from '../../../../ui-components' +import {LoadingBlock} from '../../../components/loadingBlock/LoadingBlock' +import {AddonDatasetProvider} from '../../../studio/addonDataset/AddonDatasetProvider' +import {type BundleDocument} from '../types' +import {useBundleOperations} from '../useBundleOperations' +import {useBundlesStore} from '../useBundlesStore' +import {ReleaseForm} from './ReleaseForm' + +const WithAddonDatasetProvider =

(Component: ComponentType

): React.FC

=> { + const WrappedComponent: React.FC

= (props) => ( + + + + ) + WrappedComponent.displayName = `WithAddonDatasetProvider(${Component.displayName || Component.name || 'Component'})` + + return WrappedComponent +} + +const initialValue = {name: '', title: '', tone: undefined, publishAt: undefined} +const BundlesStoreStory = () => { + const {data, loading} = useBundlesStore() + const {createBundle, deleteBundle} = useBundleOperations() + const [creating, setCreating] = useState(false) + const [deleting, setDeleting] = useState(null) + const [value, setValue] = useState>(initialValue) + const handleCreateBundle = useCallback( + async (event: FormEvent) => { + try { + event.preventDefault() + setCreating(true) + await createBundle(value) + setValue(initialValue) + } catch (err) { + console.error(err) + } finally { + setCreating(false) + } + }, + [createBundle, value], + ) + + const handleDeleteBundle = useCallback( + async (id: string) => { + try { + setDeleting(id) + await deleteBundle(id) + } catch (err) { + console.error(err) + } finally { + setDeleting(null) + } + }, + [deleteBundle], + ) + + return ( + + + +

+ + Create a new release + + +