geno/wp-content/plugins/woocommerce/assets/client/admin/chunks/9616.js

1 line
12 KiB
JavaScript
Raw Permalink Normal View History

2024-02-01 17:24:18 +05:30
"use strict";(globalThis.webpackChunk_wcAdmin_webpackJsonp=globalThis.webpackChunk_wcAdmin_webpackJsonp||[]).push([[9616],{17666:(e,t,r)=>{r.d(t,{Z:()=>w});var o=r(69307),a=r(65736),l=r(94333),c=r(69771),s=r(9818),i=r(92819),n=r(7862),m=r.n(n),u=r(86020),d=r(67221),p=r(81921),_=r(17844),f=r(65994),y=r(10431);function g(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!e||0===e.length)return null;const o=e.slice(0),a=o.pop();if(a.showFilters(t,r)){const e=(0,y.flattenFilters)(a.filters),r=t[a.param]||a.defaultValue||"all";return(0,i.find)(e,{value:r})}return g(o,t,r)}function h(e){return t=>(0,c.format)(e,t)}class b extends o.Component{shouldComponentUpdate(e){return e.isRequesting!==this.props.isRequesting||e.primaryData.isRequesting!==this.props.primaryData.isRequesting||e.secondaryData.isRequesting!==this.props.secondaryData.isRequesting||!(0,i.isEqual)(e.query,this.props.query)}getItemChartData(){const{primaryData:e,selectedChart:t}=this.props;return e.data.intervals.map((function(e){const r={};return e.subtotals.segments.forEach((function(e){if(e.segment_label){const o=r[e.segment_label]?e.segment_label+" (#"+e.segment_id+")":e.segment_label;r[e.segment_id]={label:o,value:e.subtotals[t.key]||0}}})),{date:(0,c.format)("Y-m-d\\TH:i:s",e.date_start),...r}}))}getTimeChartData(){const{query:e,primaryData:t,secondaryData:r,selectedChart:o,defaultDateRange:a}=this.props,l=(0,p.getIntervalForQuery)(e,a),{primary:s,secondary:i}=(0,p.getCurrentDates)(e,a);return t.data.intervals.map((function(t,a){const n=(0,p.getPreviousDate)(t.date_start,s.after,i.after,e.compare,l),m=r.data.intervals[a];return{date:(0,c.format)("Y-m-d\\TH:i:s",t.date_start),primary:{label:`${s.label} (${s.range})`,labelDate:t.date_start,value:t.subtotals[o.key]||0},secondary:{label:`${i.label} (${i.range})`,labelDate:n.format("YYYY-MM-DD HH:mm:ss"),value:m&&m.subtotals[o.key]||0}}}))}getTimeChartTotals(){const{primaryData:e,secondaryData:t,selectedChart:r}=this.props;return{primary:(0,i.get)(e,["data","totals",r.key],null),secondary:(0,i.get)(t,["data","totals",r.key],null)}}renderChart(e,t,r,l){const{emptySearchResults:c,filterParam:s,interactiveLegend:i,itemsLabel:n,legendPosition:m,path:_,query:f,selectedChart:y,showHeaderControls:g,primaryData:b,defaultDateRange:w}=this.props,v=(0,p.getIntervalForQuery)(f,w),C=(0,p.getAllowedIntervalsForQuery)(f,w),S=(0,p.getDateFormatsForInterval)(v,b.data.intervals.length,{type:"php"}),R=c?(0,a.__)("No data for the current search","woocommerce"):(0,a.__)("No data for the selected date range","woocommerce"),{formatAmount:x,getCurrencyConfig:D}=this.context;return(0,o.createElement)(u.Chart,{allowedIntervals:C,data:r,dateParser:"%Y-%m-%dT%H:%M:%S",emptyMessage:R,filterParam:s,interactiveLegend:i,interval:v,isRequesting:t,itemsLabel:n,legendPosition:m,legendTotals:l,mode:e,path:_,query:f,screenReaderFormat:h(S.screenReaderFormat),showHeaderControls:g,title:y.label,tooltipLabelFormat:h(S.tooltipLabelFormat),tooltipTitle:"time-comparison"===e&&y.label||null,tooltipValueFormat:(0,d.getTooltipValueFormat)(y.type,x),chartType:(0,p.getChartTypeForQuery)(f),valueType:y.type,xFormat:h(S.xFormat),x2Format:h(S.x2Format),currency:D()})}renderItemComparison(){const{isRequesting:e,primaryData:t}=this.props;if(t.isError)return(0,o.createElement)(f.Z,null);const r=e||t.isRequesting,a=this.getItemChartData();return this.renderChart("item-comparison",r,a)}renderTimeComparison(){const{isRequesting:e,primaryData:t,secondaryData:r}=this.props;if(!t||t.isError||r.isError)return(0,o.createElement)(f.Z,null);const a=e||t.isRequesting||r.isRequesting,l=this.getTimeChartData(),c=this.getTimeChartTotals();return this.renderChart("time-comparison",a,l,c)}render(){const{mode:e}=this.props;return"item-comparison"===e?this.renderItemComparison():this.renderTimeComparison()}}b.contextType=_.CurrencyContext,b.propTypes={filters:m().array,isRequesting:m().bool,itemsLabel:m().string,limitProperties:m().array,mode:m().string,path:m().string.isRequired,primaryData:m().object,query:m().object.isRequired,secondaryData:m().object,selec