fix status action in view estimate

This commit is contained in:
satyaprakash10
2019-11-15 19:43:42 +05:30
parent e018d71443
commit d529c1d68f
5 changed files with 71 additions and 19 deletions

View File

@ -56,6 +56,7 @@ export const fetchViewEstimate = ({ commit, dispatch, state }, id) => {
export const sendEmail = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.post(`/api/estimates/send`, data).then((response) => {
commit(types.UPDATE_ESTIMATE_STATUS, {id: data.id, status: 'SENT'})
resolve(response)
}).catch((err) => {
reject(err)
@ -100,7 +101,7 @@ export const deleteMultipleEstimates = ({ commit, dispatch, state }, id) => {
export const updateEstimate = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.put(`/api/estimates/${data.id}`, data).then((response) => {
commit(types.UPDATE_ESTIMATE, response.data)
commit(types.UPDATE_ESTIMATE_STATUS, response.data)
resolve(response)
}).catch((err) => {
reject(err)

View File

@ -4,3 +4,7 @@ export const getTemplateId = (state) => state.estimateTemplateId
export const selectedEstimates = (state) => state.selectedEstimates
export const totalEstimates = (state) => state.totalEstimates
export const selectedCustomer = (state) => state.selectedCustomer
export const getEstimate = (state) => (id) => {
let invId = parseInt(id)
return state.estimates.find(estimate => estimate.id === invId)
}

View File

@ -14,3 +14,4 @@ export const SELECT_CUSTOMER = 'SELECT_CUSTOMER'
export const RESET_SELECTED_CUSTOMER = 'RESET_SELECTED_CUSTOMER'
export const SET_SELECT_ALL_STATE = 'SET_SELECT_ALL_STATE'
export const RESET_SELECTED_ESTIMATES = 'RESET_SELECTED_ESTIMATES'
export const UPDATE_ESTIMATE_STATUS = 'UPDATE_ESTIMATE_STATUS'

View File

@ -37,6 +37,12 @@ export default {
state.estimates[pos] = data.estimate
},
[types.UPDATE_ESTIMATE_STATUS] (state, data) {
let pos = state.estimates.findIndex(estimate => estimate.id === data.id)
state.estimates[pos].status = data.status
},
[types.RESET_SELECTED_ESTIMATES] (state, data) {
state.selectedEstimates = []
state.selectAllField = false