teableio/teable

View on GitHub
apps/nextjs-app/src/features/app/blocks/billing/useSpaceSubscriptionStore.ts

Summary

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

interface ISpaceSubscriptionState {
  subscribeLevel?: BillingProductLevel;
  closeModal: () => void;
  openModal: (subscribeLevel: BillingProductLevel) => void;
}

export const useSpaceSubscriptionStore = create<ISpaceSubscriptionState>((set) => ({
  closeModal: () => {
    set((state) => {
      return {
        ...state,
        subscribeLevel: undefined,
      };
    });
  },
  openModal: (subscribeLevel: BillingProductLevel) => {
    set((state) => {
      return {
        ...state,
        subscribeLevel,
      };
    });
  },
}));