import { create } from 'zustand';

interface ModalStore {
  activeModal: string | null;
  modalData: Record<string, unknown> | null;
  openModal: (name: string, data?: Record<string, unknown>) => void;
  closeModal: () => void;
}

export const useModalStore = create<ModalStore>((set) => ({
  activeModal: null,
  modalData: null,
  openModal: (name, data) =>
    set({
      activeModal: name,
      modalData: data ?? null,
    }),
  closeModal: () =>
    set({
      activeModal: null,
      modalData: null,
    }),
}));
