import{r as l,B as n,h as o}from"./p-f8363b1b.js";import{m as i}from"./p-405797ac.js";import{s as t}from"./p-02e053de.js";import{f as a}from"./p-5717491f.js";import"./p-d2ac57a0.js";import"./p-f44f0a67.js";import"./p-a93a14c5.js";import"./p-ccb7d102.js";import"./p-86bd3473.js";import"./p-60cf0cc2.js";const e=class{constructor(n){l(this,n),this.methodIcons={check:"create",manual:"cash",card:"card"}}onChange(l){var n;"ION-SEARCHBAR"===(null===(n=null==l?void 0:l.target)||void 0===n?void 0:n.tagName)&&(this.paginationEl.query=l.detail.value?l.detail.value:"")}formatUSD(l){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2}).format(l||0)}async openPayCalculatorModal(l,n){var o,a,e;return this.payCalculatorModalEl=await i.create({component:"modal-pay-calculator",componentProps:{amount:l,disableAmount:!0,disableReferral:!0,jobId:n,payModelId:(null===(e=null===(a=null===(o=null==t?void 0:t.profile)||void 0===o?void 0:o.location)||void 0===a?void 0:a.defaultPayModel)||void 0===e?void 0:e.id)||null}}),this.payCalculatorModalEl.present()}async componentDidLoad(){}render(){return[o("ion-content",{class:"ion-padding"},o("floodteam-title-bar",null,o("ion-router-link",{href:"/payments"},"Payments"),o("ion-buttons",{slot:"end"},o("ion-button",{fill:"solid",color:"primary",href:"/payments/new"},"Add"))),o("fireenjin-search-bar",{ref:l=>this.filterBarEl=l,paginationEl:this.paginationEl,filters:[{name:"paymodelId",label:"Pay Model",endpoint:"listPayModels",icon:"pie-chart",resultsKey:"payModels"},{name:"locationId",label:"Location",endpoint:"listLocations",value:this.locationId,icon:"business",resultsKey:"locations"},{name:"method",label:"Payment Method",icon:"pricetags",multiple:!0,options:[{label:"Check",value:"check"},{label:"Manual",value:"manual"},{label:"Card",value:"card"}]}]}),o("fireenjin-pagination",{ref:l=>this.paginationEl=l,endpoint:"listPayments",display:"list",limit:20,resultsKey:"payments",name:"payments",listEl:({result:l})=>{var n,i;return o("ion-item",null,(null==l?void 0:l.method)&&this.methodIcons[l.method]&&o("ion-icon",{slot:"start",color:"medium",name:this.methodIcons[l.method]}),o("ion-label",null,o("h2",null,null===(n=l.job)||void 0===n?void 0:n.title),o("p",null,this.formatUSD(l.amount)," paid by ",l.method),o("div",null,o("ion-button",{fill:"clear",href:`/jobs/${null===(i=l.job)||void 0===i?void 0:i.id}`,target:"_blank"},"Open Job"))),l.createdAt&&o("span",{slot:"end"},o("div",{style:{textAlign:"center"}},(null==l?void 0:l.createdAt)&&a(l.createdAt.toDate(),"MM/dd/yyyy")),o("ion-button",{style:{display:"block"},size:"small",fill:"clear",onClick:()=>{var n;return this.openPayCalculatorModal(null==l?void 0:l.amount,null===(n=null==l?void 0:l.job)||void 0===n?void 0:n.id)}},"Process",o("ion-icon",{slot:"end",name:"pie-chart"}))))}})),o("floodteam-navigation-footer",null)]}};e.style="";export{e as app_payment_list}