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,KAAK,EAAC;MAAZ,GAAsB,KAAKzB,KAAL,CAAW+B,SAAX,CAAqBF,KAA3C,CALJ,CAPJ,CAXJ,CADJ,CADF;IA8BD;;IACC,OAAQS,IAAR;EACD;;AAtHgC;;AAyHrC,+DAAezC,YAAf;AAEAoB,QAAQ,CAACC,gBAAT,CAA0B,kBAA1B,EAA8C,UAASP,KAAT,EAAgB;EAC1D,IAAI+B,IAAI,GAAGzB,QAAQ,CAAC0B,sBAAT,CAAgC,6CAAhC,CAAX;;EACA,IAAID,IAAI,CAACE,MAAL,GAAY,CAAhB,EAAmB;IACfC,QAAQ,CAACrD,MAAT,CAAgBJ,0DAAA,CAAoBS,YAApB,CAAhB,EAAmD6C,IAAI,CAAC,CAAD,CAAvD;EACH;AACJ,CALD,E","sources":["webpack://learndash-reports-by-wisdmlabs/./includes/blocks/src/commons/loader/index.js","webpack://learndash-reports-by-wisdmlabs/./includes/blocks/src/total-courses/index.scss?c4f9","webpack://learndash-reports-by-wisdmlabs/external window \"React\"","webpack://learndash-reports-by-wisdmlabs/external window \"moment\"","webpack://learndash-reports-by-wisdmlabs/external window [\"wp\",\"element\"]","webpack://learndash-reports-by-wisdmlabs/external window [\"wp\",\"i18n\"]","webpack://learndash-reports-by-wisdmlabs/webpack/bootstrap","webpack://learndash-reports-by-wisdmlabs/webpack/runtime/compat get default export","webpack://learndash-reports-by-wisdmlabs/webpack/runtime/define property getters","webpack://learndash-reports-by-wisdmlabs/webpack/runtime/hasOwnProperty shorthand","webpack://learndash-reports-by-wisdmlabs/webpack/runtime/make namespace object","webpack://learndash-reports-by-wisdmlabs/./includes/blocks/src/total-courses/index-total-courses.js"],"sourcesContent":["import React, { Component } from \"react\";\nimport { __ } from '@wordpress/i18n';\n\nclass WisdmLoader extends React.Component {\n\n render() {\n let loadingData = '';\n loadingData =
\n
\n
\n \n \n
\n
\n
;\n return loadingData;\n }\n }\n\n export default WisdmLoader;\n","// extracted by mini-css-extract-plugin\nexport {};","module.exports = window[\"React\"];","module.exports = window[\"moment\"];","module.exports = window[\"wp\"][\"element\"];","module.exports = window[\"wp\"][\"i18n\"];","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = function(module) {\n\tvar getter = module && module.__esModule ?\n\t\tfunction() { return module['default']; } :\n\t\tfunction() { return module; };\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = function(exports, definition) {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }","// define __esModule on exports\n__webpack_require__.r = function(exports) {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import './index.scss';\nimport React, { Component } from \"react\";\nimport WisdmLoader from '../commons/loader/index.js';\nimport moment from 'moment';\nimport { __ } from '@wordpress/i18n';\n\nclass TotalCourses extends Component {\n constructor(props) {\n super(props);\n \n this.state = {\n isLoaded: false,\n error: null,\n start_date:moment(new Date(wisdm_ld_reports_common_script_data.start_date)).unix(),\n end_date:moment(new Date(wisdm_ld_reports_common_script_data.end_date)).unix(),\n };\n\n this.durationUpdated = this.durationUpdated.bind(this);\n this.updateBlock = this.updateBlock.bind(this);\n }\n\n durationUpdated(event) {\n this.setState({start_date:event.detail.startDate, end_date:event.detail.endDate});\n this.updateBlock();\n }\n \n componentDidMount() { \n document.addEventListener('duration_updated', this.durationUpdated); \n this.updateBlock();\n }\n\n updateBlock(callback = '/rp/v1/total-courses') {\n wp.apiFetch({\n path: '/rp/v1/total-courses?start_date=' + this.state.start_date + '&end_date=' + this.state.end_date,\n }).then(response => {\n let percentChange = response.percentChange;\n let chnageDirectionClass = 'udup';\n let percentValueClass = 'change-value';\n let hideChange = '';\n let udtxt = '';\n let udsrc = '';\n if ( 0 < percentChange ) {\n chnageDirectionClass = 'udup';\n percentValueClass = 'change-value-positive';\n udtxt = __('Up', 'learndash-reports-by-wisdmlabs');\n udsrc = wisdm_learndash_reports_front_end_script_total_revenue_earned.plugin_asset_url + '/images/up.png';\n } else if( 0 > percentChange ) {\n chnageDirectionClass = 'uddown'\n percentValueClass = 'change-value-negative';\n udtxt = __('Down', 'learndash-reports-by-wisdmlabs');\n udsrc = wisdm_learndash_reports_front_end_script_total_revenue_earned.plugin_asset_url + '/images/down.png';\n } else if( 0 == percentChange ){\n hideChange = 'wrld-hidden';\n udtxt = __('Up', 'learndash-reports-by-wisdmlabs');\n udsrc = wisdm_learndash_reports_front_end_script_total_revenue_earned.plugin_asset_url + '/images/up.png';\n }\n this.setState(\n {\n isLoaded: true,\n graphData: {\n totalCourses: response.totalCourses,\n percentChange: percentChange + '%',\n chnageDirectionClass:chnageDirectionClass,\n percentValueClass:percentValueClass,\n hideChange: hideChange,\n udtxt: udtxt,\n udsrc: udsrc\n },\n startDate: moment.unix(response.requestData.start_date).format(\"MMM, DD YYYY\"),\n endDate: moment.unix(response.requestData.end_date).format(\"MMM, DD YYYY\"),\n });\n }).catch((error) => {\n this.setState({\n error:error,\n graph_summary:[],\n isLoaded: true,\n series:[],\n });\n });\n }\n \n render() {\n let body =
;\n if (!this.state.isLoaded) {\n // yet loading\n body = ;\n } else if (this.state.error) {\n // error\n body =
\n
{this.state.error.message}
\n
;\n } else {\n body = \n
\n
\n
\n \n
\n {__('Date filter applied:', 'learndash-reports-by-wisdmlabs')}
{this.state.startDate} - {this.state.endDate}\n
\n
\n
\n \n \n
\n
\n
\n {__('Total','learndash-reports-by-wisdmlabs') + ' ' + wisdm_reports_get_ld_custom_lebel_if_avaiable('courses')}\n
\n
\n {this.state.graphData.totalCourses}\n
\n
\n \n \n \n {this.state.graphData.percentChange}\n {this.state.graphData.udtxt}\n
\n
\n
\n
;\n }\n return (body);\n }\n }\n\nexport default TotalCourses;\n\ndocument.addEventListener(\"DOMContentLoaded\", function(event) {\n let elem = document.getElementsByClassName('wisdm-learndash-reports-total-courses front');\n if (elem.length>0) {\n ReactDOM.render(React.createElement(TotalCourses), elem[0]); \n }\n});\n\n"],"names":["React","Component","__","WisdmLoader","render","loadingData","wisdm_learndash_reports_front_end_script_total_revenue_earned","plugin_asset_url","moment","TotalCourses","constructor","props","state","isLoaded","error","start_date","Date","wisdm_ld_reports_common_script_data","unix","end_date","durationUpdated","bind","updateBlock","event","setState","detail","startDate","endDate","componentDidMount","document","addEventListener","callback","wp","apiFetch","path","then","response","percentChange","chnageDirectionClass","percentValueClass","hideChange","udtxt","udsrc","graphData","totalCourses","requestData","format","catch","graph_summary","series","body","message","wisdm_learndash_reports_front_end_script_total_courses","wisdm_reports_get_ld_custom_lebel_if_avaiable","elem","getElementsByClassName","length","ReactDOM","createElement"],"sourceRoot":""}