teableio/teable

View on GitHub
packages/sdk/src/components/billing/store/usage-limit-modal.ts

Summary

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

export enum UsageLimitModalType {
  Upgrade = 'upgrade',
  User = 'user',
}

interface IUsageLimitModalState {
  modalType: UsageLimitModalType;
  modalOpen: boolean;
  openModal: (modalType: UsageLimitModalType) => void;
  closeModal: () => void;
  toggleModal: (open: boolean) => void;
}

export const useUsageLimitModalStore = create<IUsageLimitModalState>((set) => ({
  modalType: UsageLimitModalType.Upgrade,
  modalOpen: false,
  openModal: () => {
    set((state) => {
      return {
        ...state,
        modalOpen: true,
      };
    });
  },
  closeModal: () => {
    set((state) => {
      return {
        ...state,
        modalOpen: false,
      };
    });
  },
  toggleModal: (open: boolean) => {
    set((state) => {
      return {
        ...state,
        modalOpen: open,
      };
    });
  },
}));