import{r as i,d as e,h as t}from"./p-f8363b1b.js";import{f as l}from"./p-cf4a3445.js";const o=class{constructor(t){i(this,t),this.fireenjinSubmit=e(this,"fireenjinSubmit",7),this.isGeneral=!1,this.amount=0,this.quantity=1,this.price=0}onSuccess(i){var e,t,l,o,s;"deleteScopeService"===(null===(e=null==i?void 0:i.detail)||void 0===e?void 0:e.endpoint)?(this.amount=0,this.quantity=1,this.siteServiceId=null):"addScopeService"===(null===(t=null==i?void 0:i.detail)||void 0===t?void 0:t.endpoint)&&(this.siteServiceId=null===(s=null===(o=null===(l=null==i?void 0:i.detail)||void 0===l?void 0:l.data)||void 0===o?void 0:o.addScopeService)||void 0===s?void 0:s.id)}onReset(i){this.fireenjinSubmit.emit({endpoint:"deleteScopeService",event:i,data:{id:this.siteServiceId,siteId:this.siteId,jobId:this.jobId}})}render(){var i,e,o,s;return t("ion-accordion",{value:`${this.isGeneral?this.jobId:this.siteId}-${this.serviceId}`},t("ion-item",{slot:"header"},t("ion-label",null,t("h2",null,this.name||(this.isGeneral?"General Service":"No Site Name")),this.siteServiceId?t("ion-text",{color:"primary"},t("b",null,this.amount||0," ",(null==this?void 0:this.unit)||"")," ","x ",t("b",null,this.quantity||1," Qty")," x"," ",t("b",null,l(this.price||0))):t("p",null,"Click to Add")),t("ion-text",{color:"success",slot:"end"},this.siteServiceId&&t("small",null,l(parseFloat(this.amount||0)*parseFloat(this.quantity||1)*parseFloat(this.price||0))))),t("fireenjin-form",{slot:"content",disableLoader:!0,name:`siteService-${this.siteId}-${this.serviceId}`,resetButton:"Remove",resetButtonColor:"danger",disableReset:!0,endpoint:this.siteServiceId?"editScopeService":"addScopeService",beforeSubmit:async i=>{const e={jobId:this.jobId,siteId:this.siteId,...this.siteServiceId?{id:this.siteServiceId}:{serviceId:this.serviceId},price:parseFloat((null==i?void 0:i.price)||this.price||0),quantity:parseFloat((null==i?void 0:i.quantity)||this.quantity||1),amount:parseFloat((null==i?void 0:i.amount)||this.amount||1)};if(null==i?void 0:i.price)try{e.price=parseFloat((null==i?void 0:i.price)||0)}catch(i){console.log("Error setting price: ",i)}return e}},t("ion-grid",{class:"ion-no-padding"},t("ion-row",{class:"ion-no-padding"},t("ion-col",{size:"6",sizeXs:"4"},t("fireenjin-input",{type:"number",name:"amount",value:this.amount||0,label:"Amount",labelPosition:"stacked",min:"0",step:"0.01"})),t("ion-col",{size:"6",sizeXs:"4"},t("fireenjin-input",{type:"number",name:"quantity",value:this.quantity||1,label:"Quantity",labelPosition:"stacked",min:"1"})),t("ion-col",{size:"12",sizeXs:"4"},t("fireenjin-input",{type:"number",name:"price",value:this.price||0,label:"Price",labelPosition:"stacked",step:"0.01",min:"0"}))),t("ion-row",null,t("ion-col",null,t("fireenjin-chip-bar",null,[{label:"Affected Sqft",value:null===(i=this.site)||void 0===i?void 0:i.affectedAreaTotalSqft},{label:"Affected CuSqft",value:null===(e=this.site)||void 0===e?void 0:e.affectedAreaTotalCuft},{label:"Total Sqft",value:null===(o=this.site)||void 0===o?void 0:o.areaTotalSqft},{label:"Total CuSqft",value:null===(s=this.site)||void 0===s?void 0:s.areaTotalCuft}].filter((i=>(null==i?void 0:i.value)>0)).map((i=>t("ion-chip",{onClick:()=>this.amount=(null==i?void 0:i.value)||0},(null==i?void 0:i.label)||""," - ",(null==i?void 0:i.value)||"")))))))))}};export{o as floodteam_form_site_service}