Files
crater/public/build/assets/estimate.c2ce8e7a.js
Mohit Panjwani eea3925fcd new build 605
2022-03-03 17:03:40 +05:30

2 lines
1.6 KiB
JavaScript

import{u as h}from"./main.c7bd6c0e.js";import{a as n}from"./vendor.d12b5734.js";import{h as r}from"./auth.a07e0850.js";const{defineStore:u}=window.pinia,p=u({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};