mirror of
				https://github.com/crater-invoice/crater.git
				synced 2025-10-31 05:31:10 -04:00 
			
		
		
		
	init crater
This commit is contained in:
		
							
								
								
									
										70
									
								
								resources/assets/js/store/modules/currency/actions.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								resources/assets/js/store/modules/currency/actions.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,70 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| // export const indexLoadData = ({ commit, dispatch, state }) => { | ||||
| //   return new Promise((resolve, reject) => { | ||||
| //     window.axios.get('/api/settings/currencies').then((response) => { | ||||
| //       commit(types.BOOTSTRAP_CURRENCIES, response.data) | ||||
| //       resolve(response) | ||||
| //     }).catch((err) => { | ||||
| //       reject(err) | ||||
| //     }) | ||||
| //   }) | ||||
| // } | ||||
|  | ||||
| // export const loadData = ({ commit, dispatch, state }, id) => { | ||||
| //   return new Promise((resolve, reject) => { | ||||
| //     window.axios.get(`/api/settings/currencies/${id}/edit`).then((response) => { | ||||
| //       resolve(response) | ||||
| //     }).catch((err) => { | ||||
| //       reject(err) | ||||
| //     }) | ||||
| //   }) | ||||
| // } | ||||
|  | ||||
| // export const addCurrency = ({ commit, dispatch, state }, data) => { | ||||
| //   return new Promise((resolve, reject) => { | ||||
| //     window.axios.post('/api/settings/currencies', data).then((response) => { | ||||
| //       commit(types.ADD_CURRENCY, response.data) | ||||
| //       resolve(response) | ||||
| //     }).catch((err) => { | ||||
| //       reject(err) | ||||
| //     }) | ||||
| //   }) | ||||
| // } | ||||
|  | ||||
| // export const editCurrency = ({ commit, dispatch, state }, data) => { | ||||
| //   return new Promise((resolve, reject) => { | ||||
| //     window.axios.put('/api/settings/currency_setting', data).then((response) => { | ||||
| //       resolve(response) | ||||
| //     }).catch((err) => { | ||||
| //       reject(err) | ||||
| //     }) | ||||
| //   }) | ||||
| // } | ||||
|  | ||||
| // export const removeItem = ({ commit, dispatch, state }, id) => { | ||||
| //   return new Promise((resolve, reject) => { | ||||
| //     window.axios.delete(`/api/settings/currencies/${id}`).then((response) => { | ||||
| //       resolve(response) | ||||
| //     }).catch((err) => { | ||||
| //       reject(err) | ||||
| //     }) | ||||
| //   }) | ||||
| // } | ||||
|  | ||||
| // export const selectCurrency = ({ commit, dispatch, state }) => { | ||||
| //   return new Promise((resolve, reject) => { | ||||
| //     let data = { | ||||
| //       currency: state.currencyId | ||||
| //     } | ||||
| //     window.axios.delete(`/api/settings/currency_setting`, data).then((response) => { | ||||
| //       resolve(response) | ||||
| //     }).catch((err) => { | ||||
| //       reject(err) | ||||
| //     }) | ||||
| //   }) | ||||
| // } | ||||
|  | ||||
| export const setDefaultCurrency = ({ commit, dispatch, state }, data) => { | ||||
|   commit(types.SET_DEFAULT_CURRENCY, { default_currency: data }) | ||||
| } | ||||
							
								
								
									
										21
									
								
								resources/assets/js/store/modules/currency/getters.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								resources/assets/js/store/modules/currency/getters.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,21 @@ | ||||
| export const currencies = (state) => state.currencies | ||||
| export const defaultCurrency = (state) => state.defaultCurrency | ||||
| export const defaultCurrencyForInput = (state) => { | ||||
|   if (state.defaultCurrency) { | ||||
|     return { | ||||
|       decimal: state.defaultCurrency.decimal_separator, | ||||
|       thousands: state.defaultCurrency.thousand_separator, | ||||
|       prefix: state.defaultCurrency.symbol + ' ', | ||||
|       precision: state.defaultCurrency.precision, | ||||
|       masked: false | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   return { | ||||
|     decimal: '.', | ||||
|     thousands: ',', | ||||
|     prefix: '$ ', | ||||
|     precision: 2, | ||||
|     masked: false | ||||
|   } | ||||
| } | ||||
							
								
								
									
										20
									
								
								resources/assets/js/store/modules/currency/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								resources/assets/js/store/modules/currency/index.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,20 @@ | ||||
| import mutations from './mutations' | ||||
| import * as actions from './actions' | ||||
| import * as getters from './getters' | ||||
|  | ||||
| const initialState = { | ||||
|   currencies: [], | ||||
|   defaultCurrency: null | ||||
| } | ||||
|  | ||||
| export default { | ||||
|   namespaced: true, | ||||
|  | ||||
|   state: initialState, | ||||
|  | ||||
|   getters: getters, | ||||
|  | ||||
|   actions: actions, | ||||
|  | ||||
|   mutations: mutations | ||||
| } | ||||
| @ -0,0 +1,5 @@ | ||||
| export const BOOTSTRAP_CURRENCIES = 'BOOTSTRAP_CURRENCIES' | ||||
| export const SET_DEFAULT_CURRENCY = 'SET_DEFAULT_CURRENCY' | ||||
| export const ADD_CURRENCY = 'ADD_CURRENCY' | ||||
| export const UPDATE_CURRENCY = 'UPDATE_CURRENCY' | ||||
| export const DELETE_CURRENCY = 'DELETE_CURRENCY' | ||||
							
								
								
									
										16
									
								
								resources/assets/js/store/modules/currency/mutations.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								resources/assets/js/store/modules/currency/mutations.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,16 @@ | ||||
| import * as types from './mutation-types' | ||||
|  | ||||
| export default { | ||||
|   [types.BOOTSTRAP_CURRENCIES] (state, data) { | ||||
|     state.currencies = data.currencies | ||||
|     state.currencyId = data.currencyId | ||||
|   }, | ||||
|  | ||||
|   [types.SET_DEFAULT_CURRENCY] (state, data) { | ||||
|     state.defaultCurrency = data.default_currency | ||||
|   }, | ||||
|  | ||||
|   [types.ADD_CURRENCY] (state, data) { | ||||
|     state.currencies.push(data) | ||||
|   } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user