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