|
@@ -1,14 +1,53 @@
|
|
|
import axios from 'axios'
|
|
|
|
|
|
-const url = '/eiru_purchases/new'
|
|
|
+const newUrl = '/eiru_purchases/new'
|
|
|
+
|
|
|
+const createUrl = '/eiru_purchases/create'
|
|
|
|
|
|
const actions = {
|
|
|
+ /**
|
|
|
+ * Get all resources to init purchase app
|
|
|
+ * @param {*} param0
|
|
|
+ */
|
|
|
initPurchase({ dispatch }) {
|
|
|
- return axios.get(url).then(response => {
|
|
|
- console.log(response.data)
|
|
|
+ return axios.get(newUrl).then(response => {
|
|
|
+ dispatch('explodeData', response.data)
|
|
|
+ }).catch(error => {
|
|
|
+ console.log(error)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param {*} param0
|
|
|
+ * @param {*} payload
|
|
|
+ */
|
|
|
+ explodeData({ commit }, payload) {
|
|
|
+ commit('setDate', payload.date)
|
|
|
+ commit('setUser', payload.user)
|
|
|
+ commit('setCurrencies', payload.currencies)
|
|
|
+ commit('setProducts', payload.products)
|
|
|
+ commit('setPickingTypes', payload.pickingTypes)
|
|
|
+ commit('setPaymentTerms', payload.paymentTerms)
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * Send data to create concrete purchase
|
|
|
+ * @param {*} param0
|
|
|
+ */
|
|
|
+ createPurchase({ commit, dispatch }) {
|
|
|
+ return axios.post(createUrl, {
|
|
|
+
|
|
|
+ }).then(response => {
|
|
|
+ dispatch('resetPurchase')
|
|
|
}).catch(error => {
|
|
|
console.log(error)
|
|
|
})
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * Reset all default app state
|
|
|
+ * @param {*} param0
|
|
|
+ */
|
|
|
+ resetPurchase({ getters }) {
|
|
|
+ console.log('reseting')
|
|
|
}
|
|
|
}
|
|
|
|