import{r as o,d as i,B as l,h as n}from"./p-f8363b1b.js";import{t as d}from"./p-510e3bc9.js";import"./p-d2ac57a0.js";import"./p-f44f0a67.js";const e=class{constructor(l){o(this,l),this.fireenjinFetch=i(this,"fireenjinFetch",7),this.payModel={}}async onSuccess(o){var i,l,n,d,e,t;if("addPayModel"===o.detail.endpoint){const d=document.querySelector("ion-router");if(!d||!(null===(n=null===(l=null===(i=null==o?void 0:o.detail)||void 0===i?void 0:i.data)||void 0===l?void 0:l.addPayModel)||void 0===n?void 0:n.id))return;d.push(`/paymodels/${o.detail.data.addPayModel.id}`)}else"editPayModel"===o.detail.endpoint?this.presentToast():"findPayModel"===o.detail.endpoint&&(this.payModel=(null===(t=null===(e=null===(d=null==o?void 0:o.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 o,i,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===(o=this.payModel)||void 0===o?void 0:o.name})),n("ion-col",null,n("h2",null,"Payout Roles"),n("ion-list",null,(null===(l=null===(i=this.payModel)||void 0===i?void 0:i.payouts)||void 0===l?void 0:l.length)?this.payModel.payouts.map((o=>{var i,l;return n("ion-item",null,(null===(i=null==o?void 0:o.role)||void 0===i?void 0:i.name)?null===(l=null==o?void 0:o.role)||void 0===l?void 0:l.name:"No Role Name")})):null)))))))),n("floodteam-navigation-footer",null)]}};e.style="";export{e as app_paymodel}