release v2.0.0 #4
|
@ -1,5 +1,5 @@
|
|||
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 { AxiosResponse } from 'axios';
|
||||
|
||||
|
@ -170,13 +170,20 @@ const actions: ActionTree<BalanceInterface, StateInterface> = {
|
|||
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');
|
||||
return axios
|
||||
.put(`/users/${data.user}/balance`, data)
|
||||
.then((response: AxiosResponse<FG.Transaction>) => {
|
||||
const transaction = response.data;
|
||||
fixTransaction(transaction);
|
||||
if (
|
||||
data.user == rootState.user.currentUser?.userid ||
|
||||
data.sender === rootState.user.currentUser?.userid
|
||||
)
|
||||
commit('addTransaction', transaction);
|
||||
commit(state.balances.has(data.user) ? 'changeBalance' : 'setBalance', {
|
||||
userid: data.user,
|
||||
|
|
Loading…
Reference in New Issue