import { confirmStore } from "./store"; const createId = () =>{ return typeof crypto !== "undefined" && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}_${Math.random()}`; } // let id = createId(); export function confirmDialog(options: { title?: string; content?: string | string[]; noOk?: boolean; noCancel?: boolean; okBtnTxt?: string; cancelBtnTxt?: string; }) { return new Promise((resolve) => { const state = confirmStore.getSnapshot(); confirmStore.setState({ queue: [ ...state.queue, { id: createId(), ...options, resolve, }, ], }); }); }