init crater

This commit is contained in:
Mohit Panjwani
2019-11-11 12:16:00 +05:30
commit bdf2ba51d6
668 changed files with 158503 additions and 0 deletions

View 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 })
}

View 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
}
}

View 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
}

View File

@ -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'

View 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)
}
}