(self.webpackChunknisje=self.webpackChunknisje||[]).push([[4877],{22463:function(e,t,r){"use strict";r.r(t),r.d(t,{default:function(){return C}});var a=r(78927),n=r(6610),s=r(5991),l=r(10379),c=r(46070),o=r(77608),i=r(63027),d=r(14890),u=r(37974),h=r(63804),m=r(33804),p=r(33163),f=r(9974),v=r(2006),y=r(97011),_=r(22121),E=r(55955),b=r(37035);var g=(0,v.isFeatureActive)("learndash"),N=(0,v.getOption)("learndashEndpoint"),k=function(e){(0,l.Z)(u,e);var t,r,d=(t=u,r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,a=(0,o.Z)(t);if(r){var n=(0,o.Z)(this).constructor;e=Reflect.construct(a,arguments,n)}else e=a.apply(this,arguments);return(0,c.Z)(this,e)});function u(){var e;(0,n.Z)(this,u);for(var t=arguments.length,r=new Array(t),a=0;a<t;a++)r[a]=arguments[a];return(e=d.call.apply(d,[this].concat(r))).state={search:""},e.renderSearch=function(t){e.setState({search:t})},e.findTaxonomies=function(e,t){var r=[];return(0,m.filter)(e,(function(e){return!(0,m.isEmpty)(e)})).forEach((function(e){Array.isArray(e)&&e.forEach((function(e){e.taxonomy&&t===e.taxonomy&&r.push(e)}))})),r},e.renderCourses=function(t){return(0,i.createElement)("div",{className:"learndash-table"},(0,i.createElement)("div",{className:"learndash-table-thead"},(0,i.createElement)("span",{className:"learndash-table-td"},(0,p.__)("Title")),(0,i.createElement)("span",{className:"learndash-table-td"},(0,p.__)("Author")),(0,i.createElement)("span",{className:"learndash-table-td"},(0,p.__)("Categories")),(0,i.createElement)("span",{className:"learndash-table-td learndash-table-td-long"},(0,p.__)("Description"))),(0,i.createElement)("div",{className:"learndash-table-tbody"},t.map((function(t){if("sfwd-courses"!==t.type)return null;var r=t.id,a=t.link,n=t._embedded,s=n.author,l=t.title,c=t.excerpt,o=[],d=[];n["wp:term"]&&(o=n["wp:term"],d=e.findTaxonomies(o,"ld_course_category"));var u=s&&s[0]&&s[0].name||"";return l=l&&l.rendered||"",(c=c&&c.rendered||"")||(c=t.meta&&t.meta.teft_cards_excerpt||""),(0,i.createElement)("a",{className:"learndash-table-tr",href:a,key:r,target:"_blank",rel:"noopener noreferrer"},(0,i.createElement)("span",{className:"learndash-table-td"},l),(0,i.createElement)("span",{className:"learndash-table-td"},u),(0,i.createElement)("span",{className:"learndash-table-td"},e.renderItems(d)),(0,i.createElement)("span",{className:"learndash-table-td learndash-table-td-description learndash-table-td-long"},c))}))))},e}return(0,s.Z)(u,[{key:"noCoursesFound",value:function(){return(0,i.createElement)("div",{className:"learndash-error"},(0,i.createElement)("h3",null,(0,p.__)("No courses found")))}},{key:"renderItems",value:function(e){return!e||e.length<1?null:(0,i.createElement)("div",null,e.map((function(e,t){return(0,i.createElement)("div",{key:t},e.name)})))}},{key:"getFilterActions",value:function(){var e=this,t=this.props.match.params.termId,r=[{title:(0,p.__)("All"),href:"/learndash",isActive:!t}],n=this.props.learndashCourses,s=[];return n&&0!==Object.keys(n).length?(Object.keys(n).forEach((function(t){var r=n[t]._embedded&&n[t]._embedded["wp:term"],l=e.findTaxonomies(r,"ld_course_category");(0,m.isEmpty)(l)||(s=[].concat((0,a.Z)(s),(0,a.Z)(l)))})),(s=(0,m.uniqBy)(s,"id"))&&s.forEach((function(e){r.push({title:e.name,href:"/learndash/term/".concat(e.id),isActive:parseInt(t,10)===e.id})})),r):r}},{key:"render",value:function(){var e=this.props,t=e.noFilter,r=e.category;if(!g)return null;var a={per_page:24},n=this.state.search;if(n&&(a.search=n),0!==r)a.ld_course_category=r;else{var s=!t&&this.props.match&&this.props.match.params&&this.props.match.params.termId;s&&(a.ld_course_category=s)}return(0,i.createElement)("div",{className:"learndash wall"},N?(0,i.createElement)("div",null,!t&&(0,i.createElement)(y.Header,{title:(0,p.__)("E-learning"),onSearch:this.renderSearch,filters:this.getFilterActions().length>1?this.getFilterActions():[]}),(0,i.createElement)(b.Z,{className:"courses",dispatch:this.props.receiveLearndashCourses,loader:(0,i.createElement)(f.Loader,null),noPosts:this.noCoursesFound(),paginationPath:"/learndash",path:"".concat(N,"?_embed"),query:a,render:this.renderCourses})):(0,i.createElement)("div",{className:"learndash-error"},(0,i.createElement)("h2",null,(0,p.__)("Error")),(0,i.createElement)("p",null,(0,p.__)("Please set an external courses endpoint in the Learndash settings panel."))))}}]),u}(h.Component);k.defaultProps={learndashCourses:{},match:{},noFilter:!1,category:0};var C=(0,d.qC)((0,u.$j)((function(e){return{learndashCourses:g&&e.learndash.courses||{}}}),(function(e){return{receiveLearndashCourses:function(t){e(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{type:_.PT,payload:(0,E.Z)(e)}}(t))}}})))(k)}}]);