import{r as i,d as o,B as l,h as n}from"./p-03169580.js";import{f as t}from"./p-cf4a3445.js";import{s as e}from"./p-29293869.js";import{s,g as d}from"./p-ee5cc21c.js";import"./p-59c95c5f.js";import"./p-1930048e.js";import"./p-4d314fbd.js";function r(i,o=[],l="."){return Object.keys(i).reduce(((n,t)=>Object.assign({},n,Object.prototype.toString.call(i[t])==="[object Object]"?r(i[t],o.concat([t]),l):{[o.concat([t]).join(l)]:i[t]})),{})}function a(i,...o){const l={...i};o.forEach((function(i){delete l[i]}));return l}const v="";let u=class{constructor(l){i(this,l);this.fireenjinTrigger=o(this,"fireenjinTrigger",7);this.selectedIds=[];this.selectedServices=[];this.services=[];this.filter={tab:null}}async onSearchInput(i){this.query=i.target.value;this.services=await s(this.query)}async onTrigger(i){var o,l,n,t,e,d;if(i.detail.name==="set"&&((l=(o=i.detail)===null||o===void 0?void 0:o.payload)===null||l===void 0?void 0:l.name)){this.filter={...this.filter,[(t=(n=i.detail)===null||n===void 0?void 0:n.payload)===null||t===void 0?void 0:t.name]:((d=(e=i===null||i===void 0?void 0:i.detail)===null||e===void 0?void 0:e.payload)===null||d===void 0?void 0:d.value)||null};this.services=await s(this.query,(i=>{var o,l;return(l=(o=this.filter)===null||o===void 0?void 0:o.tab)===null||l===void 0?void 0:l.includes(i===null||i===void 0?void 0:i.tab)}))}}async toggleService(i){var o,l,n;if(!((o=i===null||i===void 0?void 0:i.target)===null||o===void 0?void 0:o.value))return;i.preventDefault();i.stopPropagation();const t=this.selectedIds;console.log(i);if(this.selectedIds.includes((l=i===null||i===void 0?void 0:i.target)===null||l===void 0?void 0:l.value)){t.splice(this.selectedIds.indexOf(i.target.value),1)}else{t.push((n=i===null||i===void 0?void 0:i.target)===null||n===void 0?void 0:n.value)}this.selectedIds=t;console.log(this.selectedIds)}async componentDidLoad(){if(!(l===null||l===void 0?void 0:l.isBrowser))return;this.services=await s(this.query)}render(){var i,o,l;return[n("ion-content",{class:"ion-padding"},n("floodteam-title-bar",null,n("ion-router-link",{href:"/services"},"Services"),n("ion-buttons",{slot:"end"},n("ion-button",{fill:"solid",color:"primary",href:"/services/new"},"Add"))),n("fireenjin-search-bar",{paginationEl:this.paginationEl,filters:((i=e===null||e===void 0?void 0:e.claims)===null||i===void 0?void 0:i.tester)||((o=e===null||e===void 0?void 0:e.claims)===null||o===void 0?void 0:o.admin)?[{name:"tab",label:"Tab",icon:"albums",multiple:true,options:d(),value:(l=this.filter)===null||l===void 0?void 0:l.tab}]:null}),n("ion-card",null,n("ion-list",{class:"ion-no-padding"},n("fireenjin-pagination",{approxItemHeight:84,results:this.services,renderItem:i=>n("ion-item",{href:`/services/${i.id}`,detail:true},n("ion-checkbox",{id:`toggle.${(i===null||i===void 0?void 0:i.id)||""}`,slot:"start",value:i===null||i===void 0?void 0:i.id,onClick:i=>this.toggleService(i),checked:this.selectedIds.includes(i===null||i===void 0?void 0:i.id)}),n("ion-label",null,n("h2",null,(i===null||i===void 0?void 0:i.name)||""," "),n("div",null,Object.entries((i===null||i===void 0?void 0:i.prices)||{}).map((([i,o])=>n("ion-chip",null,n("ion-label",null,i||"",":"," ",n("ion-text",{color:"success",slot:"end"},t(o||0)))))))))})))),n("floodteam-navigation-footer",null,n("fireenjin-chip-bar",null,n("ion-chip",{onClick:()=>this.fireenjinTrigger.emit({name:"import",type:"services"})},n("ion-icon",{class:"ft-icon-style",name:"cloud-upload"}),n("ion-label",null,"Import from CSV")),n("ion-chip",{onClick:()=>this.fireenjinTrigger.emit({name:"export",payload:this.services.map((i=>r(a(i,"createdAt","updatedAt"))))})},n("ion-icon",{name:"cloud-download",class:"ft-icon-style"}),n("ion-label",null,"Export to CSV"))))]}};u.style=v;export{u as app_service_list};
//# sourceMappingURL=p-47f8ed59.entry.js.map