import{r as i,d as e,h as t}from"./p-03169580.js";import{f as s}from"./p-cf4a3445.js";let o=class{constructor(t){i(this,t);this.fireenjinSubmit=e(this,"fireenjinSubmit",7);this.isGeneral=false;this.amount=0;this.quantity=1;this.price=0}onSuccess(i){var e,t,s,o,n;if(((e=i===null||i===void 0?void 0:i.detail)===null||e===void 0?void 0:e.endpoint)==="deleteScopeService"){this.amount=0;this.quantity=1;this.siteServiceId=null}else if(((t=i===null||i===void 0?void 0:i.detail)===null||t===void 0?void 0:t.endpoint)==="addScopeService"){this.siteServiceId=(n=(o=(s=i===null||i===void 0?void 0:i.detail)===null||s===void 0?void 0:s.data)===null||o===void 0?void 0:o.addScopeService)===null||n===void 0?void 0:n.id}}onReset(i){this.fireenjinSubmit.emit({endpoint:"deleteScopeService",event:i,data:{id:this.siteServiceId,siteId:this.siteId,jobId:this.jobId}})}render(){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," ",(this===null||this===void 0?void 0:this.unit)||"")," ","x ",t("b",null,this.quantity||1," Qty")," x"," ",t("b",null,s(this.price||0))):t("p",null,"Click to Add")),t("ion-text",{color:"success",slot:"end"},this.siteServiceId&&t("small",null,s(parseFloat(this.amount||0)*parseFloat(this.quantity||1)*parseFloat(this.price||0))))),t("fireenjin-form",{slot:"content",disableLoader:true,name:`siteService-${this.siteId}-${this.serviceId}`,resetButton:"Remove",resetButtonColor:"danger",disableReset:true,endpoint:this.siteServiceId?"editScopeService":"addScopeService",beforeSubmit:async i=>{const e={jobId:this.jobId,siteId:this.siteId,...this.siteServiceId?{id:this.siteServiceId}:{serviceId:this.serviceId},quantity:parseFloat((i===null||i===void 0?void 0:i.quantity)||this.quantity||1),amount:parseFloat((i===null||i===void 0?void 0:i.amount)||this.amount||1)};if(i===null||i===void 0?void 0:i.price){try{e.price=parseFloat((i===null||i===void 0?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"}))))))}};export{o as floodteam_form_site_service};
//# sourceMappingURL=p-110d0340.entry.js.map