作者:Zulus
项目:Budgetariu
return (dispatch: Redux.Dispatch<any, IState>, getState: () => IState) => {
dispatch(endLoading(scope));
if (message) {
dispatch(addError(scope, message));
} else {
dispatch(addError(scope, "Some error"));
}
};
作者:Zulus
项目:Budgetariu
.then(response => {
const answer = response.data as any;
clientAccess.cache.reset();
if (!answer || !answer.wallets) {
throw Error("Server returns empty response");
} else {
dispatch(endLoading("wallets"));
dispatch(walletsLoadSuccess(answer.wallets as any));
}
})
作者:Zulus
项目:Budgetariu
.then((response: any) => {
if (!response.data) {
throw Error("Server returns empty response");
} else {
clientAccess.cache.reset();
const {token, expiredIn} = response.data.access;
dispatch(authUpdateAccessToken({token, expiredIn}));
dispatch(endLoading("auth"));
}
})
作者:Zulus
项目:Budgetariu
.then(response => {
const answer = (response.data as any);
clientAccess.cache.reset();
if (!answer) {
throw Error("Server returns empty response");
} else {
dispatch(endLoading("transactions"));
dispatch(removeTransactionFromSelectedWallet(id));
dispatch(transactionDeleteSuccess(id));
}
})
作者:Zulus
项目:Budgetariu
.then(response => {
dispatch(endLoading("transactions"));
if (!response.data) {
throw Error("Server returns empty response");
} else {
const w = (response.data.createTransaction as ITransactionCreateMutationResponse);
const transaction = {
...w,
};
dispatch(transactionCreationSuccess(transaction as any));
}
})
作者:Zulus
项目:Budgetariu
.then(response => {
dispatch(endLoading("wallet"));
if (!response.data) {
throw Error("Server returns empty response");
} else {
const w = (response.data.createWallet as IWalletCreateMutationResponse);
const wallet = {
...w,
ownerId: (w.owner.id as string)
};
dispatch(walletCreationSuccess(wallet as any));
}
})