import { create } from 'zustand';

interface ConfirmDialogState {
  open: boolean;
  title: string;
  message: string;
  onConfirm?: () => void;
}

interface UIState {
  /** 글로벌 로딩 오버레이 */
  globalLoading: boolean;
  setGlobalLoading: (loading: boolean) => void;

  /** 전역 확인 다이얼로그 */
  confirmDialog: ConfirmDialogState;
  openConfirmDialog: (title: string, message: string, onConfirm: () => void) => void;
  closeConfirmDialog: () => void;
}

export const useUIStore = create<UIState>((set) => ({
  globalLoading: false,
  setGlobalLoading: (loading) => set({ globalLoading: loading }),

  confirmDialog: { open: false, title: '', message: '' },
  openConfirmDialog: (title, message, onConfirm) =>
    set({ confirmDialog: { open: true, title, message, onConfirm } }),
  closeConfirmDialog: () =>
    set({ confirmDialog: { open: false, title: '', message: '' } }),
}));
