mirror of
https://github.com/crater-invoice/crater.git
synced 2025-12-16 18:32:55 -05:00
init crater
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
// import * as types from './mutation-types'
|
||||
|
||||
export const loadData = ({ commit, dispatch, state }, id) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios.get(`/api/settings/company`).then((response) => {
|
||||
resolve(response)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const editCompany = ({ commit, dispatch, state }, data) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios.post('/api/settings/company', data, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
}).then((response) => {
|
||||
// commit(types.UPDATE_ITEM, response.data)
|
||||
resolve(response)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export const company = (state) => state.company
|
||||
@@ -0,0 +1,19 @@
|
||||
import mutations from './mutations'
|
||||
import * as actions from './actions'
|
||||
import * as getters from './getters'
|
||||
|
||||
const initialState = {
|
||||
company: null
|
||||
}
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
|
||||
state: initialState,
|
||||
|
||||
getters: getters,
|
||||
|
||||
actions: actions,
|
||||
|
||||
mutations: mutations
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export const SET_COMPANY = 'SET_COMPANY'
|
||||
export const UPDATE_COMPANY = 'UPDATE_COMPANY'
|
||||
@@ -0,0 +1,11 @@
|
||||
import * as types from './mutation-types'
|
||||
|
||||
export default {
|
||||
[types.SET_COMPANY] (state, data) {
|
||||
state.company = data.company
|
||||
},
|
||||
|
||||
[types.UPDATE_COMPANY] (state, data) {
|
||||
state.company = data
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import * as types from './mutation-types'
|
||||
|
||||
export const submitData = ({ commit, dispatch, state }, data) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios.post('/api/settings/general', data).then((response) => {
|
||||
// commit(types.SET_CATEGORIES, response.data)
|
||||
resolve(response)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const loadData = ({ commit, dispatch, state }) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios.get('/api/settings/general').then((response) => {
|
||||
commit(types.SET_INITIAL_DATA, response.data)
|
||||
resolve(response)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const setItemDiscount = ({ commit, dispatch, state }) => {
|
||||
commit(types.SET_ITEM_DISCOUNT)
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export const items = (state) => state.items
|
||||
export const itemDiscount = (state) => state.item_discount
|
||||
23
resources/assets/js/store/modules/settings/general/index.js
Normal file
23
resources/assets/js/store/modules/settings/general/index.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import mutations from './mutations'
|
||||
import * as actions from './actions'
|
||||
import * as getters from './getters'
|
||||
|
||||
const initialState = {
|
||||
currencies: null,
|
||||
time_zones: null,
|
||||
languages: null,
|
||||
date_formats: null,
|
||||
item_discount: false
|
||||
}
|
||||
|
||||
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 SET_ITEM_DISCOUNT = 'SET_ITEM_DISCOUNT'
|
||||
@@ -0,0 +1,14 @@
|
||||
import * as types from './mutation-types'
|
||||
|
||||
export default {
|
||||
[types.SET_INITIAL_DATA] (state, data) {
|
||||
state.currencies = data.currencies
|
||||
state.time_zones = data.time_zones
|
||||
state.languages = data.languages
|
||||
state.date_formats = data.date_formats
|
||||
},
|
||||
|
||||
[types.SET_ITEM_DISCOUNT] (state) {
|
||||
state.item_discount = true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import * as types from './mutation-types'
|
||||
|
||||
export const loadData = ({ commit, dispatch, state }, id) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios.get(`/api/settings/general`).then((response) => {
|
||||
resolve(response)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const editPreferences = ({ commit, dispatch, state }, data) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios.put('/api/settings/general', data).then((response) => {
|
||||
// commit(types.UPDATE_USER, response.data)
|
||||
commit(types.SET_MOMENT_DATE_FORMAT, data.moment_date_format)
|
||||
resolve(response)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export const getMomentDateFormat = (state) => state.momentDateFormat
|
||||
@@ -0,0 +1,19 @@
|
||||
import mutations from './mutations'
|
||||
import * as actions from './actions'
|
||||
import * as getters from './getters'
|
||||
|
||||
const initialState = {
|
||||
momentDateFormat: null
|
||||
}
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
|
||||
state: initialState,
|
||||
|
||||
getters: getters,
|
||||
|
||||
actions: actions,
|
||||
|
||||
mutations: mutations
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export const SET_MOMENT_DATE_FORMAT = 'SET_MOMENT_DATE_FORMAT'
|
||||
@@ -0,0 +1,7 @@
|
||||
import * as types from './mutation-types'
|
||||
|
||||
export default {
|
||||
[types.SET_MOMENT_DATE_FORMAT] (state, data) {
|
||||
state.momentDateFormat = data
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// import * as types from './mutation-types'
|
||||
|
||||
export const loadData = ({ commit, dispatch, state }, id) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios.get(`/api/settings/profile`).then((response) => {
|
||||
resolve(response)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export const editUser = ({ commit, dispatch, state }, data) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
window.axios.put('/api/settings/profile', data).then((response) => {
|
||||
// commit(types.UPDATE_USER, response.data)
|
||||
resolve(response)
|
||||
}).catch((err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export const user = (state) => state.user
|
||||
@@ -0,0 +1,19 @@
|
||||
import mutations from './mutations'
|
||||
import * as actions from './actions'
|
||||
import * as getters from './getters'
|
||||
|
||||
const initialState = {
|
||||
user: null
|
||||
}
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
|
||||
state: initialState,
|
||||
|
||||
getters: getters,
|
||||
|
||||
actions: actions,
|
||||
|
||||
mutations: mutations
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export const SET_USER = 'SET_USER'
|
||||
export const UPDATE_USER = 'UPDATE_USER'
|
||||
@@ -0,0 +1,11 @@
|
||||
import * as types from './mutation-types'
|
||||
|
||||
export default {
|
||||
[types.SET_USER] (state, data) {
|
||||
state.user = data.user
|
||||
},
|
||||
|
||||
[types.UPDATE_USER] (state, data) {
|
||||
state.user = data
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user