"use strict";(self.webpackChunkautonami=self.webpackChunkautonami||[]).push([[2043],{22043(e,t,a){a.r(t),a.d(t,{default:()=>h});var n=a(86087),r=a(27723),o=a(16520),l=a(78551),s=a(95731),c=a(28614),i=a(83583),u=a(21668),m=a(66087),f=a(91218),d=a(87361),p=a(29548),w=a(22008);function g(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=a){var n,r,o,l,s=[],c=!0,i=!1;try{if(o=(a=a.call(e)).next,0===t){if(Object(a)!==a)return;c=!1}else for(;!(c=(n=o.call(a)).done)&&(s.push(n.value),s.length!==t);c=!0);}catch(e){i=!0,r=e}finally{try{if(!c&&null!=a.return&&(l=a.return(),Object(l)!==l))return}finally{if(i)throw r}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return y(e,t);var a={}.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?y(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,n=Array(t);a<t;a++)n[a]=e[a];return n}const h=function(e){var t=e.campaignType;(0,f.A)("orders","",!0,!0,!1,t);var a=e.campaignId,y=s.A.getConversionData(),h=s.A.getConversionLoading(),b=s.A.getConversionLimit(),v=s.A.getConversionOffset(),_=s.A.getConversionTotal(),k=(0,l.A)(),E=k.fetchConversion,A=k.setConversionValues;(0,n.useEffect)(function(){return function(){return A("offset",0)}},[]),(0,n.useEffect)(function(){E(a,b,v)},[b,v]);var C=[{key:"orderid",label:(0,r.__)("Order ID","wp-marketing-automations"),cellClassName:"bwf-crm-col-stats-m"},{key:"contact",label:(0,r.__)("Contact","wp-marketing-automations"),required:!0,cellClassName:"bwf-crm-col-contact"},{key:"purchaseitems",label:(0,r.__)("Purchased Items","wp-marketing-automations"),cellClassName:"bwf-crm-col-contact-details"},{key:"revenue",label:(0,r.__)("Revenue","wp-marketing-automations"),cellClassName:"bwf-crm-col-stats-m"},{key:"date",label:(0,r.__)("Date","wp-marketing-automations"),cellClassName:"bwf-crm-col-stats-m"}],N=s.A.getConversionPage(),O=function(e){e!==b&&(A("limit",e),A("offset",0))},P=function(e){return(0,n.createElement)(p.A,{href:"admin.php?page=autonami&path=/contact/"+e.cid,type:"bwf-crm",className:"bwf-crm-campaign-order-contact-link bwf-a-no-underline",key:e.cid},(0,n.createElement)(w.A,{contact:e,date:e.date,dateText:(0,r.__)("Placed on","wp-marketing-automations")}))},I=function(e){return e.hasOwnProperty("order_deleted")&&e.order_deleted?(0,n.createElement)(n.Fragment,null,"#"+e.wcid):(0,n.createElement)("a",{target:"_blank",className:"bwf-a-no-underline",href:"post.php?post="+e.wcid+"&action=edit",rel:"noreferrer"},"#"+e.wcid)},j=function(e){if(e.hasOwnProperty("wctotal")&&parseFloat(e.wctotal)>0){var t=(0,c.A)(e.hasOwnProperty("currency")?e.currency:(0,i.r)()).formatAmount;return(0,n.createElement)("span",{className:"bwf-tags bwf-tag-green"},t(e.wctotal))}return"-"},S=y.map(function(e){return[{display:e.hasOwnProperty("wcid")?I(e):"",value:e.hasOwnProperty("wcid")?e.wcid:"-"},{display:P(e),value:e.hasOwnProperty("contact_name")?e.contact_name:""},{display:e.hasOwnProperty("items")?(t=e.items,a="",o=[],Object.entries(t).map(function(e){var t=g(e,2),r=t[0],l=t[1];(0,m.isEmpty)(a)&&(a=(0,n.createElement)("a",{className:"bwf-a-no-underline",target:"_blank",href:"post.php?action=edit&post="+r,rel:"noreferrer"},l)),o.push((0,n.createElement)("a",{className:"bwf-a-no-underline",target:"_blank",href:"post.php?action=edit&post="+r},l))}),(0,n.createElement)(n.Fragment,null,(0,m.isEmpty)(a)?"-":a,!(0,m.isEmpty)(o)&&o.length>1&&(0,n.createElement)(u.A,{items:o}))):(0,r.__)("Order Deleted","wp-marketing-automations"),value:""},{display:j(e),value:""},{display:e.hasOwnProperty("date")?(0,i.po)(e.date):"-",value:""}];var t,a,o});return(0,n.createElement)(n.Fragment,null,(0,n.createElement)(d.A,null),(0,n.createElement)("div",{className:"bwf-content-header-new"},(0,n.createElement)("div",{className:"bwf-content-header-left"},(0,n.createElement)("div",{className:"bwf-content-header-title2"},(0,r.__)("Orders","wp-marketing-automations")),parseInt(_)>0&&(0,n.createElement)("div",{className:"bwf-content-header-count"},(0,r.sprintf)((0,r._n)("(%s Result)","(%s Results)",_,"wp-marketing-automations"),_)))),(0,n.createElement)(o.A,{className:"bwf-crm-campaign-report-conversion",rows:S,headers:C,query:{paged:N},rowsPerPage:b,totalRows:_,isLoading:h,onPageChange:function(e,t){A("offset",(e-1)*b)},onQueryChange:function(e){return"per_page"!==e?function(){}:O},rowHeader:!0,showMenu:!1,emptyMessage:(0,r.__)("No orders found","wp-marketing-automations"),hideHeader:"yes"}))}}}]);