import{r as i,d as o,B as l,h as n}from"./p-846bd001.js";import{t as d}from"./p-9732f456.js";import"./p-18891da7.js";import"./p-8cd54418.js";const e=class{constructor(l){i(this,l),this.fireenjinFetch=o(this,"fireenjinFetch",7),this.payModelId=void 0,this.payModel={}}async onSuccess(i){var o,l,n,d,e,t;if("addPayModel"===i.detail.endpoint){const d=document.querySelector("ion-router");if(!d||!(null===(n=null===(l=null===(o=null==i?void 0:i.detail)||void 0===o?void 0:o.data)||void 0===l?void 0:l.addPayModel)||void 0===n?void 0:n.id))return;d.push(`/paymodels/${i.detail.data.addPayModel.id}`)}else"editPayModel"===i.detail.endpoint?this.presentToast():"findPayModel"===i.detail.endpoint&&(this.payModel=(null===(t=null===(e=null===(d=null==i?void 0:i.detail)||void 0===d?void 0:d.data)||void 0===e?void 0:e.findPayModel)||void 0===t?void 0:t.payModel)||{})}async presentToast(){(await d.create({message:"The pay model has been updated.",duration:2e3})).present()}async fetchData(){this.fireenjinFetch.emit({endpoint:"findPayModel",id:this.payModelId})}async componentDidLoad(){(null==l?void 0:l.isBrowser)&&this.payModelId&&(null==l?void 0:l.isBrowser)&&this.fetchData()}render(){var i,o,l;return[n("ion-content",{scrollEvents:!0,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:"new"===this.payModelId?"addPayModel":"editPayModel",documentId:"new"===this.payModelId?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:null===(i=this.payModel)||void 0===i?void 0:i.name})),n("ion-col",null,n("h2",null,"Payout Roles"),n("ion-list",null,(null===(l=null===(o=this.payModel)||void 0===o?void 0:o.payouts)||void 0===l?void 0:l.length)?this.payModel.payouts.map((i=>{var o,l;return n("ion-item",null,(null===(o=null==i?void 0:i.role)||void 0===o?void 0:o.name)?null===(l=null==i?void 0:i.role)||void 0===l?void 0:l.name:"No Role Name")})):null)))))))),n("floodteam-navigation-footer",null)]}};e.style="";export{e as app_paymodel}