import{_ as __unplugin_components_0}from"./ButtonDefault-BIBStZbJ.js";import{u as useGlobalStore}from"./global-5eUCDNCu.js";import{_ as _export_sfc}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{x as inject,r as ref,H as onMounted,s as onBeforeUnmount,c as createElementBlock,o as openBlock,a as createBaseVNode,b as createVNode,t as toDisplayString}from"./index-CmCGXBst.js";const _hoisted_1={class:"modal__body"},_hoisted_2={class:"modal__info"},_hoisted_3={class:"modal__alert-title"},_sfc_main={__name:"ModalWindowDeleteItem",props:{data:{type:Object,default:()=>{}}},emits:["modalClose"],setup(__props,{emit:__emit}){const props=__props,emit=__emit,globalStore=useGlobalStore(),emitter=inject("emitter"),isLoading=ref(!1);function deleteHosting(){if(isLoading.value=!0,props.data&&props.data?.callback){const e=props.data.callback.match(/RowsIDs:(\d+)/);globalStore.deleteItem({TableID:props.data?.tableID,RowsIDs:e[1]}).then(({result:t,error:o})=>{t==="SUCCESS"&&(emitter.emit(props.data?.successEmit),emit("modalClose")),isLoading.value=!1})}else props.data?globalStore.deleteItem({TableID:props.data?.tableID,RowsIDs:props.data?.id}).then(({result:e})=>{e==="SUCCESS"&&(emitter.emit(props.data?.successEmit),emit("modalClose")),isLoading.value=!1}):(eval(props.data?.callback),emit("modalClose"))}const handleKeyup=e=>{e.key==="Enter"&&deleteHosting()};return onMounted(()=>{document.addEventListener("keyup",handleKeyup)}),onBeforeUnmount(()=>{document.removeEventListener("keyup",handleKeyup)}),(e,t)=>{const o=__unplugin_components_0;return openBlock(),createElementBlock("div",_hoisted_1,[createBaseVNode("div",_hoisted_2,[createBaseVNode("div",_hoisted_3,toDisplayString(__props.data?.message),1)]),createVNode(o,{class:"modal__alert-button",onClick:t[0]||(t[0]=a=>deleteHosting()),label:"УДАЛИТЬ","is-loading":isLoading.value},null,8,["is-loading"])])}}},ModalWindowDeleteItem=_export_sfc(_sfc_main,[["__scopeId","data-v-4919bde8"]]);export{ModalWindowDeleteItem as default};
