Merge branch 'dashboard-refactor' into 'master'

add separate actions for dashboard tables

See merge request mohit.panjvani/crater-web!45
This commit is contained in:
Mohit Panjwani
2019-11-18 14:29:57 +00:00
20 changed files with 143 additions and 201179 deletions

View File

@ -21,11 +21,11 @@ REDIS_PASSWORD=null
REDIS_PORT=6379 REDIS_PORT=6379
MAIL_DRIVER=smtp MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io MAIL_HOST=
MAIL_PORT=2525 MAIL_PORT=
MAIL_USERNAME=null MAIL_USERNAME=
MAIL_PASSWORD=null MAIL_PASSWORD=
MAIL_ENCRYPTION=null MAIL_ENCRYPTION=
PUSHER_APP_ID= PUSHER_APP_ID=
PUSHER_KEY= PUSHER_KEY=

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,13 @@
<svg
aria-hidden="true"
focusable="false"
data-prefix="fas"
data-icon="file-alt"
class="svg-inline--fa fa-file-alt fa-w-12"
role="img" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 384 512">
<path
fill="#55547A"
d="M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm64 236c0 6.6-5.4 12-12 12H108c-6.6 0-12-5.4-12-12v-8c0-6.6 5.4-12 12-12h168c6.6 0 12 5.4 12 12v8zm0-64c0 6.6-5.4 12-12 12H108c-6.6 0-12-5.4-12-12v-8c0-6.6 5.4-12 12-12h168c6.6 0 12 5.4 12 12v8zm0-72v8c0 6.6-5.4 12-12 12H108c-6.6 0-12-5.4-12-12v-8c0-6.6 5.4-12 12-12h168c6.6 0 12 5.4 12 12zm96-114.1v6.1H256V0h6.1c6.4 0 12.5 2.5 17 7l97.9 98c4.5 4.5 7 10.6 7 16.9z">
</path>
</svg>

After

Width:  |  Height:  |  Size: 764 B

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +0,0 @@
{
"/assets/js/app.js": "/assets/js/app.js",
"/assets/css/laraspace.css": "/assets/css/laraspace.css",
"/assets/js/app.js.map": "/assets/js/app.js.map",
"/assets/css/laraspace.css.map": "/assets/css/laraspace.css.map"
}

View File

@ -260,6 +260,8 @@ export default {
created_message: 'Estimate created successfully', created_message: 'Estimate created successfully',
updated_message: 'Estimate updated successfully', updated_message: 'Estimate updated successfully',
deleted_message: 'Estimate deleted successfully | Estimates deleted successfully', deleted_message: 'Estimate deleted successfully | Estimates deleted successfully',
user_email_does_not_exist: 'User email does not exist',
something_went_wrong: 'something went wrong',
item: { item: {
title: 'Item Title', title: 'Item Title',
description: 'Description', description: 'Description',
@ -349,6 +351,8 @@ export default {
updated_message: 'Invoice updated successfully', updated_message: 'Invoice updated successfully',
deleted_message: 'Invoice deleted successfully | Invoices deleted successfully', deleted_message: 'Invoice deleted successfully | Invoices deleted successfully',
marked_as_sent_message: 'Invoice marked as sent successfully', marked_as_sent_message: 'Invoice marked as sent successfully',
user_email_does_not_exist: 'User email does not exist',
something_went_wrong: 'something went wrong',
invalid_due_amount_message: 'Total Invoice amount cannot be less than total paid amount for this Invoice. Please update the invoice or delete the associated payments to continue.' invalid_due_amount_message: 'Total Invoice amount cannot be less than total paid amount for this Invoice. Please update the invoice or delete the associated payments to continue.'
}, },
credit_notes: { credit_notes: {

View File

@ -23,108 +23,3 @@ export const getChart = ({ commit, dispatch, state }) => {
}) })
}) })
} }
export const sendEmail = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.post(`/api/invoices/send`, data).then((response) => {
commit(types.UPDATE_INVOICE_STATUS, { id: data.id, status: 'SENT' })
resolve(response)
}).catch((err) => {
reject(err)
})
})
}
export const markAsSent = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.post(`/api/invoices/mark-as-sent`, data).then((response) => {
commit(types.UPDATE_INVOICE_STATUS, { id: data.id, status: 'SENT' })
resolve(response)
}).catch((err) => {
reject(err)
})
})
}
export const deleteInvoice = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios.delete(`/api/invoices/${id}`).then((response) => {
if (response.data.error) {
resolve(response)
} else {
commit(types.DELETE_INVOICE, id)
resolve(response)
}
}).catch((err) => {
reject(err)
})
})
}
export const sendEstimateEmail = ({ 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)
})
})
}
export const markAsAccepted = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.post(`/api/estimates/accept`, data).then((response) => {
commit(types.UPDATE_ESTIMATE_STATUS, { id: data.id, status: 'ACCEPTED' })
resolve(response)
}).catch((err) => {
reject(err)
})
})
}
export const markAsRejected = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.post(`/api/estimates/reject`, data).then((response) => {
commit(types.UPDATE_ESTIMATE_STATUS, { id: data.id, status: 'REJECTED' })
resolve(response)
}).catch((err) => {
reject(err)
})
})
}
export const markEstimateAsSent = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => {
window.axios.post(`/api/estimates/mark-as-sent`, data).then((response) => {
commit(types.UPDATE_ESTIMATE_STATUS, { id: data.id, status: 'SENT' })
resolve(response)
}).catch((err) => {
reject(err)
})
})
}
export const convertToInvoice = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios.post(`/api/estimates/${id}/convert-to-invoice`).then((response) => {
// commit(types.UPDATE_INVOICE, response.data)
resolve(response)
}).catch((err) => {
reject(err)
})
})
}
export const deleteEstimate = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => {
window.axios.delete(`/api/estimates/${id}`).then((response) => {
commit(types.DELETE_ESTIMATE, id)
resolve(response)
}).catch((err) => {
reject(err)
})
})
}

View File

@ -37,7 +37,9 @@ export default {
[types.UPDATE_INVOICE_STATUS] (state, data) { [types.UPDATE_INVOICE_STATUS] (state, data) {
let pos = state.dueInvoices.findIndex(invoice => invoice.id === data.id) let pos = state.dueInvoices.findIndex(invoice => invoice.id === data.id)
if (state.dueInvoices[pos]) {
state.dueInvoices[pos].status = data.status state.dueInvoices[pos].status = data.status
}
}, },
[types.DELETE_INVOICE] (state, id) { [types.DELETE_INVOICE] (state, id) {
@ -53,6 +55,8 @@ export default {
[types.UPDATE_ESTIMATE_STATUS] (state, data) { [types.UPDATE_ESTIMATE_STATUS] (state, data) {
let pos = state.recentEstimates.findIndex(estimate => estimate.id === data.id) let pos = state.recentEstimates.findIndex(estimate => estimate.id === data.id)
if (state.recentEstimates[pos]) {
state.recentEstimates[pos].status = data.status state.recentEstimates[pos].status = data.status
}, }
}
} }

View File

@ -1,4 +1,5 @@
import * as types from './mutation-types' import * as types from './mutation-types'
import * as dashboardTypes from '../dashboard/mutation-types'
export const fetchEstimates = ({ commit, dispatch, state }, params) => { export const fetchEstimates = ({ commit, dispatch, state }, params) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -56,7 +57,10 @@ export const fetchViewEstimate = ({ commit, dispatch, state }, id) => {
export const sendEmail = ({ commit, dispatch, state }, data) => { export const sendEmail = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
window.axios.post(`/api/estimates/send`, data).then((response) => { window.axios.post(`/api/estimates/send`, data).then((response) => {
if (response.data.success) {
commit(types.UPDATE_ESTIMATE_STATUS, {id: data.id, status: 'SENT'}) commit(types.UPDATE_ESTIMATE_STATUS, {id: data.id, status: 'SENT'})
commit('dashboard/' + dashboardTypes.UPDATE_ESTIMATE_STATUS, { id: data.id, status: 'SENT' }, { root: true })
}
resolve(response) resolve(response)
}).catch((err) => { }).catch((err) => {
reject(err) reject(err)
@ -80,6 +84,7 @@ export const deleteEstimate = ({ commit, dispatch, state }, id) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
window.axios.delete(`/api/estimates/${id}`).then((response) => { window.axios.delete(`/api/estimates/${id}`).then((response) => {
commit(types.DELETE_ESTIMATE, id) commit(types.DELETE_ESTIMATE, id)
commit('dashboard/' + dashboardTypes.DELETE_ESTIMATE, id, { root: true })
resolve(response) resolve(response)
}).catch((err) => { }).catch((err) => {
reject(err) reject(err)
@ -112,6 +117,7 @@ export const updateEstimate = ({ commit, dispatch, state }, data) => {
export const markAsAccepted = ({ commit, dispatch, state }, data) => { export const markAsAccepted = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
window.axios.post(`/api/estimates/accept`, data).then((response) => { window.axios.post(`/api/estimates/accept`, data).then((response) => {
commit('dashboard/' + dashboardTypes.UPDATE_ESTIMATE_STATUS, { id: data.id, status: 'ACCEPTED' }, { root: true })
resolve(response) resolve(response)
}).catch((err) => { }).catch((err) => {
reject(err) reject(err)
@ -122,6 +128,7 @@ export const markAsAccepted = ({ commit, dispatch, state }, data) => {
export const markAsRejected = ({ commit, dispatch, state }, data) => { export const markAsRejected = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
window.axios.post(`/api/estimates/reject`, data).then((response) => { window.axios.post(`/api/estimates/reject`, data).then((response) => {
commit('dashboard/' + dashboardTypes.UPDATE_ESTIMATE_STATUS, { id: data.id, status: 'REJECTED' }, { root: true })
resolve(response) resolve(response)
}).catch((err) => { }).catch((err) => {
reject(err) reject(err)
@ -133,6 +140,7 @@ export const markAsSent = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
window.axios.post(`/api/estimates/mark-as-sent`, data).then((response) => { window.axios.post(`/api/estimates/mark-as-sent`, data).then((response) => {
commit(types.UPDATE_ESTIMATE_STATUS, {id: data.id, status: 'SENT'}) commit(types.UPDATE_ESTIMATE_STATUS, {id: data.id, status: 'SENT'})
commit('dashboard/' + dashboardTypes.UPDATE_ESTIMATE_STATUS, { id: data.id, status: 'SENT' }, { root: true })
resolve(response) resolve(response)
}).catch((err) => { }).catch((err) => {
reject(err) reject(err)

View File

@ -40,7 +40,9 @@ export default {
[types.UPDATE_ESTIMATE_STATUS] (state, data) { [types.UPDATE_ESTIMATE_STATUS] (state, data) {
let pos = state.estimates.findIndex(estimate => estimate.id === data.id) let pos = state.estimates.findIndex(estimate => estimate.id === data.id)
if (state.estimates[pos]) {
state.estimates[pos].status = data.status state.estimates[pos].status = data.status
}
}, },
[types.RESET_SELECTED_ESTIMATES] (state, data) { [types.RESET_SELECTED_ESTIMATES] (state, data) {

View File

@ -1,5 +1,5 @@
import * as types from './mutation-types' import * as types from './mutation-types'
// import moment from 'moment' import * as dashboardTypes from '../dashboard/mutation-types'
export const fetchInvoices = ({ commit, dispatch, state }, params) => { export const fetchInvoices = ({ commit, dispatch, state }, params) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -47,7 +47,10 @@ export const fetchViewInvoice = ({ commit, dispatch, state }, id) => {
export const sendEmail = ({ commit, dispatch, state }, data) => { export const sendEmail = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
window.axios.post(`/api/invoices/send`, data).then((response) => { window.axios.post(`/api/invoices/send`, data).then((response) => {
if (response.data.success) {
commit(types.UPDATE_INVOICE_STATUS, {id: data.id, status: 'SENT'}) commit(types.UPDATE_INVOICE_STATUS, {id: data.id, status: 'SENT'})
commit('dashboard/' + dashboardTypes.UPDATE_INVOICE_STATUS, {id: data.id, status: 'SENT'}, { root: true })
}
resolve(response) resolve(response)
}).catch((err) => { }).catch((err) => {
reject(err) reject(err)
@ -83,6 +86,7 @@ export const deleteInvoice = ({ commit, dispatch, state }, id) => {
resolve(response) resolve(response)
} else { } else {
commit(types.DELETE_INVOICE, id) commit(types.DELETE_INVOICE, id)
commit('dashboard/' + dashboardTypes.DELETE_INVOICE, id, { root: true })
resolve(response) resolve(response)
} }
}).catch((err) => { }).catch((err) => {
@ -123,6 +127,7 @@ export const markAsSent = ({ commit, dispatch, state }, data) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
window.axios.post(`/api/invoices/mark-as-sent`, data).then((response) => { window.axios.post(`/api/invoices/mark-as-sent`, data).then((response) => {
commit(types.UPDATE_INVOICE_STATUS, {id: data.id, status: 'SENT'}) commit(types.UPDATE_INVOICE_STATUS, {id: data.id, status: 'SENT'})
commit('dashboard/' + dashboardTypes.UPDATE_INVOICE_STATUS, {id: data.id, status: 'SENT'}, { root: true })
resolve(response) resolve(response)
}).catch((err) => { }).catch((err) => {
reject(err) reject(err)

View File

@ -31,7 +31,9 @@ export default {
[types.UPDATE_INVOICE_STATUS] (state, data) { [types.UPDATE_INVOICE_STATUS] (state, data) {
let pos = state.invoices.findIndex(invoice => invoice.id === data.id) let pos = state.invoices.findIndex(invoice => invoice.id === data.id)
if (state.invoices[pos]) {
state.invoices[pos].status = data.status state.invoices[pos].status = data.status
}
}, },
[types.RESET_SELECTED_INVOICES] (state, data) { [types.RESET_SELECTED_INVOICES] (state, data) {

View File

@ -190,7 +190,7 @@
> >
<template slot-scope="row"> <template slot-scope="row">
<v-dropdown> <v-dropdown>
<a slot="activator" href="#"> <a slot="activator" href="#/">
<dot-icon /> <dot-icon />
</a> </a>
<v-dropdown-item> <v-dropdown-item>
@ -203,14 +203,14 @@
{{ $t('invoices.view') }} {{ $t('invoices.view') }}
</router-link> </router-link>
</v-dropdown-item> </v-dropdown-item>
<v-dropdown-item> <v-dropdown-item v-if="row.status == 'DRAFT'">
<a class="dropdown-item" href="#" @click="sendInvoice(row.id)" > <a class="dropdown-item" href="#/" @click="sendInvoice(row.id)" >
<font-awesome-icon icon="envelope" class="dropdown-item-icon" /> <font-awesome-icon icon="envelope" class="dropdown-item-icon" />
{{ $t('invoices.send_invoice') }} {{ $t('invoices.send_invoice') }}
</a> </a>
</v-dropdown-item> </v-dropdown-item>
<v-dropdown-item v-if="row.status === 'DRAFT'"> <v-dropdown-item v-if="row.status === 'DRAFT'">
<a class="dropdown-item" href="#" @click="sentInvoice(row.id)"> <a class="dropdown-item" href="#/" @click="sentInvoice(row.id)">
<font-awesome-icon icon="check-circle" class="dropdown-item-icon" /> <font-awesome-icon icon="check-circle" class="dropdown-item-icon" />
{{ $t('invoices.mark_as_sent') }} {{ $t('invoices.mark_as_sent') }}
</a> </a>
@ -272,7 +272,7 @@
> >
<template slot-scope="row"> <template slot-scope="row">
<v-dropdown> <v-dropdown>
<a slot="activator" href="#"> <a slot="activator" href="#/">
<dot-icon /> <dot-icon />
</a> </a>
<v-dropdown-item> <v-dropdown-item>
@ -294,31 +294,31 @@
</router-link> </router-link>
</v-dropdown-item> </v-dropdown-item>
<v-dropdown-item> <v-dropdown-item>
<a class="dropdown-item" href="#" @click="convertInToinvoice(row.id)"> <a class="dropdown-item" href="#/" @click="convertInToinvoice(row.id)">
<font-awesome-icon icon="envelope" class="dropdown-item-icon" /> <font-awesome-icon icon="file-alt" class="dropdown-item-icon" />
{{ $t('estimates.convert_to_invoice') }} {{ $t('estimates.convert_to_invoice') }}
</a> </a>
</v-dropdown-item> </v-dropdown-item>
<v-dropdown-item v-if="row.status === 'DRAFT'"> <v-dropdown-item v-if="row.status === 'DRAFT'">
<a class="dropdown-item" href="#" @click.self="onMarkAsSent(row.id)"> <a class="dropdown-item" href="#/" @click.self="onMarkAsSent(row.id)">
<font-awesome-icon icon="check-circle" class="dropdown-item-icon" /> <font-awesome-icon icon="check-circle" class="dropdown-item-icon" />
{{ $t('estimates.mark_as_sent') }} {{ $t('estimates.mark_as_sent') }}
</a> </a>
</v-dropdown-item> </v-dropdown-item>
<v-dropdown-item v-if="row.status !== 'SENT'"> <v-dropdown-item v-if="row.status !== 'SENT'">
<a class="dropdown-item" href="#" @click.self="sendEstimate(row.id)"> <a class="dropdown-item" href="#/" @click.self="sendEstimate(row.id)">
<font-awesome-icon icon="paper-plane" class="dropdown-item-icon" /> <font-awesome-icon icon="paper-plane" class="dropdown-item-icon" />
{{ $t('estimates.send_estimate') }} {{ $t('estimates.send_estimate') }}
</a> </a>
</v-dropdown-item> </v-dropdown-item>
<v-dropdown-item v-if="row.status !== 'ACCEPTED'"> <v-dropdown-item v-if="row.status !== 'ACCEPTED'">
<a class="dropdown-item" href="#" @click.self="onMarkAsAccepted(row.id)"> <a class="dropdown-item" href="#/" @click.self="onMarkAsAccepted(row.id)">
<font-awesome-icon icon="check-circle" class="dropdown-item-icon" /> <font-awesome-icon icon="check-circle" class="dropdown-item-icon" />
{{ $t('estimates.mark_as_accepted') }} {{ $t('estimates.mark_as_accepted') }}
</a> </a>
</v-dropdown-item> </v-dropdown-item>
<v-dropdown-item v-if="row.status !== 'REJECTED'"> <v-dropdown-item v-if="row.status !== 'REJECTED'">
<a class="dropdown-item" href="#" @click.self="onMarkAsRejected(row.id)"> <a class="dropdown-item" href="#/" @click.self="onMarkAsRejected(row.id)">
<font-awesome-icon icon="times-circle" class="dropdown-item-icon" /> <font-awesome-icon icon="times-circle" class="dropdown-item-icon" />
{{ $t('estimates.mark_as_rejected') }} {{ $t('estimates.mark_as_rejected') }}
</a> </a>
@ -404,17 +404,23 @@ export default {
methods: { methods: {
...mapActions('dashboard', [ ...mapActions('dashboard', [
'getChart', 'getChart',
'loadData', 'loadData'
]),
...mapActions('invoice', [
'deleteInvoice', 'deleteInvoice',
'sendEmail', 'sendEmail',
'markAsSent', 'markAsSent'
'sendEstimateEmail', ]),
...mapActions('estimate', [
'deleteEstimate', 'deleteEstimate',
'markAsAccepted', 'markAsAccepted',
'markAsRejected', 'markAsRejected',
'markEstimateAsSent',
'convertToInvoice' 'convertToInvoice'
]), ]),
...mapActions('estimate', {
'sendEstimateEmail': 'sendEmail',
'markEstimateAsSent': 'markAsSent'
}),
async loadChart () { async loadChart () {
await this.$store.dispatch('dashboard/getChart') await this.$store.dispatch('dashboard/getChart')
@ -459,7 +465,7 @@ export default {
swal({ swal({
title: this.$t('general.are_you_sure'), title: this.$t('general.are_you_sure'),
text: this.$t('estimates.confirm_conversion'), text: this.$t('estimates.confirm_conversion'),
icon: '/assets/icon/envelope-solid.svg', icon: '/assets/icon/file-alt-solid.svg',
buttons: true, buttons: true,
dangerMode: true dangerMode: true
}).then(async (willDelete) => { }).then(async (willDelete) => {
@ -532,9 +538,15 @@ export default {
} }
let response = await this.sendEmail(data) let response = await this.sendEmail(data)
this.refreshInvTable() this.refreshInvTable()
if (response.data) { if (response.data.success) {
window.toastr['success'](this.$tc('invoices.send_invoice_successfully')) window.toastr['success'](this.$tc('invoices.send_invoice_successfully'))
return true
} }
if (response.data.error === 'user_email_does_not_exist') {
window.toastr['error'](this.$tc('invoices.user_email_does_not_exist'))
return false
}
window.toastr['error'](this.$tc('invoices.something_went_wrong'))
} }
}) })
}, },
@ -618,9 +630,15 @@ export default {
} }
let response = await this.sendEstimateEmail(data) let response = await this.sendEstimateEmail(data)
this.refreshEstTable() this.refreshEstTable()
if (response.data) { if (response.data.success) {
window.toastr['success'](this.$tc('estimates.send_estimate_successfully')) window.toastr['success'](this.$tc('estimates.send_estimate_successfully'))
return true
} }
if (response.data.error === 'user_email_does_not_exist') {
window.toastr['success'](this.$tc('estimates.user_email_does_not_exist'))
return true
}
window.toastr['error'](this.$tc('estimates.something_went_wrong'))
} }
}) })
} }

View File

@ -245,31 +245,31 @@
</router-link> </router-link>
</v-dropdown-item> </v-dropdown-item>
<v-dropdown-item> <v-dropdown-item>
<a class="dropdown-item" href="#" @click="convertInToinvoice(row.id)"> <a class="dropdown-item" href="#/" @click="convertInToinvoice(row.id)">
<font-awesome-icon icon="envelope" class="dropdown-item-icon" /> <font-awesome-icon icon="file-alt" class="dropdown-item-icon" />
{{ $t('estimates.convert_to_invoice') }} {{ $t('estimates.convert_to_invoice') }}
</a> </a>
</v-dropdown-item> </v-dropdown-item>
<v-dropdown-item v-if="row.status !== 'SENT'"> <v-dropdown-item v-if="row.status !== 'SENT'">
<a class="dropdown-item" href="#" @click.self="onMarkAsSent(row.id)"> <a class="dropdown-item" href="#/" @click.self="onMarkAsSent(row.id)">
<font-awesome-icon icon="check-circle" class="dropdown-item-icon" /> <font-awesome-icon icon="check-circle" class="dropdown-item-icon" />
{{ $t('estimates.mark_as_sent') }} {{ $t('estimates.mark_as_sent') }}
</a> </a>
</v-dropdown-item> </v-dropdown-item>
<v-dropdown-item v-if="row.status !== 'SENT'"> <v-dropdown-item v-if="row.status !== 'SENT'">
<a class="dropdown-item" href="#" @click.self="sendEstimate(row.id)"> <a class="dropdown-item" href="#/" @click.self="sendEstimate(row.id)">
<font-awesome-icon icon="paper-plane" class="dropdown-item-icon" /> <font-awesome-icon icon="paper-plane" class="dropdown-item-icon" />
{{ $t('estimates.send_estimate') }} {{ $t('estimates.send_estimate') }}
</a> </a>
</v-dropdown-item> </v-dropdown-item>
<v-dropdown-item v-if="row.status !== 'ACCEPTED'"> <v-dropdown-item v-if="row.status !== 'ACCEPTED'">
<a class="dropdown-item" href="#" @click.self="onMarkAsAccepted(row.id)"> <a class="dropdown-item" href="#/" @click.self="onMarkAsAccepted(row.id)">
<font-awesome-icon icon="check-circle" class="dropdown-item-icon" /> <font-awesome-icon icon="check-circle" class="dropdown-item-icon" />
{{ $t('estimates.mark_as_accepted') }} {{ $t('estimates.mark_as_accepted') }}
</a> </a>
</v-dropdown-item> </v-dropdown-item>
<v-dropdown-item v-if="row.status !== 'REJECTED'"> <v-dropdown-item v-if="row.status !== 'REJECTED'">
<a class="dropdown-item" href="#" @click.self="onMarkAsRejected(row.id)"> <a class="dropdown-item" href="#/" @click.self="onMarkAsRejected(row.id)">
<font-awesome-icon icon="times-circle" class="dropdown-item-icon" /> <font-awesome-icon icon="times-circle" class="dropdown-item-icon" />
{{ $t('estimates.mark_as_rejected') }} {{ $t('estimates.mark_as_rejected') }}
</a> </a>
@ -424,7 +424,7 @@ export default {
let response = await this.markAsAccepted(data) let response = await this.markAsAccepted(data)
this.refreshTable() this.refreshTable()
if (response.data) { if (response.data) {
this.filters.status = 'ACCEPTED' this.filters.status = ''
this.$refs.table.refresh() this.$refs.table.refresh()
window.toastr['success'](this.$tc('estimates.marked_as_accepted_message')) window.toastr['success'](this.$tc('estimates.marked_as_accepted_message'))
} }
@ -446,7 +446,7 @@ export default {
let response = await this.markAsRejected(data) let response = await this.markAsRejected(data)
this.refreshTable() this.refreshTable()
if (response.data) { if (response.data) {
this.filters.status = 'REJECTED' this.filters.status = ''
this.$refs.table.refresh() this.$refs.table.refresh()
window.toastr['success'](this.$tc('estimates.marked_as_rejected_message')) window.toastr['success'](this.$tc('estimates.marked_as_rejected_message'))
} }
@ -512,7 +512,7 @@ export default {
swal({ swal({
title: this.$t('general.are_you_sure'), title: this.$t('general.are_you_sure'),
text: this.$t('estimates.confirm_conversion'), text: this.$t('estimates.confirm_conversion'),
icon: '/assets/icon/envelope-solid.svg', icon: '/assets/icon/file-alt-solid.svg',
buttons: true, buttons: true,
dangerMode: true dangerMode: true
}).then(async (willConvertInToinvoice) => { }).then(async (willConvertInToinvoice) => {
@ -590,9 +590,15 @@ export default {
} }
let response = await this.sendEmail(data) let response = await this.sendEmail(data)
this.refreshTable() this.refreshTable()
if (response.data) { if (response.data.success) {
window.toastr['success'](this.$tc('estimates.send_estimate_successfully')) window.toastr['success'](this.$tc('estimates.send_estimate_successfully'))
return true
} }
if (response.data.error === 'user_email_does_not_exist') {
window.toastr['success'](this.$tc('estimates.user_email_does_not_exist'))
return true
}
window.toastr['error'](this.$tc('estimates.something_went_wrong'))
} }
}) })
} }

View File

@ -260,9 +260,15 @@ export default {
this.isSendingEmail = true this.isSendingEmail = true
let response = await this.sendEmail({id: this.estimate.id}) let response = await this.sendEmail({id: this.estimate.id})
this.isSendingEmail = false this.isSendingEmail = false
if (response.data) { if (response.data.success) {
window.toastr['success'](this.$tc('estimates.send_estimate_successfully')) window.toastr['success'](this.$tc('estimates.send_estimate_successfully'))
return true
} }
if (response.data.error === 'user_email_does_not_exist') {
window.toastr['success'](this.$tc('estimates.user_email_does_not_exist'))
return true
}
window.toastr['error'](this.$tc('estimates.something_went_wrong'))
} }
}) })
}, },

View File

@ -248,13 +248,13 @@
</router-link> </router-link>
</v-dropdown-item> </v-dropdown-item>
<v-dropdown-item v-if="row.status == 'DRAFT'"> <v-dropdown-item v-if="row.status == 'DRAFT'">
<a class="dropdown-item" href="#" @click="sendInvoice(row.id)" > <a class="dropdown-item" href="#/" @click="sendInvoice(row.id)" >
<font-awesome-icon icon="paper-plane" class="dropdown-item-icon" /> <font-awesome-icon icon="paper-plane" class="dropdown-item-icon" />
{{ $t('invoices.send_invoice') }} {{ $t('invoices.send_invoice') }}
</a> </a>
</v-dropdown-item> </v-dropdown-item>
<v-dropdown-item v-if="row.status == 'DRAFT'"> <v-dropdown-item v-if="row.status == 'DRAFT'">
<a class="dropdown-item" href="#" @click="markInvoiceAsSent(row.id)"> <a class="dropdown-item" href="#/" @click="markInvoiceAsSent(row.id)">
<font-awesome-icon icon="check-circle" class="dropdown-item-icon" /> <font-awesome-icon icon="check-circle" class="dropdown-item-icon" />
{{ $t('invoices.mark_as_sent') }} {{ $t('invoices.mark_as_sent') }}
</a> </a>
@ -397,9 +397,15 @@ export default {
} }
let response = await this.sendEmail(data) let response = await this.sendEmail(data)
this.refreshTable() this.refreshTable()
if (response.data) { if (response.data.success) {
window.toastr['success'](this.$tc('invoices.send_invoice_successfully')) window.toastr['success'](this.$tc('invoices.send_invoice_successfully'))
return true
} }
if (response.data.error === 'user_email_does_not_exist') {
window.toastr['error'](this.$tc('invoices.user_email_does_not_exist'))
return false
}
window.toastr['error'](this.$tc('invoices.something_went_wrong'))
} }
}) })
}, },
@ -505,6 +511,7 @@ export default {
if (res.data.success) { if (res.data.success) {
window.toastr['success'](this.$tc('invoices.deleted_message')) window.toastr['success'](this.$tc('invoices.deleted_message'))
this.$refs.table.refresh()
return true return true
} }

View File

@ -260,9 +260,15 @@ export default {
this.isSendingEmail = true this.isSendingEmail = true
let response = await this.sendEmail({id: this.invoice.id}) let response = await this.sendEmail({id: this.invoice.id})
this.isSendingEmail = false this.isSendingEmail = false
if (response.data) { if (response.data.success) {
window.toastr['success'](this.$tc('invoices.confirm_send_invoice')) window.toastr['success'](this.$tc('invoices.send_invoice_successfully'))
return true
} }
if (response.data.error === 'user_email_does_not_exist') {
window.toastr['error'](this.$tc('invoices.user_email_does_not_exist'))
return false
}
window.toastr['error'](this.$tc('invoices.something_went_wrong'))
} }
}) })
}, },

View File

@ -166,7 +166,7 @@ export default {
user_id: null, user_id: null,
payment_number: null, payment_number: null,
payment_date: null, payment_date: null,
amount: 100, amount: 0,
payment_mode: null, payment_mode: null,
invoice_id: null, invoice_id: null,
notes: null notes: null