import{r as i,d as o,B as l,h as n}from"./p-03169580.js";import{t as d}from"./p-3bc4f2ce.js";import"./p-4cb16df5.js";import"./p-f44f0a67.js";const e="";let t=class{constructor(l){i(this,l);this.fireenjinFetch=o(this,"fireenjinFetch",7);this.payModel={}}async onSuccess(i){var o,l,n,d,e,t;if(i.detail.endpoint==="addPayModel"){const d=document.querySelector("ion-router");if(!d||!((n=(l=(o=i===null||i===void 0?void 0:i.detail)===null||o===void 0?void 0:o.data)===null||l===void 0?void 0:l.addPayModel)===null||n===void 0?void 0:n.id))return;d.push(`/paymodels/${i.detail.data.addPayModel.id}`)}else if(i.detail.endpoint==="editPayModel"){this.presentToast()}else if(i.detail.endpoint==="findPayModel"){this.payModel=((t=(e=(d=i===null||i===void 0?void 0:i.detail)===null||d===void 0?void 0:d.data)===null||e===void 0?void 0:e.findPayModel)===null||t===void 0?void 0:t.payModel)||{}}}async presentToast(){const i=await d.create({message:"The pay model has been updated.",duration:2e3});i.present()}async fetchData(){this.fireenjinFetch.emit({endpoint:"findPayModel",id:this.payModelId})}async componentDidLoad(){if(!(l===null||l===void 0?void 0:l.isBrowser))return;if(this.payModelId&&(l===null||l===void 0?void 0:l.isBrowser)){this.fetchData()}}render(){var i,o,l;return[n("ion-content",{scrollEvents:true,class:"ion-padding"},n("floodteam-title-bar",null,n("ion-router-link",{href:"/paymodels"},"Pay Models")),n("ion-card",{class:"ion-padding"},n("fireenjin-form",{endpoint:this.payModelId==="new"?"addPayModel":"editPayModel",documentId:this.payModelId==="new"?null:this.payModelId,resetButton:null},n("ion-list",null,n("ion-grid",null,n("ion-row",null,n("ion-col",null,n("fireenjin-input",{name:"firstName",label:"First Name",value:(i=this.payModel)===null||i===void 0?void 0:i.name})),n("ion-col",null,n("h2",null,"Payout Roles"),n("ion-list",null,((l=(o=this.payModel)===null||o===void 0?void 0:o.payouts)===null||l===void 0?void 0:l.length)?this.payModel.payouts.map((i=>{var o,l;return n("ion-item",null,((o=i===null||i===void 0?void 0:i.role)===null||o===void 0?void 0:o.name)?(l=i===null||i===void 0?void 0:i.role)===null||l===void 0?void 0:l.name:"No Role Name")})):null)))))))),n("floodteam-navigation-footer",null)]}};t.style=e;export{t as app_paymodel};
//# sourceMappingURL=p-0e797a87.entry.js.map