import{_ as __unplugin_components_0}from"./ButtonDefault-CzWpVlv6.js";import{u as useGlobalStore}from"./global-BK91p1BE.js";import{_ as _export_sfc}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{A as inject,r as ref,l as onMounted,D as onBeforeUnmount,o as openBlock,c as createElementBlock,a as createBaseVNode,t as toDisplayString,b as createVNode}from"./index-Bb2UEb_P.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})=>{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-d3064614"]]);export{ModalWindowDeleteItem as default};
