mirror of
https://github.com/crater-invoice/crater.git
synced 2025-12-16 18:32:55 -05:00
build version 400
This commit is contained in:
@@ -1,21 +1,23 @@
|
||||
|
||||
import * as types from './mutation-types'
|
||||
|
||||
export const loadData = ({ commit, dispatch, state }, params) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios.get(`/api/dashboard`, { params }).then((response) => {
|
||||
commit(types.SET_INITIAL_DATA, response.data)
|
||||
commit(types.GET_INITIAL_DATA, true)
|
||||
resolve(response)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
window.axios
|
||||
.get(`/api/v1/dashboard`, { params })
|
||||
.then((response) => {
|
||||
commit(types.SET_INITIAL_DATA, response.data)
|
||||
commit(types.SET_DASHBOARD_DATA_LOADED_STATE, true)
|
||||
resolve(response)
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// export const getChart = ({ commit, dispatch, state }) => {
|
||||
// return new Promise((resolve, reject) => {
|
||||
// window.axios.get(`/api/dashboard/expense/chart`).then((response) => {
|
||||
// window.axios.get(`/api/v1/dashboard/expense/chart`).then((response) => {
|
||||
// commit(types.SET_INITIAL_DATA, response.data)
|
||||
// resolve(response)
|
||||
// }).catch((err) => {
|
||||
|
||||
@@ -9,7 +9,7 @@ export const getTotalDueAmount = (state) => state.totalDueAmount
|
||||
export const getDueInvoices = (state) => state.dueInvoices
|
||||
export const getRecentEstimates = (state) => state.recentEstimates
|
||||
|
||||
export const getLoadedData = (state) => state.isDataLoaded
|
||||
export const getDashboardDataLoaded = (state) => state.isDashboardDataLoaded
|
||||
|
||||
export const getWeeklyInvoicesCounter = (state) => state.weeklyInvoices.counter
|
||||
export const getWeeklyInvoicesDays = (state) => state.weeklyInvoices.days
|
||||
|
||||
@@ -8,11 +8,11 @@ const initialState = {
|
||||
estimates: 0,
|
||||
expenses: 0,
|
||||
totalDueAmount: [],
|
||||
isDataLoaded: false,
|
||||
isDashboardDataLoaded: false,
|
||||
|
||||
weeklyInvoices: {
|
||||
days: [],
|
||||
counter: []
|
||||
counter: [],
|
||||
},
|
||||
|
||||
chartData: {
|
||||
@@ -20,7 +20,7 @@ const initialState = {
|
||||
invoiceTotals: [],
|
||||
expenseTotals: [],
|
||||
netProfits: [],
|
||||
receiptTotals: []
|
||||
receiptTotals: [],
|
||||
},
|
||||
|
||||
salesTotal: null,
|
||||
@@ -30,7 +30,7 @@ const initialState = {
|
||||
|
||||
dueInvoices: [],
|
||||
recentEstimates: [],
|
||||
newContacts: []
|
||||
newContacts: [],
|
||||
}
|
||||
|
||||
export default {
|
||||
@@ -42,5 +42,5 @@ export default {
|
||||
|
||||
actions: actions,
|
||||
|
||||
mutations: mutations
|
||||
mutations: mutations,
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export const SET_INITIAL_DATA = 'SET_INITIAL_DATA'
|
||||
export const GET_INITIAL_DATA = 'GET_INITIAL_DATA'
|
||||
export const SET_DASHBOARD_DATA_LOADED_STATE = 'SET_DASHBOARD_DATA_LOADED_STATE'
|
||||
export const DELETE_INVOICE = 'DELETE_INVOICE'
|
||||
export const UPDATE_INVOICE_STATUS = 'UPDATE_INVOICE_STATUS'
|
||||
export const DELETE_ESTIMATE = 'DELETE_ESTIMATE'
|
||||
export const UPDATE_ESTIMATE_STATUS = 'UPDATE_ESTIMATE_STATUS'
|
||||
export const UPDATE_ESTIMATE_STATUS = 'UPDATE_ESTIMATE_STATUS'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as types from './mutation-types'
|
||||
|
||||
export default {
|
||||
[types.SET_INITIAL_DATA] (state, data) {
|
||||
[types.SET_INITIAL_DATA](state, data) {
|
||||
state.contacts = data.customersCount
|
||||
state.invoices = data.invoicesCount
|
||||
state.estimates = data.estimatesCount
|
||||
@@ -30,33 +30,39 @@ export default {
|
||||
state.netProfit = data.netProfit
|
||||
},
|
||||
|
||||
[types.GET_INITIAL_DATA] (state, data) {
|
||||
state.isDataLoaded = data
|
||||
[types.SET_DASHBOARD_DATA_LOADED_STATE](state, data) {
|
||||
state.isDashboardDataLoaded = data
|
||||
},
|
||||
|
||||
[types.UPDATE_INVOICE_STATUS] (state, data) {
|
||||
let pos = state.dueInvoices.findIndex(invoice => invoice.id === data.id)
|
||||
[types.UPDATE_INVOICE_STATUS](state, data) {
|
||||
let pos = state.dueInvoices.findIndex((invoice) => invoice.id === data.id)
|
||||
|
||||
if (state.dueInvoices[pos]) {
|
||||
state.dueInvoices[pos].status = data.status
|
||||
}
|
||||
},
|
||||
|
||||
[types.DELETE_INVOICE] (state, id) {
|
||||
let index = state.dueInvoices.findIndex(invoice => invoice.id === id)
|
||||
[types.DELETE_INVOICE](state, data) {
|
||||
let index = state.dueInvoices.findIndex(
|
||||
(invoice) => invoice.id === data.ids[0]
|
||||
)
|
||||
state.dueInvoices.splice(index, 1)
|
||||
},
|
||||
|
||||
[types.DELETE_ESTIMATE] (state, id) {
|
||||
let index = state.recentEstimates.findIndex(estimate => estimate.id === id)
|
||||
[types.DELETE_ESTIMATE](state, data) {
|
||||
let index = state.recentEstimates.findIndex(
|
||||
(estimate) => estimate.id === data.ids[0]
|
||||
)
|
||||
state.recentEstimates.splice(index, 1)
|
||||
},
|
||||
|
||||
[types.UPDATE_ESTIMATE_STATUS] (state, data) {
|
||||
let pos = state.recentEstimates.findIndex(estimate => estimate.id === data.id)
|
||||
[types.UPDATE_ESTIMATE_STATUS](state, data) {
|
||||
let pos = state.recentEstimates.findIndex(
|
||||
(estimate) => estimate.id === data.id
|
||||
)
|
||||
|
||||
if (state.recentEstimates[pos]) {
|
||||
state.recentEstimates[pos].status = data.status
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user