1"use strict";(self.webpackChunkfrontend=self.webpackChunkfrontend||[]).push([[1213],{51213(T,_,p){p.d(_,{CorporateDiscountsPageComponent:()=>V});var r=p(54049),d=p(48065),c=p(48015),u=p(12219),m=p(77997),h=p(12896),f=p(15075);let C=(()=>{var e;class s{constructor(){this.url="/api/editable_corporate_discounts",this.http=(0,r.WQX)(f.Qq)}query(){return this.http.get(this.url)}create(o){return this.http.post(this.url,o)}update(o){return this.http.patch(`${this.url}/${o.id}`,o)}delete(o){return this.http.delete(`${this.url}/${o}`)}}return(e=s).\u0275fac=function(o){return new(o||e)},e.\u0275prov=r.jDH({token:e,factory:e.\u0275fac,providedIn:"root"}),s})();var t=p(11525);const k=(e,s)=>s.key;function g(e,s){1&e&&(t.j41(0,"div",5),t.nrm(1,"i",6),t.k0s())}function v(e,s){if(1&e&&(t.j41(0,"div"),t.EFF(1),t.k0s()),2&e){const n=t.XpG().$implicit;t.R7$(),t.JRh(n.form.controls.company_name.value)}}function b(e,s){if(1&e&&(t.j41(0,"div"),t.nrm(1,"input",19),t.k0s()),2&e){const n=t.XpG().$implicit;t.AVh("has-error",n.form.controls.company_name.invalid)}}function y(e,s){if(1&e&&(t.j41(0,"div"),t.EFF(1),t.k0s()),2&e){const n=t.XpG().$implicit;t.R7$(),t.JRh(n.form.controls.link_for_6crickets.value)}}function D(e,s){if(1&e&&(t.j41(0,"div"),t.nrm(1,"input",20),t.k0s()),2&e){const n=t.XpG().$implicit;t.AVh("has-error",n.form.controls.link_for_6crickets.invalid)}}function x(e,s){if(1&e&&(t.j41(0,"div"),t.EFF(1),t.k0s()),2&e){const n=t.XpG().$implicit;t.R7$(),t.JRh(n.form.controls.discount_code.value)}}function j(e,s){if(1&e&&(t.j41(0,"div"),t.nrm(1,"input",21),t.k0s()),2&e){const n=t.XpG().$implicit;t.AVh("has-error",n.form.controls.discount_code.invalid)}}function F(e,s){if(1&e){const n=t.RV6();t.j41(0,"button",22),t.bIt("click",function(){r.eBV(n);const i=t.XpG().$implicit,a=t.XpG(2);return r.Njj(a.edit(i))}),t.nrm(1,"i",23),t.k0s()}}function R(e,s){1&e&&(t.j41(0,"span",15),t.nrm(1,"i",24),t.k0s())}function w(e,s){if(1&e){const n=t.RV6();t.j41(0,"button",25),t.bIt("click",function(){r.eBV(n);const i=t.XpG().$implicit,a=t.XpG(2);return r.Njj(a.stopEditing(i))}),t.nrm(1,"i",24),t.k0s()}}function P(e,s){if(1&e){const n=t.RV6();t.j41(0,"button",25),t.bIt("click",function(){r.eBV(n);const i=t.XpG().$implicit,a=t.XpG(2);return r.Njj(a.save(i))}),t.nrm(1,"i",24),t.k0s()}}function $(e,s){if(1&e){const n=t.RV6();t.j41(0,"tr",10)(1,"td"),t.nVh(2,v,2,1,"div")(3,b,2,2,"div",13),t.k0s(),t.j41(4,"td"),t.nVh(5,y,2,1,"div")(6,D,2,2,"div",13),t.k0s(),t.j41(7,"td"),t.nVh(8,x,2,1,"div")(9,j,2,2,"div",13),t.k0s(),t.j41(10,"td"),t.nVh(11,F,2,0,"button",14)(12,R,2,0,"span",15)(13,w,2,0,"button",16)(14,P,2,0,"button",16),t.j41(15,"button",17),t.bIt("click",function(){const i=r.eBV(n).$implicit,a=t.XpG(2);return r.Njj(a.onDelete(i))}),t.nrm(16,"i",18),t.k0s()()()}if(2&e){const n=s.$implicit;t.Y8G("formGroup",n.form),t.R7$(2),t.vxM(n.editable?3:2),t.R7$(3),t.vxM(n.editable?6:5),t.R7$(3),t.vxM(n.editable?9:8),t.R7$(3),t.vxM(n.editable?n.form.invalid?12:n.form.dirty?14:13:11)}}function X(e,s){if(1&e){const n=t.RV6();t.j41(0,"div",7)(1,"table",8)(2,"thead")(3,"tr")(4,"th"),t.EFF(5,"Company Name"),t.k0s(),t.j41(6,"th"),t.EFF(7,"Link For 6crickets"),t.k0s(),t.j41(8,"th"),t.EFF(9,"Discount Code"),t.k0s(),t.nrm(10,"th",9),t.k0s()(),t.j41(11,"tbody"),t.Z7z(12,$,17,5,"tr",10,k),t.k0s()()(),t.j41(14,"div",11)(15,"button",12),t.bIt("click",function(){r.eBV(n);const i=t.XpG();return r.Njj(i.addDiscount())}),t.EFF(16," Add New Corporate Discount "),t.k0s()()}if(2&e){const n=t.XpG();t.R7$(12),t.Dyx(n.rows())}}let V=(()=>{var e;class s{constructor(){this.api=(0,r.WQX)(C),this.fb=(0,r.WQX)(c.ok),this.toastr=(0,r.WQX)(u.t),this.confirmation=(0,r.WQX)(m.Y),this.destroyRef=(0,r.WQX)(r.abz),this.loading=(0,r.vPA)(!0),this.loaded=(0,r.vPA)(!1),this.rows=(0,r.vPA)([]),this.nextKey=0}ngOnInit(){this.api.query().pipe((0,d.pQ)(this.destroyRef)).subscribe({next:o=>{this.rows.set(o.map(i=>this.toRow(i,!1))),this.loading.set(!1),this.loaded.set(!0)},error:()=>{this.loading.set(!1),this.toastr.error("Something went wrong. Please reload the page and try again.")}})}addDiscount(){const o=this.toRow({id:null,company_name:"",link_for_6crickets:"http://",discount_code:""},!0);this.rows.update(i=>[...i,o])}edit(o){this.patchRow(o,{editable:!0})}stopEditing(o){this.patchRow(o,{editable:!1})}save(o){const i=this.payloadFor(o);(null===o.id?this.api.create(i):this.api.update(i)).pipe((0,d.pQ)(this.destroyRef)).subscribe({next:l=>{this.replaceRow(o,this.toRow(l,!1,o.key)),this.toastr.success("Corporate discount saved.")},error:l=>{this.toastr.error("Error occurred: "+JSON.stringify(l.error))}})}onDelete(o){null!==o.id?this.confirmation.openYesNoModal({title:"Deleting a Corporate Discount",text:"Are you sure you want to delete this corporate discount?",yesCallback:()=>this.deleteSaved(o)}):this.removeRow(o)}deleteSaved(o){null!==o.id&&this.api.delete(o.id).pipe((0,d.pQ)(this.destroyRef)).subscribe({next:()=>{this.removeRow(o),this.toastr.success("Corporate discount deleted.")},error:i=>{this.toastr.error("Error occurred: "+JSON.stringify(i.error))}})}toRow(o,i,a=this.nextKey++){return{key:a,id:o.id,editable:i,form:this.fb.nonNullable.group({company_name:[o.company_name,c.k0.required],link_for_6crickets:[o.link_for_6crickets,[c.k0.required,(0,h._)()]],discount_code:[o.discount_code,c.k0.required]})}}payloadFor(o){const i=o.form.getRawValue();return{id:o.id,company_name:i.company_name,link_for_6crickets:i.link_for_6crickets,discount_code:i.discount_code}}patchRow(o,i){this.rows.update(a=>a.map(l=>l.key===o.key?{...l,...i}:l))}replaceRow(o,i){this.rows.update(a=>a.map(l=>l.key===o.key?i:l))}removeRow(o){this.rows.update(i=>i.filter(a=>a.key!==o.key))}}return(e=s).\u0275fac=function(o){return new(o||e)},e.\u0275cmp=t.VBU({type:e,selectors:[["ec-superuser-corporate-discounts-page"]],decls:9,vars:2,consts:[[1,"page-header","custom","larger"],[1,"container"],[1,"page-title","with-icon"],["aria-hidden","true",1,"page-title-icon","fa","fa-tag","fa-flip-horizontal","first-color"],[1,"main-container-wrapper"],[2,"text-align","center"],[1,"ec-spinner"],[1,"table-responsive"],[1,"table","table-bordered","mb0"],[2,"width","100px"],[3,"formGroup"],[1,"mt10","mb30"],["type","button",1,"btn","btn-default",3,"click"],[3,"has-error"],["type","button",1,"icon-btn"],[1,"text-muted",2,"cursor","not-allowed"],["type","button",1,"icon-btn","text-success"],["type","button",1,"icon-btn","text-danger",3,"click"],[1,"left-icon","glyphicon","glyphicon-trash"],["type","text","formControlName","company_name",1,"form-control"],["type","text","formControlName","link_for_6crickets",1,"form-control"],["type","text","formControlName","discount_code",1,"form-control"],["type","button",1,"icon-btn",3,"click"],[1,"left-icon","glyphicon","glyphicon-pencil"],[1,"left-icon","glyphicon","glyphicon-ok"],["type","button",1,"icon-btn","text-success",3,"click"]],template:function(o,i){1&o&&(t.j41(0,"div",0)(1,"div",1)(2,"h1",2),t.nrm(3,"i",3),t.EFF(4," Manage Corporate Discounts "),t.k0s()()(),t.j41(5,"div",4)(6,"div",1),t.nVh(7,g,2,0,"div",5),t.nVh(8,X,17,0),t.k0s()()),2&o&&(t.R
17$(7),t.vxM(i.loading()?7:-1),t.R7$(),t.vxM(!i.loading()&&i.loaded()?8:-1))},dependencies:[c.X1,c.me,c.BC,c.cb,c.j4,c.JD],styles:[".icon-btn[_ngcontent-%COMP%]{padding:0;border:none;background:none;cursor:pointer;color:inherit}"],changeDetection:0}),s})()}}]); 2//# sourceMappingURL=1213.01dc2391438a613c.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.