import{r as l,B as o,h as n}from"./p-f8363b1b.js";import{m as i}from"./p-510e3bc9.js";import{s as t}from"./p-c78d1e1b.js";import{f as e}from"./p-5717491f.js";import"./p-d2ac57a0.js";import"./p-f44f0a67.js";import"./p-3775d1fc.js";import"./p-80de33dc.js";import"./p-c2fbed0d.js";import"./p-de14d315.js";const a=class{constructor(o){l(this,o),this.methodIcons={check:"create",manual:"cash",card:"card"}}onChange(l){var o;"ION-SEARCHBAR"===(null===(o=null==l?void 0:l.target)||void 0===o?void 0:o.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,o){var n,e,a;return this.payCalculatorModalEl=await i.create({component:"modal-pay-calculator",componentProps:{amount:l,disableAmount:!0,disableReferral:!0,jobId:o,payModelId:(null===(a=null===(e=null===(n=null==t?void 0:t.profile)||void 0===n?void 0:n.location)||void 0===e?void 0:e.defaultPayModel)||void 0===a?void 0:a.id)||null}}),this.payCalculatorModalEl.present()}async componentDidLoad(){}render(){return[n("ion-content",{class:"ion-padding"},n("floodteam-title-bar",null,n("ion-router-link",{href:"/payments"},"Payments"),n("ion-buttons",{slot:"end"},n("ion-button",{fill:"solid",color:"primary",href:"/payments/new"},"Add"))),n("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"}]}]}),n("fireenjin-pagination",{ref:l=>this.paginationEl=l,endpoint:"listPayments",display:"list",limit:20,resultsKey:"payments",listEl:({result:l})=>{var o,i;return n("ion-item",null,(null==l?void 0:l.method)&&this.methodIcons[l.method]&&n("ion-icon",{slot:"start",color:"medium",name:this.methodIcons[l.method]}),n("ion-label",null,n("h2",null,null===(o=l.job)||void 0===o?void 0:o.title),n("p",null,this.formatUSD(l.amount)," paid by ",l.method),n("div",null,n("ion-button",{fill:"clear",href:`/jobs/${null===(i=l.job)||void 0===i?void 0:i.id}`,target:"_blank"},"Open Job"))),l.createdAt&&n("span",{slot:"end"},n("div",{style:{textAlign:"center"}},(null==l?void 0:l.createdAt)&&e(l.createdAt.toDate(),"MM/dd/yyyy")),n("ion-button",{style:{display:"block"},size:"small",fill:"clear",onClick:()=>{var o;return this.openPayCalculatorModal(null==l?void 0:l.amount,null===(o=null==l?void 0:l.job)||void 0===o?void 0:o.id)}},"Process",n("ion-icon",{slot:"end",name:"pie-chart"}))))}})),n("floodteam-navigation-footer",null)]}};a.style="";export{a as app_payment_list}