mirror of
				https://github.com/crater-invoice/crater.git
				synced 2025-10-30 21:21:09 -04:00 
			
		
		
		
	init crater
This commit is contained in:
		
							
								
								
									
										25
									
								
								resources/assets/js/store/modules/dashboard/actions.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								resources/assets/js/store/modules/dashboard/actions.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,25 @@ | ||||
|  | ||||
| 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) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
|  | ||||
| export const getChart = ({ commit, dispatch, state }) => { | ||||
|   return new Promise((resolve, reject) => { | ||||
|     window.axios.get(`/api/dashboard/expense/chart`).then((response) => { | ||||
|       commit(types.SET_INITIAL_DATA, response.data) | ||||
|       resolve(response) | ||||
|     }).catch((err) => { | ||||
|       reject(err) | ||||
|     }) | ||||
|   }) | ||||
| } | ||||
							
								
								
									
										26
									
								
								resources/assets/js/store/modules/dashboard/getters.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								resources/assets/js/store/modules/dashboard/getters.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,26 @@ | ||||
| export const getContacts = (state) => state.contacts | ||||
| export const getInvoices = (state) => state.invoices | ||||
| export const getEstimates = (state) => state.estimates | ||||
| export const getExpenses = (state) => state.expenses | ||||
| export const getRecentInvoices = (state) => state.recentInvoices | ||||
| export const getNewContacts = (state) => state.newContacts | ||||
| 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 getWeeklyInvoicesCounter = (state) => state.weeklyInvoices.counter | ||||
| export const getWeeklyInvoicesDays = (state) => state.weeklyInvoices.days | ||||
|  | ||||
| export const getChartMonths = (state) => state.chartData.months | ||||
| export const getChartInvoices = (state) => state.chartData.invoiceTotals | ||||
| export const getChartExpenses = (state) => state.chartData.expenseTotals | ||||
| export const getNetProfits = (state) => state.chartData.netProfits | ||||
| export const getReceiptTotals = (state) => state.chartData.receiptTotals | ||||
|  | ||||
| export const getTotalSales = (state) => state.salesTotal | ||||
| export const getTotalReceipts = (state) => state.totalReceipts | ||||
| export const getTotalExpenses = (state) => state.totalExpenses | ||||
| export const getNetProfit = (state) => state.netProfit | ||||
							
								
								
									
										46
									
								
								resources/assets/js/store/modules/dashboard/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								resources/assets/js/store/modules/dashboard/index.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,46 @@ | ||||
| import mutations from './mutations' | ||||
| import * as actions from './actions' | ||||
| import * as getters from './getters' | ||||
|  | ||||
| const initialState = { | ||||
|   contacts: 0, | ||||
|   invoices: 0, | ||||
|   estimates: 0, | ||||
|   expenses: 0, | ||||
|   totalDueAmount: [], | ||||
|   isDataLoaded: false, | ||||
|  | ||||
|   weeklyInvoices: { | ||||
|     days: [], | ||||
|     counter: [] | ||||
|   }, | ||||
|  | ||||
|   chartData: { | ||||
|     months: [], | ||||
|     invoiceTotals: [], | ||||
|     expenseTotals: [], | ||||
|     netProfits: [], | ||||
|     receiptTotals: [] | ||||
|   }, | ||||
|  | ||||
|   salesTotal: null, | ||||
|   totalReceipts: null, | ||||
|   totalExpenses: null, | ||||
|   netProfit: null, | ||||
|  | ||||
|   dueInvoices: [], | ||||
|   recentEstimates: [], | ||||
|   newContacts: [] | ||||
| } | ||||
|  | ||||
| export default { | ||||
|   namespaced: true, | ||||
|  | ||||
|   state: initialState, | ||||
|  | ||||
|   getters: getters, | ||||
|  | ||||
|   actions: actions, | ||||
|  | ||||
|   mutations: mutations | ||||
| } | ||||
| @ -0,0 +1,2 @@ | ||||
| export const SET_INITIAL_DATA = 'SET_INITIAL_DATA' | ||||
| export const GET_INITIAL_DATA = 'GET_INITIAL_DATA' | ||||
							
								
								
									
										36
									
								
								resources/assets/js/store/modules/dashboard/mutations.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								resources/assets/js/store/modules/dashboard/mutations.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,36 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export default { | ||||
|   [types.SET_INITIAL_DATA] (state, data) { | ||||
|     state.contacts = data.customersCount | ||||
|     state.invoices = data.invoicesCount | ||||
|     state.estimates = data.estimatesCount | ||||
|     state.expenses = data.expenses | ||||
|     state.recentInvoices = data.invoices | ||||
|     state.newContacts = data.contacts | ||||
|     state.totalDueAmount = data.totalDueAmount | ||||
|  | ||||
|     state.dueInvoices = data.dueInvoices | ||||
|     state.recentEstimates = data.estimates | ||||
|  | ||||
|     state.weeklyInvoices.days = data.weekDays | ||||
|     state.weeklyInvoices.counter = data.counters | ||||
|  | ||||
|     if (state.chartData && data.chartData) { | ||||
|       state.chartData.months = data.chartData.months | ||||
|       state.chartData.invoiceTotals = data.chartData.invoiceTotals | ||||
|       state.chartData.expenseTotals = data.chartData.expenseTotals | ||||
|       state.chartData.netProfits = data.chartData.netProfits | ||||
|       state.chartData.receiptTotals = data.chartData.receiptTotals | ||||
|     } | ||||
|  | ||||
|     state.salesTotal = data.salesTotal | ||||
|     state.totalReceipts = data.totalReceipts | ||||
|     state.totalExpenses = data.totalExpenses | ||||
|     state.netProfit = data.netProfit | ||||
|   }, | ||||
|  | ||||
|   [types.GET_INITIAL_DATA] (state, data) { | ||||
|     state.isDataLoaded = data | ||||
|   } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user