teableio/teable

View on GitHub
apps/nextjs-app/src/features/app/blocks/base/duplicate/useDuplicateBaseStore.ts

Summary

Maintainability
A
0 mins
Test Coverage
import type { IGetBaseVo } from '@teable/openapi';
import { create } from 'zustand';

interface IDuplicateBaseState {
  base?: IGetBaseVo;
  closeModal: () => void;
  openModal: (base: IGetBaseVo) => void;
}

export const useDuplicateBaseStore = create<IDuplicateBaseState>((set) => ({
  closeModal: () => {
    set((state) => {
      return {
        ...state,
        base: undefined,
      };
    });
  },
  openModal: (base: IGetBaseVo) => {
    set((state) => {
      return {
        ...state,
        base,
      };
    });
  },
}));