mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-30 05:01:10 -04:00
build version 400
This commit is contained in:
@ -1,31 +1,146 @@
|
||||
import * as types from './mutation-types'
|
||||
import * as currencyTypes from './modules/currency/mutation-types'
|
||||
import * as userTypes from './modules/user/mutation-types'
|
||||
import * as companyTypes from './modules/company/mutation-types'
|
||||
import * as preferencesTypes from './modules/settings/preferences/mutation-types'
|
||||
import * as taxTypeTypes from './modules/tax-type/mutation-types'
|
||||
import * as itemTypes from './modules/item/mutation-types'
|
||||
import * as paymentModes from './modules/payment/mutation-types'
|
||||
|
||||
export default {
|
||||
bootstrap ({ commit, dispatch, state }) {
|
||||
bootstrap({ commit, dispatch, state }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios.get('/api/bootstrap').then((response) => {
|
||||
commit('company/' + companyTypes.BOOTSTRAP_COMPANIES, response.data.companies)
|
||||
commit('company/' + companyTypes.SET_SELECTED_COMPANY, response.data.company)
|
||||
commit('currency/' + currencyTypes.BOOTSTRAP_CURRENCIES, response.data)
|
||||
commit('currency/' + currencyTypes.SET_DEFAULT_CURRENCY, response.data)
|
||||
commit('user/' + userTypes.BOOTSTRAP_CURRENT_USER, response.data.user)
|
||||
commit('taxType/' + taxTypeTypes.BOOTSTRAP_TAX_TYPES, response.data.taxTypes)
|
||||
commit('preferences/' + preferencesTypes.SET_MOMENT_DATE_FORMAT, response.data.moment_date_format)
|
||||
commit('preferences/' + preferencesTypes.SET_LANGUAGE_FORMAT, response.data.default_language)
|
||||
commit('item/' + itemTypes.SET_ITEM_UNITS, response.data.units)
|
||||
commit('payment/' + paymentModes.SET_PAYMENT_MODES, response.data.paymentMethods)
|
||||
commit(types.UPDATE_APP_LOADING_STATUS, true)
|
||||
resolve(response)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
window.axios
|
||||
.get('/api/v1/bootstrap')
|
||||
.then((response) => {
|
||||
commit('user/' + userTypes.BOOTSTRAP_CURRENT_USER, response.data.user)
|
||||
|
||||
commit(
|
||||
'company/' + companyTypes.SET_SELECTED_COMPANY,
|
||||
response.data.company
|
||||
)
|
||||
|
||||
commit('company/' + companyTypes.SET_DEFAULT_CURRENCY, response.data)
|
||||
|
||||
commit(
|
||||
'user/' + userTypes.SET_DEFAULT_LANGUAGE,
|
||||
response.data.default_language
|
||||
)
|
||||
|
||||
commit(
|
||||
'company/' + companyTypes.SET_MOMENT_DATE_FORMAT,
|
||||
response.data.moment_date_format
|
||||
)
|
||||
|
||||
commit(
|
||||
'company/' + companyTypes.SET_CARBON_DATE_FORMAT,
|
||||
response.data.carbon_date_format
|
||||
)
|
||||
|
||||
commit(
|
||||
'company/' + companyTypes.SET_DEFAULT_FISCAL_YEAR,
|
||||
response.data.fiscal_year
|
||||
)
|
||||
|
||||
commit(
|
||||
'company/' + companyTypes.SET_DEFAULT_TIME_ZONE,
|
||||
response.data.time_zone
|
||||
)
|
||||
|
||||
commit(types.SET_CURRENCIES, response.data.currencies)
|
||||
|
||||
commit(types.SET_COUNTRIES, response.data.countries)
|
||||
|
||||
commit(types.UPDATE_APP_LOADING_STATUS, true)
|
||||
|
||||
resolve(response)
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
fetchLanguages({ commit, dispatch, state }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios
|
||||
.get('/api/v1/languages')
|
||||
.then((response) => {
|
||||
commit(types.SET_LANGUAGES, response.data.languages)
|
||||
resolve(response)
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
fetchCurrencies({ commit, dispatch, state }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios
|
||||
.get('/api/v1/currencies')
|
||||
.then((response) => {
|
||||
commit(types.SET_CURRENCIES, response.data.currencies)
|
||||
resolve(response)
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
fetchDateFormats({ commit, dispatch, state }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios
|
||||
.get('/api/v1/date/formats')
|
||||
.then((response) => {
|
||||
commit(types.SET_DATE_FORMATS, response.data.date_formats)
|
||||
resolve(response)
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
fetchFiscalYears({ commit, dispatch, state }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios
|
||||
.get('/api/v1/fiscal/years')
|
||||
.then((response) => {
|
||||
commit(types.SET_FISCAL_YEARS, response.data.fiscal_years)
|
||||
resolve(response)
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
fetchTimeZones({ commit, dispatch, state }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios
|
||||
.get('/api/v1/timezones')
|
||||
.then((response) => {
|
||||
commit(types.SET_TIMEZONES, response.data.time_zones)
|
||||
resolve(response)
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
fetchCountries({ commit, dispatch, state }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios
|
||||
.get('/api/v1/countries')
|
||||
.then((response) => {
|
||||
commit(types.SET_COUNTRIES, response.data.countries)
|
||||
resolve(response)
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
toggleSidebar({ commit }) {
|
||||
commit(types.TOGGLE_SIDEBAR)
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user