import { ReactNode } from "react"; import { create } from "zustand"; export type AlertType = "success" | "warning" | "error" | "info"; export interface AlertState { isOpen: boolean; type: AlertType; title: ReactNode; message: ReactNode; confirmLabel?: string; cancelLabel?: string; onConfirm?: () => void; onCancel?: () => void; // 단일 버튼 모드 여부 (Confirm 모달이 아닌 단순 Alert) isSingleButton?: boolean; } interface AlertActions { openAlert: (params: Omit) => void; closeAlert: () => void; } const initialState: AlertState = { isOpen: false, type: "info", title: "", message: "", confirmLabel: "확인", cancelLabel: "취소", isSingleButton: true, }; export const useGlobalAlertStore = create((set) => ({ ...initialState, openAlert: (params) => set({ ...initialState, // 초기화 후 설정 ...params, isOpen: true, }), closeAlert: () => set({ isOpen: false }), }));