whoami7 - Manager
:
/
home
/
dataiclx
/
www
/
wp-content
/
plugins
/
woocommerce
/
assets
/
client
/
admin
/
chunks
/
Upload File:
files >> /home/dataiclx/www/wp-content/plugins/woocommerce/assets/client/admin/chunks/analytics-settings.js
"use strict";(globalThis.webpackChunk_wcAdmin_webpackJsonp=globalThis.webpackChunk_wcAdmin_webpackJsonp||[]).push([[5941],{45579:(e,t,o)=>{o.r(t),o.d(t,{default:()=>D});var s=o(27723),r=o(56427),a=o(86087),i=o(29491),n=o(47143),c=o(98846),l=o(40314),m=o(83306),d=o(15838),p=o(66087),h=o(39793);class u extends a.Component{constructor(e){super(e),this.state={disabled:!1}}renderInput=()=>{const{handleChange:e,name:t,inputText:o,inputType:s,options:a,value:i,component:n}=this.props,{disabled:c}=this.state;switch(s){case"checkboxGroup":return a.map((e=>e.options.length>0&&(0,h.jsxs)("div",{className:"woocommerce-setting__options-group","aria-labelledby":t+"-label",children:[e.label&&(0,h.jsx)("span",{className:"woocommerce-setting__options-group-label",children:e.label}),this.renderCheckboxOptions(e.options)]},e.key)));case"checkbox":return this.renderCheckboxOptions(a);case"button":return(0,h.jsx)(r.Button,{variant:"secondary",onClick:this.handleInputCallback,disabled:c,children:o});case"component":const s=n;return(0,h.jsx)(s,{value:i,onChange:e,...this.props});case"select":return(0,h.jsx)(r.SelectControl,{options:a,value:i,onChange:o=>e({target:{name:t,type:"select",value:o}})});case"radio":return(0,h.jsx)(r.RadioControl,{selected:i,options:a,onChange:o=>e({target:{name:t,type:"radio",value:o}})});default:const l=(0,p.uniqueId)(t);return(0,h.jsx)("input",{id:l,type:"text",name:t,onChange:e,value:i,placeholder:o,disabled:c})}};handleInputCallback=()=>{const{createNotice:e,callback:t}=this.props;if("function"==typeof t)return new Promise(((o,s)=>{this.setState({disabled:!0}),t(o,s,e)})).then((()=>{this.setState({disabled:!1})})).catch((()=>{this.setState({disabled:!1})}))};renderCheckboxOptions(e){const{handleChange:t,name:o,value:s}=this.props,{disabled:a}=this.state;return e.map((e=>(0,h.jsx)(r.CheckboxControl,{label:e.label,name:o,checked:s&&s.includes(e.value),onChange:s=>t({target:{checked:s,name:o,type:"checkbox",value:e.value}}),disabled:a},o+"-"+e.value)))}render(){const{helpText:e,label:t,name:o}=this.props;return(0,h.jsxs)("div",{className:"woocommerce-setting",children:[(0,h.jsx)("div",{className:"woocommerce-setting__label",id:o+"-label",children:t}),(0,h.jsxs)("div",{className:"woocommerce-setting__input",children:[this.renderInput(),e&&(0,h.jsx)("span",{className:"woocommerce-setting__help",children:e})]})]})}}const g=(0,i.compose)((0,n.withDispatch)((e=>{const{createNotice:t}=e("core/notices");return{createNotice:t}})))(u);var _=o(76154),w=o.n(_);const v=(e,t,o)=>{const s={};if(o&&(s.skip_existing=!0),"all"!==t.label)if("custom"===t.label){const o=w()().diff(w()(t.date,e),"days",!0);s.days=Math.floor(o)}else s.days=parseInt(t.label,10);return s};var S=o(93832);const I=(0,i.compose)([(0,n.withSelect)((e=>{const{getFormSettings:t}=e(l.importStore),{period:o,skipPrevious:s}=t();return{selectedPeriod:o,skipChecked:s}})),(0,n.withDispatch)((e=>{const{updateImportation:t,setImportStarted:o}=e(l.importStore),{createNotice:s}=e("core/notices");return{createNotice:s,setImportStarted:o,updateImportation:t}}))])((function({clearStatusAndTotalsCache:e,createNotice:t,dateFormat:o,importDate:i,onImportStarted:n,selectedPeriod:c,stopImport:l,skipChecked:d,status:p,setImportStarted:u,updateImportation:g}){const _=(e,o,s=!1)=>{g(e,s).then((e=>{"success"===e.status?t("success",e.message):(t("error",o),u(!1),l())})).catch((e=>{e&&e.message&&(t("error",e.message),u(!1),l())}))},w=()=>{const e=(0,S.addQueryArgs)("/wc-analytics/reports/import",v(o,c,d)),t=(0,s.__)("There was a problem rebuilding your report data.","woocommerce");_(e,t,!0),n()},I=()=>{l();const e=(0,s.__)("There was a problem stopping your current import.","woocommerce");_("/wc-analytics/reports/import/cancel",e)},b=()=>{const e=(0,s.__)("There was a problem deleting your previous data.","woocommerce");_("/wc-analytics/reports/import/delete",e),(0,m.recordEvent)("analytics_import_delete_previous"),u(!1)},x=()=>{u(!1),e()};return(0,h.jsx)("div",{className:"woocommerce-settings__actions woocommerce-settings-historical-data__actions",children:(()=>{const e="ready"!==p;return["initializing","customers","orders","finalizing"].includes(p)?(0,h.jsxs)(a.Fragment,{children:[(0,h.jsx)(r.Button,{className:"woocommerce-settings-historical-data__action-button",isPrimary:!0,onClick:I,children:(0,s.__)("Stop Import","woocommerce")}),(0,h.jsxs)("div",{className:"woocommerce-setting__help woocommerce-settings-historical-data__action-help",children:[(0,s.__)("Imported data will not be lost if the import is stopped.","woocommerce"),(0,h.jsx)("br",{}),(0,s.__)("Navigating away from this page will not affect the import.","woocommerce")]})]}):["ready","nothing"].includes(p)?i?(0,h.jsxs)(a.Fragment,{children:[(0,h.jsx)(r.Button,{isPrimary:!0,onClick:w,disabled:e,children:(0,s.__)("Start","woocommerce")}),(0,h.jsx)(r.Button,{isSecondary:!0,onClick:b,children:(0,s.__)("Delete Previously Imported Data","woocommerce")})]}):(0,h.jsx)(a.Fragment,{children:(0,h.jsx)(r.Button,{isPrimary:!0,onClick:w,disabled:e,children:(0,s.__)("Start","woocommerce")})}):("error"===p&&t("error",(0,s.__)("Something went wrong with the importation process.","woocommerce")),(0,h.jsxs)(a.Fragment,{children:[(0,h.jsx)(r.Button,{isSecondary:!0,onClick:x,children:(0,s.__)("Re-import Data","woocommerce")}),(0,h.jsx)(r.Button,{isSecondary:!0,onClick:b,children:(0,s.__)("Delete Previously Imported Data","woocommerce")})]}))})()})}));var b=o(77374);const x=(0,n.withDispatch)((e=>{const{setImportPeriod:t}=e(l.importStore);return{setImportPeriod:t}}))((function({dateFormat:e,disabled:t,setImportPeriod:o,value:a}){const i=t=>{const s=!0;t.date&&t.date.isValid?o(t.date.format(e),s):o(t.text,s)},n=t=>t.isValid()&&a.date.length===e.length?t.isAfter(new Date,"day")?b.dateValidationMessages.future:null:b.dateValidationMessages.invalid;return(0,h.jsxs)("div",{className:"woocommerce-settings-historical-data__columns",children:[(0,h.jsx)("div",{className:"woocommerce-settings-historical-data__column",children:(0,h.jsx)(r.SelectControl,{label:(0,s.__)("Import historical data","woocommerce"),value:a.label,disabled:t,onChange:e=>{o(e)},options:[{label:"All",value:"all"},{label:"Last 365 days",value:"365"},{label:"Last 90 days",value:"90"},{label:"Last 30 days",value:"30"},{label:"Last 7 days",value:"7"},{label:"Last 24 hours",value:"1"},{label:"Custom",value:"custom"}]})}),"custom"===a.label&&(()=>{const o=w()(a.date,e);return(0,h.jsxs)("div",{className:"woocommerce-settings-historical-data__column",children:[(0,h.jsx)("div",{className:"woocommerce-settings-historical-data__column-label",children:(0,s.__)("Beginning on","woocommerce")}),(0,h.jsx)(c.DatePicker,{date:o.isValid()?o.toDate():null,dateFormat:e,disabled:t,error:n(o),isInvalidDate:e=>w()(e).isAfter(new Date,"day"),onUpdate:i,text:a.date})]})})()]})})),C=function({label:e,progress:t,total:o}){const r=(0,s.sprintf)((0,s.__)("Imported %(label)s","woocommerce"),{label:e}),a=(0,p.isNil)(o)?null:(0,s.sprintf)((0,s.__)("%(progress)s of %(total)s","woocommerce"),{progress:t||0,total:o});return(0,h.jsxs)("div",{className:"woocommerce-settings-historical-data__progress",children:[(0,h.jsx)("span",{className:"woocommerce-settings-historical-data__progress-label",children:r}),a&&(0,h.jsx)("span",{className:"woocommerce-settings-historical-data__progress-label",children:a}),(0,h.jsx)("progress",{className:"woocommerce-settings-historical-data__progress-bar",max:o,value:t||0})]})};var k=o(52619);const j=function({importDate:e,status:t}){const o=(0,k.applyFilters)("woocommerce_admin_import_status",{nothing:(0,s.__)("Nothing To Import","woocommerce"),ready:(0,s.__)("Ready To Import","woocommerce"),initializing:[(0,s.__)("Initializing","woocommerce"),(0,h.jsx)(r.Spinner,{},"spinner")],customers:[(0,s.__)("Importing Customers","woocommerce"),(0,h.jsx)(r.Spinner,{},"spinner")],orders:[(0,s.__)("Importing Orders","woocommerce"),(0,h.jsx)(r.Spinner,{},"spinner")],finalizing:[(0,s.__)("Finalizing","woocommerce"),(0,h.jsx)(r.Spinner,{},"spinner")],finished:-1===e?(0,s.__)("All historical data imported","woocommerce"):(0,s.sprintf)((0,s.__)("Historical data from %s onward imported","woocommerce"),w()(e).format("YYYY-MM-DD"))});return(0,h.jsxs)("span",{className:"woocommerce-settings-historical-data__status",children:[(0,s.__)("Status:","woocommerce")+" ",o[t]]})},y=(0,n.withDispatch)((e=>{const{setSkipPrevious:t}=e(l.importStore);return{setSkipPrevious:t}}))((function({checked:e,disabled:t,setSkipPrevious:o}){return(0,h.jsx)(r.CheckboxControl,{className:"woocommerce-settings-historical-data__skip-checkbox",checked:e,disabled:t,label:(0,s.__)("Skip previously imported customers and orders","woocommerce"),onChange:e=>{o(e)}})}));class f extends a.Component{render(){const{customersProgress:e,customersTotal:t,dateFormat:o,importDate:r,inProgress:i,lastImportStartTimestamp:n,clearStatusAndTotalsCache:l,ordersProgress:m,ordersTotal:d,onImportStarted:p,period:u,stopImport:g,skipChecked:_,status:w}=this.props;return(0,h.jsxs)(a.Fragment,{children:[(0,h.jsx)(c.SectionHeader,{title:(0,s.__)("Import historical data","woocommerce")}),(0,h.jsx)("div",{className:"woocommerce-settings__wrapper",children:(0,h.jsx)("div",{className:"woocommerce-setting",children:(0,h.jsxs)("div",{className:"woocommerce-setting__input",children:[(0,h.jsx)("span",{className:"woocommerce-setting__help",children:(0,s.__)("This tool populates historical analytics data by processing customers and orders created prior to activating WooCommerce Admin.","woocommerce")}),"finished"!==w&&(0,h.jsxs)(a.Fragment,{children:[(0,h.jsx)(x,{dateFormat:o,disabled:i,value:u}),(0,h.jsx)(y,{disabled:i,checked:_}),(0,h.jsx)(C,{label:(0,s.__)("Registered Customers","woocommerce"),progress:e,total:t}),(0,h.jsx)(C,{label:(0,s.__)("Orders and Refunds","woocommerce"),progress:m,total:d})]}),(0,h.jsx)(j,{importDate:r,status:w})]})})}),(0,h.jsx)(I,{clearStatusAndTotalsCache:l,dateFormat:o,importDate:r,lastImportStartTimestamp:n,onImportStarted:p,stopImport:g,status:w})]})}}const N=(0,n.withSelect)(((e,t)=>{const{getImportError:o,getImportStatus:s,getImportTotals:r}=e(l.importStore),{activeImport:a,cacheNeedsClearing:i,dateFormat:n,inProgress:c,onImportStarted:m,onImportFinished:d,period:h,startStatusCheckInterval:u,skipChecked:g}=t,_=v(n,h,g),{customers:w,orders:S,lastImportStartTimestamp:I}=r(_),{customers:b,imported_from:x,is_importing:C,orders:k}=s(I),{imported:j,total:y}=b||{},{imported:f,total:N}=k||{},T=Boolean(o(I)||o(_));Boolean(!I&&!c&&!0===C)&&m();const P=Boolean(c&&!i&&!1===C&&(y>0||N>0)&&j===y&&f===N);let F={customersTotal:w,isError:T,ordersTotal:S};a&&(F={cacheNeedsClearing:i,customersProgress:j,customersTotal:(0,p.isNil)(y)?w:y,inProgress:c,isError:T,ordersProgress:f,ordersTotal:(0,p.isNil)(N)?S:N});const D=(({cacheNeedsClearing:e,customersProgress:t,customersTotal:o,isError:s,inProgress:r,ordersProgress:a,ordersTotal:i})=>s?"error":r?(0,p.isNil)(t)||(0,p.isNil)(a)||(0,p.isNil)(o)||(0,p.isNil)(i)||e?"initializing":t<o?"customers":a<i?"orders":"finalizing":o>0||i>0?t===o&&a===i?"finished":"ready":"nothing")(F);return"initializing"===D&&u(),P&&d(),{...F,importDate:x,status:D}}))(f);class T extends a.Component{constructor(){super(...arguments),this.dateFormat=(0,s.__)("MM/DD/YYYY","woocommerce"),this.intervalId=-1,this.lastImportStopTimestamp=0,this.cacheNeedsClearing=!0,this.onImportFinished=this.onImportFinished.bind(this),this.onImportStarted=this.onImportStarted.bind(this),this.clearStatusAndTotalsCache=this.clearStatusAndTotalsCache.bind(this),this.stopImport=this.stopImport.bind(this),this.startStatusCheckInterval=this.startStatusCheckInterval.bind(this),this.cancelStatusCheckInterval=this.cancelStatusCheckInterval.bind(this)}startStatusCheckInterval(){this.intervalId<0&&(this.cacheNeedsClearing=!0,this.intervalId=setInterval((()=>{this.clearCache("getImportStatus")}),3*l.SECOND))}cancelStatusCheckInterval(){clearInterval(this.intervalId),this.intervalId=-1}clearCache(e,t){const{invalidateResolution:o,lastImportStartTimestamp:s}=this.props;o(e,["getImportStatus"===e?s:t]).then((()=>{this.cacheNeedsClearing=!1}))}stopImport(){this.cancelStatusCheckInterval(),this.lastImportStopTimestamp=Date.now()}onImportFinished(){const{debouncedSpeak:e}=this.props;this.cacheNeedsClearing||(e("Import complete"),this.stopImport())}onImportStarted(){const{notes:e,setImportStarted:t,updateNote:o}=this.props,s=e.find((e=>"wc-admin-historical-data"===e.name));s&&o(s.id,{status:"actioned"}),t(!0)}clearStatusAndTotalsCache(){const{selectedPeriod:e,skipChecked:t}=this.props,o=v(this.dateFormat,e,t);this.clearCache("getImportTotals",o),this.clearCache("getImportStatus")}isImportationInProgress(){const{lastImportStartTimestamp:e}=this.props;return void 0!==e&&void 0===this.lastImportStopTimestamp||e>this.lastImportStopTimestamp}render(){const{activeImport:e,createNotice:t,lastImportStartTimestamp:o,selectedPeriod:s,skipChecked:r}=this.props;return(0,h.jsx)(N,{activeImport:e,cacheNeedsClearing:this.cacheNeedsClearing,createNotice:t,dateFormat:this.dateFormat,inProgress:this.isImportationInProgress(),onImportFinished:this.onImportFinished,onImportStarted:this.onImportStarted,lastImportStartTimestamp:o,clearStatusAndTotalsCache:this.clearStatusAndTotalsCache,period:s,skipChecked:r,startStatusCheckInterval:this.startStatusCheckInterval,stopImport:this.stopImport})}}const P=(0,i.compose)([(0,n.withSelect)((e=>{const{getNotes:t}=e(l.notesStore),{getImportStarted:o,getFormSettings:s}=e(l.importStore),r=t({page:1,per_page:l.QUERY_DEFAULTS.pageSize,type:"update",status:"unactioned"}),{activeImport:a,lastImportStartTimestamp:i}=o(),{period:n,skipPrevious:c}=s();return{activeImport:a,lastImportStartTimestamp:i,notes:r,selectedPeriod:n,skipChecked:c}})),(0,n.withDispatch)((e=>{const{updateNote:t}=e(l.notesStore),{invalidateResolution:o,setImportStarted:s}=e(l.importStore);return{invalidateResolution:o,setImportStarted:s,updateNote:t}})),r.withSpokenMessages])(T),F=({isOpen:e,onClose:t,onConfirm:o})=>e?(0,h.jsx)(r.Modal,{title:(0,s.__)("Are you sure?","woocommerce"),onRequestClose:t,className:"woocommerce-analytics-import-mode-confirmation-modal",size:"medium",children:(0,h.jsxs)(r.Flex,{direction:"column",gap:6,children:[(0,h.jsx)(r.__experimentalText,{children:(0,s.__)("Immediate updates to Analytics can impact your performance as it may slow busy stores.","woocommerce")}),(0,h.jsxs)(r.Flex,{direction:"row",className:"woocommerce-analytics-import-mode-confirmation-modal__buttons",justify:"flex-end",children:[(0,h.jsx)(r.Button,{variant:"tertiary",onClick:t,"aria-label":(0,s.__)("Cancel import mode change","woocommerce"),children:(0,s.__)("Cancel","woocommerce")}),(0,h.jsx)(r.Button,{variant:"primary",onClick:o,"aria-label":(0,s.__)("Confirm switching to immediate import mode","woocommerce"),children:(0,s.__)("Confirm","woocommerce")})]})]})}):null,D=(0,i.compose)((0,n.withDispatch)((e=>{const{createNotice:t}=e("core/notices");return{createNotice:t}})))((({createNotice:e,query:t})=>{const{settingsError:o,isRequesting:i,isDirty:n,persistSettings:p,updateAndPersistSettings:u,updateSettings:_,wcAdminSettings:w}=(0,l.useSettings)("wc_admin",["wcAdminSettings"]),v=(0,a.useRef)(!1),[S,I]=(0,a.useState)(!1),[b,x]=(0,a.useState)(null);(0,a.useEffect)((()=>{function e(e){if(n)return e.returnValue=(0,s.__)("You have unsaved changes. If you proceed, they will be lost.","woocommerce"),e.returnValue}return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)}),[n]),(0,a.useEffect)((()=>{i?v.current=!0:!i&&v.current&&(o?e("error",(0,s.__)("There was an error saving your settings. Please try again.","woocommerce")):e("success",(0,s.__)("Your settings have been successfully saved.","woocommerce")),v.current=!1)}),[i,o,e]);const C=e=>{if(S)return;const{checked:t,name:o,type:s,value:r}=e.target;if(o===d.zm&&d.$W[d.zm]&&"yes"===w[o]&&"no"===r)return x({name:o,value:r}),void I(!0);const a={...w};a[o]="checkbox"===s?t?[...a[o],r]:a[o].filter((e=>e!==r)):r,_("wcAdminSettings",a)},k=e=>e!==d.zm||w[e]?w[e]:"no";return(0,h.jsxs)(a.Fragment,{children:[(0,h.jsx)(c.SectionHeader,{title:(0,s.__)("Analytics settings","woocommerce")}),(0,h.jsxs)("div",{className:"woocommerce-settings__wrapper",children:[Object.keys(d.$W).map((e=>(0,h.jsx)(g,{handleChange:C,value:k(e),name:e,...d.$W[e]},e))),(0,h.jsxs)("div",{className:"woocommerce-settings__actions",children:[(0,h.jsx)(r.Button,{variant:"secondary",onClick:()=>{if(window.confirm((0,s.__)("Are you sure you want to reset all settings to default values?","woocommerce"))){const e=Object.keys(d.$W).reduce(((e,t)=>(e[t]=d.$W[t].defaultValue,e)),{});u("wcAdminSettings",e),(0,m.recordEvent)("analytics_settings_reset_defaults")}},children:(0,s.__)("Reset defaults","woocommerce")}),(0,h.jsx)(r.Button,{variant:"primary",isBusy:i,onClick:()=>{p(),(0,m.recordEvent)("analytics_settings_save",w),t.period=void 0,t.compare=void 0,t.before=void 0,t.after=void 0,t.interval=void 0,t.type=void 0,window.wpNavMenuUrlUpdate(t)},children:(0,s.__)("Save settings","woocommerce")})]})]}),"true"===t.import?(0,h.jsx)(c.ScrollTo,{offset:"-56",children:(0,h.jsx)(P,{createNotice:e})}):(0,h.jsx)(P,{createNotice:e}),d.$W[d.zm]&&(0,h.jsx)(F,{isOpen:S,onClose:()=>{I(!1),x(null)},onConfirm:()=>{if(b){const e={...w};e[b.name]=b.value,_("wcAdminSettings",e)}I(!1),x(null)}})]})}))}}]);
Copyright ©2021 || Defacer Indonesia