import { ModalOptionsEx, useMessage } from '../web/useMessage';

export function useSyncConfirm() {
  const { createConfirm } = useMessage();

  const createSyncConfirm = (options: ModalOptionsEx): Promise<boolean> => {
    return new Promise((resolve, reject) => {
      createConfirm({
        ...options,
        onOk: () => {
          resolve(true);
        },
        onCancel: () => {
          reject(false);
        },
      });
    });
  };

  return { createSyncConfirm };
}
