import{r as l,B as o,h as i}from"./p-846bd001.js";import{m as n}from"./p-9732f456.js";import{s as t}from"./p-4ff8bb4b.js";import{f as e}from"./p-65879f9e.js";import"./p-18891da7.js";import"./p-8cd54418.js";import"./p-5cd01495.js";import"./p-259f1737.js";import"./p-ae2fb9dc.js";import"./p-dca1478c.js";const a=class{constructor(o){l(this,o),this.methodIcons={check:"create",manual:"cash",card:"card"},this.locationId=void 0,this.paginationEl=void 0}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 i,e,a;return this.payCalculatorModalEl=await n.create({component:"modal-pay-calculator",componentProps:{amount:l,disableAmount:!0,disableReferral:!0,jobId:o,payModelId:(null===(a=null===(e=null===(i=null==t?void 0:t.profile)||void 0===i?void 0:i.location)||void 0===e?void 0:e.defaultPayModel)||void 0===a?void 0:a.id)||null}}),this.payCalculatorModalEl.present()}async componentDidLoad(){}render(){return[i("ion-content",{class:"ion-padding"},i("floodteam-title-bar",null,i("ion-router-link",{href:"/payments"},"Payments"),i("ion-buttons",{slot:"end"},i("ion-button",{fill:"solid",color:"primary",href:"/payments/new"},"Add"))),i("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"}]}]}),i("fireenjin-pagination",{ref:l=>this.paginationEl=l,endpoint:"listPayments",display:"list",limit:20,resultsKey:"payments",name:"payments",listEl:({result:l})=>{var o,n;return i("ion-item",null,(null==l?void 0:l.method)&&this.methodIcons[l.method]&&i("ion-icon",{slot:"start",color:"medium",name:this.methodIcons[l.method]}),i("ion-label",null,i("h2",null,null===(o=l.job)||void 0===o?void 0:o.title),i("p",null,this.formatUSD(l.amount)," paid by ",l.method),i("div",null,i("ion-button",{fill:"clear",href:`/jobs/${null===(n=l.job)||void 0===n?void 0:n.id}`,target:"_blank"},"Open Job"))),l.createdAt&&i("span",{slot:"end"},i("div",{style:{textAlign:"center"}},(null==l?void 0:l.createdAt)&&e(l.createdAt.toDate(),"MM/dd/yyyy")),i("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",i("ion-icon",{slot:"end",name:"pie-chart"}))))}})),i("floodteam-navigation-footer",null)]}};a.style="";export{a as app_payment_list}