release v2.0.0 #4
|
@ -1,5 +1,5 @@
|
||||||
import { Module, MutationTree, ActionTree, GetterTree } from 'vuex';
|
import { Module, MutationTree, ActionTree, GetterTree } from 'vuex';
|
||||||
import { StateInterface } from 'src/store';
|
import store, { StateInterface } from 'src/store';
|
||||||
import { axios } from 'src/boot/axios';
|
import { axios } from 'src/boot/axios';
|
||||||
import { AxiosResponse } from 'axios';
|
import { AxiosResponse } from 'axios';
|
||||||
|
|
||||||
|
@ -170,13 +170,20 @@ const actions: ActionTree<BalanceInterface, StateInterface> = {
|
||||||
dispatch('getBalance').catch(err => console.warn(err));
|
dispatch('getBalance').catch(err => console.warn(err));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
changeBalance({ dispatch, commit }, data: { amount: number; user: string; sender?: string }) {
|
changeBalance(
|
||||||
|
{ dispatch, commit, rootState },
|
||||||
|
data: { amount: number; user: string; sender?: string }
|
||||||
|
) {
|
||||||
commit('setLoading');
|
commit('setLoading');
|
||||||
return axios
|
return axios
|
||||||
.put(`/users/${data.user}/balance`, data)
|
.put(`/users/${data.user}/balance`, data)
|
||||||
.then((response: AxiosResponse<FG.Transaction>) => {
|
.then((response: AxiosResponse<FG.Transaction>) => {
|
||||||
const transaction = response.data;
|
const transaction = response.data;
|
||||||
fixTransaction(transaction);
|
fixTransaction(transaction);
|
||||||
|
if (
|
||||||
|
data.user == rootState.user.currentUser?.userid ||
|
||||||
|
data.sender === rootState.user.currentUser?.userid
|
||||||
|
)
|
||||||
commit('addTransaction', transaction);
|
commit('addTransaction', transaction);
|
||||||
commit(state.balances.has(data.user) ? 'changeBalance' : 'setBalance', {
|
commit(state.balances.has(data.user) ? 'changeBalance' : 'setBalance', {
|
||||||
userid: data.user,
|
userid: data.user,
|
||||||
|
|
Loading…
Reference in New Issue