import e from"@babel/runtime/helpers/asyncToGenerator";import r from"@babel/runtime/regenerator";import{useCallback as t}from"react";import{selectTemplateOnDeletion as o,removeTemplateFromList as n,setBusy as a}from"../utils.js";import{Action as s,ConfirmationModalType as i}from"../../types.js";import{useGet as m,useConfirmation as p}from"./sharedHooks.js";import{useCloseTemplateMenu as c}from"./useCloseTemplateMenu.js";import{deleteAppSettingsTemplate as l}from"../../../../clients/jsonApi/index.js";import"../../../../utils/index.js";import{showSuccessNotification as f}from"../../../../utils/notificationToasts.js";var u=function(u){var d=m("get"),x=m("set"),T=c(),b=t(e(r.mark((function e(){var t,i,m,p;return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(T(),t=d(),i=t.currentTemplateId,!(m=n(d,x,d().confirmationTargetTemplateId))){e.next=18;break}return p=a(x,m.id,s.Delete),e.prev=5,e.next=8,l(d().appKey,m.id);case 8:if(m.id!==i){e.next=11;break}return e.next=11,o(d,x);case 11:f('"'.concat(m.name,'" has been successfully deleted.')),e.next=17;break;case 14:e.prev=14,e.t0=e.catch(5),console.error(e.t0);case 17:p();case 18:case"end":return e.stop()}}),e,null,[[5,14]])}))),[T,d,x]);return p(i.DeleteTemplate,b,{confirmationTargetTemplateId:u})};export{u as useDeleteTemplate};
//# sourceMappingURL=useDeleteTemplate.js.map
