import { create } from "zustand"; import type { ReactNode } from "react"; interface IConfirmStore { visible: boolean; message: string; content?: ReactNode; title: string; onConfirm: () => void; onCancel: () => void; show: (message: string, onConfirm: () => void, onCancel: () => void) => void; showContent: (message: string, content: ReactNode, onConfirm: () => void, onCancel: () => void) => void; close: () => void; clear: () => void; } export type ConfirmState = IConfirmStore; const useConfirmStore = create()((set) => ({ visible: false, message: "", content: undefined, title: "", onConfirm: () => {}, onCancel: () => {}, show: (message: string, onConfirm: () => void, onCancel: () => void) => set(() => ({ visible: true, message: message, content: undefined, onConfirm: onConfirm, onCancel: onCancel, title: "Atención", })), showContent: (message: string, content: ReactNode, onConfirm: () => void, onCancel: () => void) => set(() => ({ visible: true, message: message, content: content, onConfirm: onConfirm, onCancel: onCancel, title: "Atención", })), close: () => set(() => ({ visible: false, message: "", content: undefined, onConfirm: () => {}, onCancel: () => {}, title: "", })), clear: () => set(() => ({ visible: false, message: "", content: undefined, onConfirm: () => {}, onCancel: () => {}, title: "", })), })); export { useConfirmStore };