mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
2 lines
1.6 KiB
JavaScript
2 lines
1.6 KiB
JavaScript
import{u as h}from"./main.e76e527e.js";import{a as n}from"./vendor.d12b5734.js";import{h as r}from"./auth.8a74dd7f.js";const{defineStore:d}=window.pinia,p=d({id:"customerEstimateStore",state:()=>({estimates:[],totalEstimates:0,selectedViewEstimate:[]}),actions:{fetchEstimate(s,e){return new Promise((a,i)=>{n.get(`/api/v1/${e}/customer/estimates`,{params:s}).then(t=>{this.estimates=t.data.data,this.totalEstimates=t.data.meta.estimateTotalCount,a(t)}).catch(t=>{r(t),i(t)})})},fetchViewEstimate(s,e){return new Promise((a,i)=>{n.get(`/api/v1/${e}/customer/estimates/${s.id}`,{params:s}).then(t=>{this.selectedViewEstimate=t.data.data,a(t)}).catch(t=>{r(t),i(t)})})},searchEstimate(s,e){return new Promise((a,i)=>{n.get(`/api/v1/${e}/customer/estimates`,{params:s}).then(t=>{this.estimates=t.data,a(t)}).catch(t=>{r(t),i(t)})})},acceptEstimate({slug:s,id:e,status:a}){return new Promise((i,t)=>{n.post(`/api/v1/${s}/customer/estimate/${e}/status`,{status:a}).then(o=>{let m=this.estimates.findIndex(c=>c.id===e);this.estimates[m]&&(this.estimates[m].status="ACCEPTED",h(!0).showNotification({type:"success",message:global.t("estimates.marked_as_accepted_message")})),i(o)}).catch(o=>{r(o),t(o)})})},rejectEstimate({slug:s,id:e,status:a}){return new Promise((i,t)=>{n.post(`/api/v1/${s}/customer/estimate/${e}/status`,{status:a}).then(o=>{let m=this.estimates.findIndex(c=>c.id===e);this.estimates[m]&&(this.estimates[m].status="REJECTED",h(!0).showNotification({type:"success",message:global.t("estimates.marked_as_rejected_message")})),i(o)}).catch(o=>{r(o),t(o)})})}}});export{p as u};
|