import{t as e}from"./http-BrugN6o-.js";import{t}from"./notification-BM55Quw3.js";import{n}from"./auth-CmHHJsI-.js";var{defineStore:r}=window.pinia,i=r(`customerEstimateStore`,{state:()=>({estimates:[],totalEstimates:0,selectedViewEstimate:[]}),actions:{fetchEstimate(t,r){return new Promise((i,a)=>{e.get(`/api/v1/${r}/customer/estimates`,{params:t}).then(e=>{this.estimates=e.data.data,this.totalEstimates=e.data.meta.estimateTotalCount,i(e)}).catch(e=>{n(e),a(e)})})},fetchViewEstimate(t,r){return new Promise((i,a)=>{e.get(`/api/v1/${r}/customer/estimates/${t.id}`,{params:t}).then(e=>{this.selectedViewEstimate=e.data.data,i(e)}).catch(e=>{n(e),a(e)})})},searchEstimate(t,r){return new Promise((i,a)=>{e.get(`/api/v1/${r}/customer/estimates`,{params:t}).then(e=>{this.estimates=e.data,i(e)}).catch(e=>{n(e),a(e)})})},acceptEstimate({slug:r,id:i,status:a}){return new Promise((o,s)=>{e.post(`/api/v1/${r}/customer/estimate/${i}/status`,{status:a}).then(e=>{let n=this.estimates.findIndex(e=>e.id===i);this.estimates[n]&&(this.estimates[n].status=`ACCEPTED`,t(!0).showNotification({type:`success`,message:global.t(`estimates.marked_as_accepted_message`)})),o(e)}).catch(e=>{n(e),s(e)})})},rejectEstimate({slug:r,id:i,status:a}){return new Promise((o,s)=>{e.post(`/api/v1/${r}/customer/estimate/${i}/status`,{status:a}).then(e=>{let n=this.estimates.findIndex(e=>e.id===i);this.estimates[n]&&(this.estimates[n].status=`REJECTED`,t(!0).showNotification({type:`success`,message:global.t(`estimates.marked_as_rejected_message`)})),o(e)}).catch(e=>{n(e),s(e)})})}}});export{i as t};