teableio/teable

View on GitHub
apps/nextjs-app/src/features/app/blocks/graph/useCellGraphStore.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { create } from 'zustand';

interface ICellGraphState {
  graphOpen: boolean;
  openGraph: () => void;
  closeGraph: () => void;
  toggleGraph: () => void;
}

export const useCellGraphStore = create<ICellGraphState>((set) => ({
  graphOpen: false,
  toggleGraph: () => {
    set((state) => {
      return {
        ...state,
        graphOpen: !state.graphOpen,
      };
    });
  },
  openGraph: () => {
    set((state) => {
      return {
        ...state,
        graphOpen: true,
      };
    });
  },
  closeGraph: () => {
    set((state) => {
      return {
        ...state,
        graphOpen: false,
      };
    });
  },
}));