import { AssetCategory, DEFAULT_APP_ID } from '@bit-ui-libs/common'; import { create } from 'zustand'; interface ChainAssetStoreState { appId?: string; eventId: string; assetVideoUri: string | null; categories: AssetCategory[]; typeName: string; typeId: string; shouldUploadPhoto: boolean; favorite: boolean; setAppId: (appId: string) => void; setEventId: (value: string) => void; setCategories: (categories: AssetCategory[]) => void; addCategory: (ac: AssetCategory) => void; popUntilCategoryId: (categoryId: string) => void; setType: (typeName: string, typeId: string) => void; setAssetVideoUri: (uri: string) => void; setShouldUploadPhoto: (shouldUploadPhoto: boolean) => void; toggleFavorite: () => void; } export const useChainAssetStore = create((set) => ({ appId: DEFAULT_APP_ID, eventId: '', assetVideoUri: null, categories: [], typeId: '', typeName: '', shouldUploadPhoto: true, favorite: false, setAppId: (appId) => set({ appId }), setEventId: (eventId) => set({ eventId }), setCategories: (categories) => set({ categories }), addCategory: (ac) => set((s) => ({ categories: [...s.categories, ac] })), popUntilCategoryId: (id) => set((s) => ({ categories: s.categories.slice( 0, s.categories.findIndex((c) => c.id === id) ), })), setType: (typeName, typeId) => set({ typeName, typeId }), setAssetVideoUri: (uri) => set(() => ({ assetVideoUri: uri })), setShouldUploadPhoto: (shouldUploadPhoto) => set({ shouldUploadPhoto }), toggleFavorite: () => set((s) => ({ favorite: !s.favorite })), }));