mirror of
https://github.com/crater-invoice/crater.git
synced 2026-02-11 05:12:39 -05:00
build version 400
This commit is contained in:
@@ -3,3 +3,121 @@ import * as types from './mutation-types'
|
||||
export const setSelectedCompany = ({ commit, dispatch, state }, data) => {
|
||||
commit(types.SET_SELECTED_COMPANY, data)
|
||||
}
|
||||
|
||||
export const updateCompany = ({ commit, dispatch, state }, data) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios
|
||||
.put('/api/v1/company', data)
|
||||
.then((response) => {
|
||||
resolve(response)
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const updateCompanyLogo = ({ commit, dispatch, state }, data) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios
|
||||
.post('/api/v1/company/upload-logo', data)
|
||||
.then((response) => {
|
||||
resolve(response)
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const fetchCompanySettings = ({ commit, dispatch, state }, settings) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios
|
||||
.get('/api/v1/company/settings', {
|
||||
params: {
|
||||
settings,
|
||||
},
|
||||
})
|
||||
.then((response) => {
|
||||
resolve(response)
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const updateCompanySettings = ({ commit, dispatch, state }, data) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios
|
||||
.post('/api/v1/company/settings', data)
|
||||
.then((response) => {
|
||||
commit(types.SET_CARBON_DATE_FORMAT, data.settings.carbon_date_format)
|
||||
commit(types.SET_MOMENT_DATE_FORMAT, data.settings.moment_date_format)
|
||||
resolve(response)
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const setItemDiscount = ({ commit, dispatch, state }) => {
|
||||
commit(types.SET_ITEM_DISCOUNT)
|
||||
}
|
||||
|
||||
export const fetchMailDrivers = ({ commit, dispatch, state }) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios
|
||||
.get('/api/v1/mail/drivers')
|
||||
.then((response) => {
|
||||
resolve(response)
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const fetchMailConfig = ({ commit, dispatch, state }) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios
|
||||
.get('/api/v1/mail/config')
|
||||
.then((response) => {
|
||||
resolve(response)
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const updateMailConfig = ({ commit, dispatch, state }, data) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios
|
||||
.post('/api/v1/mail/config', data)
|
||||
.then((response) => {
|
||||
resolve(response)
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const sendTestMail = ({ commit, dispatch, state }, data) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios
|
||||
.post('/api/v1/mail/test', data)
|
||||
.then((response) => {
|
||||
resolve(response)
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const setDefaultCurrency = ({ commit, dispatch, state }, data) => {
|
||||
commit(types.SET_DEFAULT_CURRENCY, { default_currency: data })
|
||||
}
|
||||
|
||||
@@ -1,2 +1,33 @@
|
||||
export const getSelectedCompany = (state) => state.selectedCompany
|
||||
export const getCompanies = (state) => state.companies
|
||||
|
||||
export const getMomentDateFormat = (state) => state.momentDateFormat
|
||||
|
||||
export const getCarbonDateFormat = (state) => state.carbonDateFormat
|
||||
|
||||
export const itemDiscount = (state) => state.item_discount
|
||||
|
||||
export const defaultFiscalYear = (state) => state.defaultFiscalYear
|
||||
|
||||
export const defaultTimeZone = (state) => state.defaultTimeZone
|
||||
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,23 @@ import * as actions from './actions'
|
||||
import * as getters from './getters'
|
||||
|
||||
const initialState = {
|
||||
companies: [],
|
||||
|
||||
selectedCompany: null,
|
||||
companies: []
|
||||
|
||||
company: null,
|
||||
|
||||
momentDateFormat: null,
|
||||
|
||||
carbonDateFormat: null,
|
||||
|
||||
item_discount: false,
|
||||
|
||||
defaultFiscalYear: null,
|
||||
|
||||
defaultTimeZone: null,
|
||||
|
||||
defaultCurrency: null,
|
||||
}
|
||||
|
||||
export default {
|
||||
@@ -16,5 +31,5 @@ export default {
|
||||
|
||||
actions: actions,
|
||||
|
||||
mutations: mutations
|
||||
mutations: mutations,
|
||||
}
|
||||
|
||||
@@ -1,2 +1,15 @@
|
||||
export const BOOTSTRAP_COMPANIES = 'BOOTSTRAP_COMPANIES'
|
||||
|
||||
export const SET_SELECTED_COMPANY = 'SET_SELECTED_COMPANY'
|
||||
|
||||
export const SET_MOMENT_DATE_FORMAT = 'SET_MOMENT_DATE_FORMAT'
|
||||
|
||||
export const SET_CARBON_DATE_FORMAT = 'SET_CARBON_DATE_FORMAT'
|
||||
|
||||
export const SET_DEFAULT_FISCAL_YEAR = 'SET_DEFAULT_FISCAL_YEAR'
|
||||
|
||||
export const SET_DEFAULT_TIME_ZONE = 'SET_DEFAULT_TIME_ZONE'
|
||||
|
||||
export const SET_ITEM_DISCOUNT = 'SET_ITEM_DISCOUNT'
|
||||
|
||||
export const SET_DEFAULT_CURRENCY = 'SET_DEFAULT_CURRENCY'
|
||||
|
||||
@@ -2,12 +2,32 @@ import * as types from './mutation-types'
|
||||
import Ls from '@/services/ls'
|
||||
|
||||
export default {
|
||||
[types.BOOTSTRAP_COMPANIES] (state, companies) {
|
||||
state.companies = companies
|
||||
state.selectedCompany = companies[0]
|
||||
},
|
||||
[types.SET_SELECTED_COMPANY] (state, company) {
|
||||
[types.SET_SELECTED_COMPANY](state, company) {
|
||||
Ls.set('selectedCompany', company.id)
|
||||
state.selectedCompany = company
|
||||
}
|
||||
},
|
||||
|
||||
[types.SET_MOMENT_DATE_FORMAT](state, data) {
|
||||
state.momentDateFormat = data
|
||||
},
|
||||
|
||||
[types.SET_CARBON_DATE_FORMAT](state, data) {
|
||||
state.carbonDateFormat = data
|
||||
},
|
||||
|
||||
[types.SET_ITEM_DISCOUNT](state) {
|
||||
state.item_discount = true
|
||||
},
|
||||
|
||||
[types.SET_DEFAULT_FISCAL_YEAR](state, data) {
|
||||
state.defaultFiscalYear = data
|
||||
},
|
||||
|
||||
[types.SET_DEFAULT_TIME_ZONE](state, data) {
|
||||
state.defaultTimeZone = data
|
||||
},
|
||||
|
||||
[types.SET_DEFAULT_CURRENCY](state, data) {
|
||||
state.defaultCurrency = data.default_currency
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user