D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
tvinntxo
/
www
/
wp-content
/
plugins
/
mailpoet
/
assets
/
dist
/
js
/
Filename :
automation.cbaec386.js
back
Copy
"use strict";(self.webpackChunkMailPoet3=self.webpackChunkMailPoet3||[]).push([[916],{66609:function(e,n,t){var o=t(52524),r=t.n(o),a=t(45993);const i=window.mailpoet_automation_api,d=`${i.root}/mailpoet/v1/automation`,s=(e,n)=>{const[t,o]=(0,a.useState)({data:void 0,loading:!1,error:void 0});return[(0,a.useCallback)((async t=>{var r;o((e=>({...e,loading:!0})));const a=await((e,n)=>fetch(`${d}/${e}`,n))(e,{...n,...t,headers:{"content-type":"application/json",...null!==(r=t?.headers)&&void 0!==r?r:{},"x-wp-nonce":i.nonce}});try{const e=await a.json(),n=a.ok?null:{...a,data:e};o((t=>({...t,data:e,error:n})))}catch(e){const n={response:a};o((e=>({...e,error:n})))}finally{o((e=>({...e,loading:!1})))}}),[n,e]),t]},c=e=>e.toString(16).padStart(2,"0"),l=()=>{if(!window.crypto||!window.crypto.getRandomValues)throw new Error("Web Crypto API 'crypto.getRandomValues' is not available");return Array.from(window.crypto.getRandomValues(new Uint8Array(8))).map(c).join("")};var u=t(15451);const w=()=>{const e={id:l(),type:"action",key:"core:wait",args:{seconds:60}},n=(t=e.id,{id:l(),type:"trigger",key:"mailpoet:segment:subscribed",next_step_id:t});var t;return{name:`Test ${(new Date).toISOString()}`,steps:{[n.id]:n,[e.id]:e}}};function p(){var e;const[n,{loading:t,error:o}]=s("workflows",{method:"POST"});return(0,u.jsxs)("div",{children:[(0,u.jsx)("button",{type:"button",onClick:()=>n({body:JSON.stringify(w())}),disabled:t,children:"Create testing workflow"}),o&&(0,u.jsx)("div",{children:null!==(e=o?.data?.message)&&void 0!==e?e:"An unknown error occurred"})]})}function m(){const{data:e,loading:n,error:t}=((e,n)=>{const[t,o]=s("workflows",void 0);return(0,a.useEffect)((()=>{t()}),[]),o})();return!e||n?(0,u.jsx)("div",{children:"Calling API..."}):(0,u.jsx)("div",{children:t?"API error!":"API OK ✓"})}function h(){var e;const[n,{loading:t,error:o}]=s("system/database",{method:"POST"});return(0,u.jsxs)("div",{children:[(0,u.jsx)("button",{type:"button",onClick:()=>n(),disabled:t,children:"Recreate DB schema (data will be lost)"}),o&&(0,u.jsx)("div",{children:null!==(e=o?.data?.message)&&void 0!==e?e:"An unknown error occurred"})]})}function v(){var e;const[n,{loading:t,error:o}]=s("system/database",{method:"DELETE"});return(0,u.jsxs)("div",{children:[(0,u.jsx)("button",{type:"button",onClick:async()=>{await n(),window.location.href="/wp-admin/admin.php?page=mailpoet-experimental"},disabled:t,children:"Delete DB schema & deactivate feature"}),o&&(0,u.jsx)("div",{children:null!==(e=o?.data?.message)&&void 0!==e?e:"An unknown error occurred"})]})}function g(){return(0,u.jsxs)("div",{children:[(0,u.jsx)(m,{}),(0,u.jsx)(p,{}),(0,u.jsx)(h,{}),(0,u.jsx)(v,{})]})}window.addEventListener("DOMContentLoaded",(()=>{const e=document.getElementById("mailpoet_automation");e&&r().render((0,u.jsx)(g,{}),e)}))}},function(e){e.O(0,[351],(function(){return 66609,e(e.s=66609)})),e.O()}]);