mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 01:04:25 +08:00
code refactor
This commit is contained in:
+11
-25
@@ -12,7 +12,7 @@ import {
|
|||||||
UPDATE_ACCOUNT_LIST_INVALID_STATE
|
UPDATE_ACCOUNT_LIST_INVALID_STATE
|
||||||
} from './mutations.js';
|
} from './mutations.js';
|
||||||
|
|
||||||
function loadAllAccounts(context, { force }) {
|
export function loadAllAccounts(context, { force }) {
|
||||||
if (!force && !context.state.accountListStateInvalid) {
|
if (!force && !context.state.accountListStateInvalid) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
resolve(context.state.allAccounts);
|
resolve(context.state.allAccounts);
|
||||||
@@ -52,7 +52,7 @@ function loadAllAccounts(context, { force }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAccount(context, { accountId }) {
|
export function getAccount(context, { accountId }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
services.getAccount({
|
services.getAccount({
|
||||||
id: accountId
|
id: accountId
|
||||||
@@ -79,7 +79,7 @@ function getAccount(context, { accountId }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveAccount(context, { account }) {
|
export function saveAccount(context, { account }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let promise = null;
|
let promise = null;
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ function saveAccount(context, { account }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeAccountDisplayOrder(context, { accountId, from, to }) {
|
export function changeAccountDisplayOrder(context, { accountId, from, to }) {
|
||||||
const account = context.state.allAccountsMap[accountId];
|
const account = context.state.allAccountsMap[accountId];
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@@ -149,7 +149,7 @@ function changeAccountDisplayOrder(context, { accountId, from, to }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateAccountDisplayOrders(context) {
|
export function updateAccountDisplayOrders(context) {
|
||||||
const newDisplayOrders = [];
|
const newDisplayOrders = [];
|
||||||
|
|
||||||
for (let category in context.state.allCategorizedAccounts) {
|
for (let category in context.state.allCategorizedAccounts) {
|
||||||
@@ -195,7 +195,7 @@ function updateAccountDisplayOrders(context) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideAccount(context, { account, hidden }) {
|
export function hideAccount(context, { account, hidden }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
services.hideAccount({
|
services.hideAccount({
|
||||||
id: account.id,
|
id: account.id,
|
||||||
@@ -237,7 +237,7 @@ function hideAccount(context, { account, hidden }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteAccount(context, { account, beforeResolve }) {
|
export function deleteAccount(context, { account, beforeResolve }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
services.deleteAccount({
|
services.deleteAccount({
|
||||||
id: account.id
|
id: account.id
|
||||||
@@ -272,7 +272,7 @@ function deleteAccount(context, { account, beforeResolve }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function allPlainAccounts(state) {
|
export function allPlainAccounts(state) {
|
||||||
const allAccounts = [];
|
const allAccounts = [];
|
||||||
|
|
||||||
for (let i = 0; i < state.allAccounts.length; i++) {
|
for (let i = 0; i < state.allAccounts.length; i++) {
|
||||||
@@ -291,7 +291,7 @@ function allPlainAccounts(state) {
|
|||||||
return allAccounts;
|
return allAccounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
function allVisiblePlainAccounts(state) {
|
export function allVisiblePlainAccounts(state) {
|
||||||
const allVisibleAccounts = [];
|
const allVisibleAccounts = [];
|
||||||
|
|
||||||
for (let i = 0; i < state.allAccounts.length; i++) {
|
for (let i = 0; i < state.allAccounts.length; i++) {
|
||||||
@@ -314,7 +314,7 @@ function allVisiblePlainAccounts(state) {
|
|||||||
return allVisibleAccounts;
|
return allVisibleAccounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
function allAvailableAccountsCount(state) {
|
export function allAvailableAccountsCount(state) {
|
||||||
let allAccountCount = 0;
|
let allAccountCount = 0;
|
||||||
|
|
||||||
for (let category in state.allCategorizedAccounts) {
|
for (let category in state.allCategorizedAccounts) {
|
||||||
@@ -328,7 +328,7 @@ function allAvailableAccountsCount(state) {
|
|||||||
return allAccountCount;
|
return allAccountCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
function allVisibleAccountsCount(state) {
|
export function allVisibleAccountsCount(state) {
|
||||||
let shownAccountCount = 0;
|
let shownAccountCount = 0;
|
||||||
|
|
||||||
for (let category in state.allCategorizedAccounts) {
|
for (let category in state.allCategorizedAccounts) {
|
||||||
@@ -347,17 +347,3 @@ function allVisibleAccountsCount(state) {
|
|||||||
|
|
||||||
return shownAccountCount;
|
return shownAccountCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
|
||||||
loadAllAccounts,
|
|
||||||
getAccount,
|
|
||||||
saveAccount,
|
|
||||||
changeAccountDisplayOrder,
|
|
||||||
updateAccountDisplayOrders,
|
|
||||||
hideAccount,
|
|
||||||
deleteAccount,
|
|
||||||
allPlainAccounts,
|
|
||||||
allVisiblePlainAccounts,
|
|
||||||
allAvailableAccountsCount,
|
|
||||||
allVisibleAccountsCount,
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
|
|
||||||
const exchangeRatesLocalStorageKey = 'lab_app_exchange_rates';
|
const exchangeRatesLocalStorageKey = 'lab_app_exchange_rates';
|
||||||
|
|
||||||
function getLatestExchangeRates(context, { silent, force }) {
|
export function getLatestExchangeRates(context, { silent, force }) {
|
||||||
const currentExchangeRateData = context.state.latestExchangeRates;
|
const currentExchangeRateData = context.state.latestExchangeRates;
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
|
|
||||||
@@ -55,12 +55,12 @@ function getLatestExchangeRates(context, { silent, force }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function exchangeRatesLastUpdateDate(state) {
|
export function exchangeRatesLastUpdateDate(state) {
|
||||||
const exchangeRates = state.latestExchangeRates || {};
|
const exchangeRates = state.latestExchangeRates || {};
|
||||||
return exchangeRates && exchangeRates.data ? exchangeRates.data.date : null;
|
return exchangeRates && exchangeRates.data ? exchangeRates.data.date : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getExchangedAmount(state) {
|
export function getExchangedAmount(state) {
|
||||||
return (amount, fromCurrency, toCurrency) => {
|
return (amount, fromCurrency, toCurrency) => {
|
||||||
if (!state.latestExchangeRates || !state.latestExchangeRates.data || !state.latestExchangeRates.data.exchangeRates) {
|
if (!state.latestExchangeRates || !state.latestExchangeRates.data || !state.latestExchangeRates.data.exchangeRates) {
|
||||||
return null;
|
return null;
|
||||||
@@ -91,25 +91,16 @@ function getExchangedAmount(state) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function getExchangeRatesFromLocalStorage() {
|
export function getExchangeRatesFromLocalStorage() {
|
||||||
const storageData = localStorage.getItem(exchangeRatesLocalStorageKey) || '{}';
|
const storageData = localStorage.getItem(exchangeRatesLocalStorageKey) || '{}';
|
||||||
return JSON.parse(storageData);
|
return JSON.parse(storageData);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setExchangeRatesToLocalStorage(value) {
|
export function setExchangeRatesToLocalStorage(value) {
|
||||||
const storageData = JSON.stringify(value);
|
const storageData = JSON.stringify(value);
|
||||||
localStorage.setItem(exchangeRatesLocalStorageKey, storageData);
|
localStorage.setItem(exchangeRatesLocalStorageKey, storageData);
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearExchangeRatesFromLocalStorage() {
|
export function clearExchangeRatesFromLocalStorage() {
|
||||||
localStorage.removeItem(exchangeRatesLocalStorageKey);
|
localStorage.removeItem(exchangeRatesLocalStorageKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
|
||||||
getLatestExchangeRates,
|
|
||||||
exchangeRatesLastUpdateDate,
|
|
||||||
getExchangedAmount,
|
|
||||||
getExchangeRatesFromLocalStorage,
|
|
||||||
setExchangeRatesToLocalStorage,
|
|
||||||
clearExchangeRatesFromLocalStorage,
|
|
||||||
}
|
|
||||||
|
|||||||
+161
-73
@@ -40,20 +40,93 @@ import {
|
|||||||
UPDATE_TRANSACTION_TAG_LIST_INVALID_STATE,
|
UPDATE_TRANSACTION_TAG_LIST_INVALID_STATE,
|
||||||
} from './mutations.js';
|
} from './mutations.js';
|
||||||
|
|
||||||
import user from './user.js';
|
import {
|
||||||
import twoFactorAuth from './twoFactorAuth.js';
|
authorize,
|
||||||
import token from './token.js';
|
authorize2FA,
|
||||||
import exchangeRates from './exchangeRates.js';
|
register,
|
||||||
import account from './account.js';
|
logout,
|
||||||
import transaction from './transaction.js';
|
getCurrentUserProfile,
|
||||||
import transactionCategory from './transactionCategory.js';
|
updateUserProfile,
|
||||||
import transactionTag from './transactionTag.js';
|
clearUserInfoState,
|
||||||
|
resetState,
|
||||||
|
currentUserNickname,
|
||||||
|
currentUserDefaultCurrency,
|
||||||
|
} from './user.js';
|
||||||
|
|
||||||
|
import {
|
||||||
|
get2FAStatus,
|
||||||
|
enable2FA,
|
||||||
|
confirmEnable2FA,
|
||||||
|
disable2FA,
|
||||||
|
regenerate2FARecoveryCode,
|
||||||
|
} from './twoFactorAuth.js';
|
||||||
|
|
||||||
|
import {
|
||||||
|
getAllTokens,
|
||||||
|
refreshTokenAndRevokeOldToken,
|
||||||
|
revokeToken,
|
||||||
|
revokeAllTokens,
|
||||||
|
} from './token.js';
|
||||||
|
|
||||||
|
import {
|
||||||
|
getLatestExchangeRates,
|
||||||
|
exchangeRatesLastUpdateDate,
|
||||||
|
getExchangedAmount,
|
||||||
|
getExchangeRatesFromLocalStorage,
|
||||||
|
setExchangeRatesToLocalStorage,
|
||||||
|
clearExchangeRatesFromLocalStorage,
|
||||||
|
} from './exchangeRates.js';
|
||||||
|
|
||||||
|
import {
|
||||||
|
loadAllAccounts,
|
||||||
|
getAccount,
|
||||||
|
saveAccount,
|
||||||
|
changeAccountDisplayOrder,
|
||||||
|
updateAccountDisplayOrders,
|
||||||
|
hideAccount,
|
||||||
|
deleteAccount,
|
||||||
|
allPlainAccounts,
|
||||||
|
allVisiblePlainAccounts,
|
||||||
|
allAvailableAccountsCount,
|
||||||
|
allVisibleAccountsCount,
|
||||||
|
} from './account.js';
|
||||||
|
|
||||||
|
import {
|
||||||
|
getTransactions,
|
||||||
|
getTransaction,
|
||||||
|
saveTransaction,
|
||||||
|
deleteTransaction,
|
||||||
|
collapseMonthInTransactionList,
|
||||||
|
noTransaction,
|
||||||
|
hasMoreTransaction,
|
||||||
|
calculateMonthTotalAmount,
|
||||||
|
} from './transaction.js';
|
||||||
|
|
||||||
|
import {
|
||||||
|
loadAllCategories,
|
||||||
|
getCategory,
|
||||||
|
saveCategory,
|
||||||
|
addCategories,
|
||||||
|
changeCategoryDisplayOrder,
|
||||||
|
updateCategoryDisplayOrders,
|
||||||
|
hideCategory,
|
||||||
|
deleteCategory,
|
||||||
|
} from './transactionCategory.js';
|
||||||
|
|
||||||
|
import {
|
||||||
|
loadAllTags,
|
||||||
|
saveTag,
|
||||||
|
changeTagDisplayOrder,
|
||||||
|
updateTagDisplayOrders,
|
||||||
|
hideTag,
|
||||||
|
deleteTag,
|
||||||
|
} from './transactionTag.js';
|
||||||
|
|
||||||
const stores = {
|
const stores = {
|
||||||
strict: process.env.NODE_ENV !== 'production',
|
strict: process.env.NODE_ENV !== 'production',
|
||||||
state: {
|
state: {
|
||||||
currentUserInfo: userState.getUserInfo(),
|
currentUserInfo: userState.getUserInfo(),
|
||||||
latestExchangeRates: exchangeRates.getExchangeRatesFromLocalStorage(),
|
latestExchangeRates: getExchangeRatesFromLocalStorage(),
|
||||||
allAccounts: [],
|
allAccounts: [],
|
||||||
allAccountsMap: {},
|
allAccountsMap: {},
|
||||||
allCategorizedAccounts: {},
|
allCategorizedAccounts: {},
|
||||||
@@ -69,16 +142,23 @@ const stores = {
|
|||||||
transactionTagListStateInvalid: true,
|
transactionTagListStateInvalid: true,
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
currentUserNickname: user.currentUserNickname,
|
// user
|
||||||
currentUserDefaultCurrency: user.currentUserDefaultCurrency,
|
currentUserNickname,
|
||||||
exchangeRatesLastUpdateDate: exchangeRates.exchangeRatesLastUpdateDate,
|
currentUserDefaultCurrency,
|
||||||
getExchangedAmount: exchangeRates.getExchangedAmount,
|
|
||||||
allPlainAccounts: account.allPlainAccounts,
|
// exchange rates
|
||||||
allVisiblePlainAccounts: account.allVisiblePlainAccounts,
|
exchangeRatesLastUpdateDate,
|
||||||
allAvailableAccountsCount: account.allAvailableAccountsCount,
|
getExchangedAmount,
|
||||||
allVisibleAccountsCount: account.allVisibleAccountsCount,
|
|
||||||
noTransaction: transaction.noTransaction,
|
// account
|
||||||
hasMoreTransaction: transaction.hasMoreTransaction,
|
allPlainAccounts,
|
||||||
|
allVisiblePlainAccounts,
|
||||||
|
allAvailableAccountsCount,
|
||||||
|
allVisibleAccountsCount,
|
||||||
|
|
||||||
|
// transaction
|
||||||
|
noTransaction,
|
||||||
|
hasMoreTransaction,
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
[RESET_STATE] (state) {
|
[RESET_STATE] (state) {
|
||||||
@@ -101,7 +181,7 @@ const stores = {
|
|||||||
state.allTransactionTagsMap = {};
|
state.allTransactionTagsMap = {};
|
||||||
state.transactionTagListStateInvalid = true;
|
state.transactionTagListStateInvalid = true;
|
||||||
|
|
||||||
exchangeRates.clearExchangeRatesFromLocalStorage();
|
clearExchangeRatesFromLocalStorage();
|
||||||
},
|
},
|
||||||
[STORE_USER_INFO] (state, userInfo) {
|
[STORE_USER_INFO] (state, userInfo) {
|
||||||
state.currentUserInfo = userInfo;
|
state.currentUserInfo = userInfo;
|
||||||
@@ -113,7 +193,7 @@ const stores = {
|
|||||||
},
|
},
|
||||||
[STORE_LATEST_EXCHANGE_RATES] (state, latestExchangeRates) {
|
[STORE_LATEST_EXCHANGE_RATES] (state, latestExchangeRates) {
|
||||||
state.latestExchangeRates = latestExchangeRates;
|
state.latestExchangeRates = latestExchangeRates;
|
||||||
exchangeRates.setExchangeRatesToLocalStorage(latestExchangeRates);
|
setExchangeRatesToLocalStorage(latestExchangeRates);
|
||||||
},
|
},
|
||||||
[LOAD_ACCOUNT_LIST] (state, accounts) {
|
[LOAD_ACCOUNT_LIST] (state, accounts) {
|
||||||
state.allAccounts = accounts;
|
state.allAccounts = accounts;
|
||||||
@@ -296,7 +376,7 @@ const stores = {
|
|||||||
|
|
||||||
if (currentMonthList && currentMonthList.year === transactionYear && currentMonthList.month === transactionMonth) {
|
if (currentMonthList && currentMonthList.year === transactionYear && currentMonthList.month === transactionMonth) {
|
||||||
currentMonthList.items.push(item);
|
currentMonthList.items.push(item);
|
||||||
transaction.calculateMonthTotalAmount(state, currentMonthList, defaultCurrency, accountId, true);
|
calculateMonthTotalAmount(state, currentMonthList, defaultCurrency, accountId, true);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,7 +386,7 @@ const stores = {
|
|||||||
currentMonthList = state.transactions[j];
|
currentMonthList = state.transactions[j];
|
||||||
|
|
||||||
if (j > 0) {
|
if (j > 0) {
|
||||||
transaction.calculateMonthTotalAmount(state, state.transactions[j - 1], defaultCurrency, accountId, false);
|
calculateMonthTotalAmount(state, state.transactions[j - 1], defaultCurrency, accountId, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -314,11 +394,11 @@ const stores = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!currentMonthList && state.transactions.length > 0) {
|
if (!currentMonthList && state.transactions.length > 0) {
|
||||||
transaction.calculateMonthTotalAmount(state, state.transactions[state.transactions.length - 1], defaultCurrency, accountId, false);
|
calculateMonthTotalAmount(state, state.transactions[state.transactions.length - 1], defaultCurrency, accountId, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!currentMonthList || currentMonthList.year !== transactionYear || currentMonthList.month !== transactionMonth) {
|
if (!currentMonthList || currentMonthList.year !== transactionYear || currentMonthList.month !== transactionMonth) {
|
||||||
transaction.calculateMonthTotalAmount(state, currentMonthList, defaultCurrency, accountId, false);
|
calculateMonthTotalAmount(state, currentMonthList, defaultCurrency, accountId, false);
|
||||||
|
|
||||||
state.transactions.push({
|
state.transactions.push({
|
||||||
year: transactionYear,
|
year: transactionYear,
|
||||||
@@ -333,14 +413,14 @@ const stores = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
currentMonthList.items.push(item);
|
currentMonthList.items.push(item);
|
||||||
transaction.calculateMonthTotalAmount(state, currentMonthList, defaultCurrency, accountId, true);
|
calculateMonthTotalAmount(state, currentMonthList, defaultCurrency, accountId, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (transactions.nextTimeSequenceId) {
|
if (transactions.nextTimeSequenceId) {
|
||||||
state.transactionsNextTimeId = transactions.nextTimeSequenceId;
|
state.transactionsNextTimeId = transactions.nextTimeSequenceId;
|
||||||
} else {
|
} else {
|
||||||
transaction.calculateMonthTotalAmount(state, state.transactions[state.transactions.length - 1], defaultCurrency, accountId, false);
|
calculateMonthTotalAmount(state, state.transactions[state.transactions.length - 1], defaultCurrency, accountId, false);
|
||||||
state.transactionsNextTimeId = -1;
|
state.transactionsNextTimeId = -1;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -362,7 +442,7 @@ const stores = {
|
|||||||
for (let j = 0; j < transactionMonthList.items.length; j++) {
|
for (let j = 0; j < transactionMonthList.items.length; j++) {
|
||||||
if (transactionMonthList.items[j].id === transaction.id) {
|
if (transactionMonthList.items[j].id === transaction.id) {
|
||||||
transactionMonthList.items.splice(j, 1, transaction);
|
transactionMonthList.items.splice(j, 1, transaction);
|
||||||
transaction.calculateMonthTotalAmount(state, transactionMonthList, defaultCurrency, accountId, i >= state.transactions.length - 1 && state.transactionsNextTimeId > 0);
|
calculateMonthTotalAmount(state, transactionMonthList, defaultCurrency, accountId, i >= state.transactions.length - 1 && state.transactionsNextTimeId > 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -387,7 +467,7 @@ const stores = {
|
|||||||
if (transactionMonthList.items.length < 1) {
|
if (transactionMonthList.items.length < 1) {
|
||||||
state.transactions.splice(i, 1);
|
state.transactions.splice(i, 1);
|
||||||
} else {
|
} else {
|
||||||
transaction.calculateMonthTotalAmount(state, transactionMonthList, defaultCurrency, accountId, i >= state.transactions.length - 1 && state.transactionsNextTimeId > 0);
|
calculateMonthTotalAmount(state, transactionMonthList, defaultCurrency, accountId, i >= state.transactions.length - 1 && state.transactionsNextTimeId > 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -553,57 +633,65 @@ const stores = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
authorize: user.authorize,
|
// user
|
||||||
authorize2FA: user.authorize2FA,
|
authorize,
|
||||||
register: user.register,
|
authorize2FA,
|
||||||
logout: user.logout,
|
register,
|
||||||
getCurrentUserProfile: user.getCurrentUserProfile,
|
logout,
|
||||||
updateUserProfile: user.updateUserProfile,
|
getCurrentUserProfile,
|
||||||
clearUserInfoState: user.clearUserInfoState,
|
updateUserProfile,
|
||||||
resetState: user.resetState,
|
clearUserInfoState,
|
||||||
|
resetState,
|
||||||
|
|
||||||
get2FAStatus: twoFactorAuth.get2FAStatus,
|
// 2fa
|
||||||
enable2FA: twoFactorAuth.enable2FA,
|
get2FAStatus,
|
||||||
confirmEnable2FA: twoFactorAuth.confirmEnable2FA,
|
enable2FA,
|
||||||
disable2FA: twoFactorAuth.disable2FA,
|
confirmEnable2FA,
|
||||||
regenerate2FARecoveryCode: twoFactorAuth.regenerate2FARecoveryCode,
|
disable2FA,
|
||||||
|
regenerate2FARecoveryCode,
|
||||||
|
|
||||||
getAllTokens: token.getAllTokens,
|
// token
|
||||||
refreshTokenAndRevokeOldToken: token.refreshTokenAndRevokeOldToken,
|
getAllTokens,
|
||||||
revokeToken: token.revokeToken,
|
refreshTokenAndRevokeOldToken,
|
||||||
revokeAllTokens: token.revokeAllTokens,
|
revokeToken,
|
||||||
|
revokeAllTokens,
|
||||||
|
|
||||||
getLatestExchangeRates: exchangeRates.getLatestExchangeRates,
|
// exchange rates
|
||||||
|
getLatestExchangeRates,
|
||||||
|
|
||||||
loadAllAccounts: account.loadAllAccounts,
|
// account
|
||||||
saveAccount: account.saveAccount,
|
loadAllAccounts,
|
||||||
getAccount: account.getAccount,
|
saveAccount,
|
||||||
changeAccountDisplayOrder: account.changeAccountDisplayOrder,
|
getAccount,
|
||||||
updateAccountDisplayOrders: account.updateAccountDisplayOrders,
|
changeAccountDisplayOrder,
|
||||||
hideAccount: account.hideAccount,
|
updateAccountDisplayOrders,
|
||||||
deleteAccount: account.deleteAccount,
|
hideAccount,
|
||||||
|
deleteAccount,
|
||||||
|
|
||||||
getTransactions: transaction.getTransactions,
|
// transaction
|
||||||
getTransaction: transaction.getTransaction,
|
getTransactions,
|
||||||
saveTransaction: transaction.saveTransaction,
|
getTransaction,
|
||||||
deleteTransaction: transaction.deleteTransaction,
|
saveTransaction,
|
||||||
collapseMonthInTransactionList: transaction.collapseMonthInTransactionList,
|
deleteTransaction,
|
||||||
|
collapseMonthInTransactionList,
|
||||||
|
|
||||||
loadAllCategories: transactionCategory.loadAllCategories,
|
// transaction category
|
||||||
getCategory: transactionCategory.getCategory,
|
loadAllCategories,
|
||||||
saveCategory: transactionCategory.saveCategory,
|
getCategory,
|
||||||
addCategories: transactionCategory.addCategories,
|
saveCategory,
|
||||||
changeCategoryDisplayOrder: transactionCategory.changeCategoryDisplayOrder,
|
addCategories,
|
||||||
updateCategoryDisplayOrders: transactionCategory.updateCategoryDisplayOrders,
|
changeCategoryDisplayOrder,
|
||||||
hideCategory: transactionCategory.hideCategory,
|
updateCategoryDisplayOrders,
|
||||||
deleteCategory: transactionCategory.deleteCategory,
|
hideCategory,
|
||||||
|
deleteCategory,
|
||||||
|
|
||||||
loadAllTags: transactionTag.loadAllTags,
|
// transaction tag
|
||||||
saveTag: transactionTag.saveTag,
|
loadAllTags,
|
||||||
changeTagDisplayOrder: transactionTag.changeTagDisplayOrder,
|
saveTag,
|
||||||
updateTagDisplayOrders: transactionTag.updateTagDisplayOrders,
|
changeTagDisplayOrder,
|
||||||
hideTag: transactionTag.hideTag,
|
updateTagDisplayOrders,
|
||||||
deleteTag: transactionTag.deleteTag,
|
hideTag,
|
||||||
|
deleteTag,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+4
-11
@@ -7,7 +7,7 @@ import {
|
|||||||
STORE_USER_INFO
|
STORE_USER_INFO
|
||||||
} from './mutations.js';
|
} from './mutations.js';
|
||||||
|
|
||||||
function getAllTokens() {
|
export function getAllTokens() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
services.getTokens().then(response => {
|
services.getTokens().then(response => {
|
||||||
const data = response.data;
|
const data = response.data;
|
||||||
@@ -32,7 +32,7 @@ function getAllTokens() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshTokenAndRevokeOldToken(context) {
|
export function refreshTokenAndRevokeOldToken(context) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
services.refreshToken().then(response => {
|
services.refreshToken().then(response => {
|
||||||
const data = response.data;
|
const data = response.data;
|
||||||
@@ -57,7 +57,7 @@ function refreshTokenAndRevokeOldToken(context) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function revokeToken(context, { tokenId, ignoreError }) {
|
export function revokeToken(context, { tokenId, ignoreError }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
services.revokeToken({
|
services.revokeToken({
|
||||||
tokenId: tokenId,
|
tokenId: tokenId,
|
||||||
@@ -85,7 +85,7 @@ function revokeToken(context, { tokenId, ignoreError }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function revokeAllTokens() {
|
export function revokeAllTokens() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
services.revokeAllTokens().then(response => {
|
services.revokeAllTokens().then(response => {
|
||||||
const data = response.data;
|
const data = response.data;
|
||||||
@@ -109,10 +109,3 @@ function revokeAllTokens() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
|
||||||
getAllTokens,
|
|
||||||
refreshTokenAndRevokeOldToken,
|
|
||||||
revokeToken,
|
|
||||||
revokeAllTokens
|
|
||||||
}
|
|
||||||
|
|||||||
+11
-21
@@ -1,9 +1,10 @@
|
|||||||
import transactionConstants from '../consts/transaction.js';
|
import transactionConstants from '../consts/transaction.js';
|
||||||
import exchangeRates from "./exchangeRates.js";
|
|
||||||
import services from '../lib/services.js';
|
import services from '../lib/services.js';
|
||||||
import logger from '../lib/logger.js';
|
import logger from '../lib/logger.js';
|
||||||
import utils from '../lib/utils.js';
|
import utils from '../lib/utils.js';
|
||||||
|
|
||||||
|
import { getExchangedAmount } from "./exchangeRates.js";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
LOAD_TRANSACTION_LIST,
|
LOAD_TRANSACTION_LIST,
|
||||||
COLLAPSE_MONTH_IN_TRANSACTION_LIST,
|
COLLAPSE_MONTH_IN_TRANSACTION_LIST,
|
||||||
@@ -17,7 +18,7 @@ const emptyTransactionResult = {
|
|||||||
transactionsNextTimeId: 0
|
transactionsNextTimeId: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
function getTransactions(context, { reload, autoExpand, defaultCurrency, maxTime, minTime, type, categoryId, accountId, keyword }) {
|
export function getTransactions(context, { reload, autoExpand, defaultCurrency, maxTime, minTime, type, categoryId, accountId, keyword }) {
|
||||||
let actualMaxTime = context.state.transactionsNextTimeId;
|
let actualMaxTime = context.state.transactionsNextTimeId;
|
||||||
|
|
||||||
if (reload && maxTime > 0) {
|
if (reload && maxTime > 0) {
|
||||||
@@ -91,7 +92,7 @@ function getTransactions(context, { reload, autoExpand, defaultCurrency, maxTime
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTransaction(context, { transactionId }) {
|
export function getTransaction(context, { transactionId }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
services.getTransaction({
|
services.getTransaction({
|
||||||
id: transactionId
|
id: transactionId
|
||||||
@@ -118,7 +119,7 @@ function getTransaction(context, { transactionId }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveTransaction(context, { transaction }) {
|
export function saveTransaction(context, { transaction }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let promise = null;
|
let promise = null;
|
||||||
|
|
||||||
@@ -167,7 +168,7 @@ function saveTransaction(context, { transaction }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteTransaction(context, { transaction, defaultCurrency, accountId, beforeResolve }) {
|
export function deleteTransaction(context, { transaction, defaultCurrency, accountId, beforeResolve }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
services.deleteTransaction({
|
services.deleteTransaction({
|
||||||
id: transaction.id
|
id: transaction.id
|
||||||
@@ -212,14 +213,14 @@ function deleteTransaction(context, { transaction, defaultCurrency, accountId, b
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function collapseMonthInTransactionList(context, { month, collapse }) {
|
export function collapseMonthInTransactionList(context, { month, collapse }) {
|
||||||
context.commit(COLLAPSE_MONTH_IN_TRANSACTION_LIST, {
|
context.commit(COLLAPSE_MONTH_IN_TRANSACTION_LIST, {
|
||||||
month: month,
|
month: month,
|
||||||
collapse: collapse
|
collapse: collapse
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function noTransaction(state) {
|
export function noTransaction(state) {
|
||||||
for (let i = 0; i < state.transactions.length; i++) {
|
for (let i = 0; i < state.transactions.length; i++) {
|
||||||
const transactionMonthList = state.transactions[i];
|
const transactionMonthList = state.transactions[i];
|
||||||
|
|
||||||
@@ -233,11 +234,11 @@ function noTransaction(state) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasMoreTransaction(state) {
|
export function hasMoreTransaction(state) {
|
||||||
return state.transactionsNextTimeId > 0;
|
return state.transactionsNextTimeId > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function calculateMonthTotalAmount(state, transactionMonthList, defaultCurrency, accountId, incomplete) {
|
export function calculateMonthTotalAmount(state, transactionMonthList, defaultCurrency, accountId, incomplete) {
|
||||||
if (!transactionMonthList) {
|
if (!transactionMonthList) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -257,7 +258,7 @@ function calculateMonthTotalAmount(state, transactionMonthList, defaultCurrency,
|
|||||||
let amount = transaction.sourceAmount;
|
let amount = transaction.sourceAmount;
|
||||||
|
|
||||||
if (transaction.sourceAccount.currency !== defaultCurrency) {
|
if (transaction.sourceAccount.currency !== defaultCurrency) {
|
||||||
const balance = exchangeRates.getExchangedAmount(state)(amount, transaction.sourceAccount.currency, defaultCurrency);
|
const balance = getExchangedAmount(state)(amount, transaction.sourceAccount.currency, defaultCurrency);
|
||||||
|
|
||||||
if (!utils.isNumber(balance)) {
|
if (!utils.isNumber(balance)) {
|
||||||
if (transaction.type === transactionConstants.allTransactionTypes.Expense) {
|
if (transaction.type === transactionConstants.allTransactionTypes.Expense) {
|
||||||
@@ -292,14 +293,3 @@ function calculateMonthTotalAmount(state, transactionMonthList, defaultCurrency,
|
|||||||
incompleteIncome: incomplete || hasUnCalculatedTotalIncome
|
incompleteIncome: incomplete || hasUnCalculatedTotalIncome
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
|
||||||
getTransactions,
|
|
||||||
getTransaction,
|
|
||||||
saveTransaction,
|
|
||||||
deleteTransaction,
|
|
||||||
collapseMonthInTransactionList,
|
|
||||||
noTransaction,
|
|
||||||
hasMoreTransaction,
|
|
||||||
calculateMonthTotalAmount
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import {
|
|||||||
UPDATE_TRANSACTION_CATEGORY_LIST_INVALID_STATE,
|
UPDATE_TRANSACTION_CATEGORY_LIST_INVALID_STATE,
|
||||||
} from './mutations.js';
|
} from './mutations.js';
|
||||||
|
|
||||||
function loadAllCategories(context, { force }) {
|
export function loadAllCategories(context, { force }) {
|
||||||
if (!force && !context.state.transactionCategoryListStateInvalid) {
|
if (!force && !context.state.transactionCategoryListStateInvalid) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
resolve(context.state.allTransactionCategories);
|
resolve(context.state.allTransactionCategories);
|
||||||
@@ -78,7 +78,7 @@ function loadAllCategories(context, { force }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCategory(context, { categoryId }) {
|
export function getCategory(context, { categoryId }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
services.getTransactionCategory({
|
services.getTransactionCategory({
|
||||||
id: categoryId
|
id: categoryId
|
||||||
@@ -105,7 +105,7 @@ function getCategory(context, { categoryId }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveCategory(context, { category }) {
|
export function saveCategory(context, { category }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let promise = null;
|
let promise = null;
|
||||||
|
|
||||||
@@ -156,7 +156,7 @@ function saveCategory(context, { category }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function addCategories(context, { categories }) {
|
export function addCategories(context, { categories }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
services.addTransactionCategoryBatch({
|
services.addTransactionCategoryBatch({
|
||||||
categories: categories
|
categories: categories
|
||||||
@@ -185,7 +185,7 @@ function addCategories(context, { categories }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeCategoryDisplayOrder(context, { categoryId, from, to }) {
|
export function changeCategoryDisplayOrder(context, { categoryId, from, to }) {
|
||||||
const category = context.state.allTransactionCategoriesMap[categoryId];
|
const category = context.state.allTransactionCategoriesMap[categoryId];
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@@ -219,7 +219,7 @@ function changeCategoryDisplayOrder(context, { categoryId, from, to }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateCategoryDisplayOrders(context, { type, parentId }) {
|
export function updateCategoryDisplayOrders(context, { type, parentId }) {
|
||||||
const newDisplayOrders = [];
|
const newDisplayOrders = [];
|
||||||
|
|
||||||
let categoryList = null;
|
let categoryList = null;
|
||||||
@@ -267,7 +267,7 @@ function updateCategoryDisplayOrders(context, { type, parentId }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideCategory(context, { category, hidden }) {
|
export function hideCategory(context, { category, hidden }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
services.hideTransactionCategory({
|
services.hideTransactionCategory({
|
||||||
id: category.id,
|
id: category.id,
|
||||||
@@ -309,7 +309,7 @@ function hideCategory(context, { category, hidden }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteCategory(context, { category, beforeResolve }) {
|
export function deleteCategory(context, { category, beforeResolve }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
services.deleteTransactionCategory({
|
services.deleteTransactionCategory({
|
||||||
id: category.id
|
id: category.id
|
||||||
@@ -343,14 +343,3 @@ function deleteCategory(context, { category, beforeResolve }) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
|
||||||
loadAllCategories,
|
|
||||||
getCategory,
|
|
||||||
saveCategory,
|
|
||||||
addCategories,
|
|
||||||
changeCategoryDisplayOrder,
|
|
||||||
updateCategoryDisplayOrders,
|
|
||||||
hideCategory,
|
|
||||||
deleteCategory,
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
UPDATE_TRANSACTION_TAG_LIST_INVALID_STATE,
|
UPDATE_TRANSACTION_TAG_LIST_INVALID_STATE,
|
||||||
} from './mutations.js';
|
} from './mutations.js';
|
||||||
|
|
||||||
function loadAllTags(context, { force }) {
|
export function loadAllTags(context, { force }) {
|
||||||
if (!force && !context.state.transactionTagListStateInvalid) {
|
if (!force && !context.state.transactionTagListStateInvalid) {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
resolve(context.state.allTransactionTags);
|
resolve(context.state.allTransactionTags);
|
||||||
@@ -49,7 +49,7 @@ function loadAllTags(context, { force }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveTag(context, { tag }) {
|
export function saveTag(context, { tag }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let promise = null;
|
let promise = null;
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ function saveTag(context, { tag }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeTagDisplayOrder(context, { tagId, from, to }) {
|
export function changeTagDisplayOrder(context, { tagId, from, to }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let tag = null;
|
let tag = null;
|
||||||
|
|
||||||
@@ -123,7 +123,7 @@ function changeTagDisplayOrder(context, { tagId, from, to }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateTagDisplayOrders(context) {
|
export function updateTagDisplayOrders(context) {
|
||||||
const newDisplayOrders = [];
|
const newDisplayOrders = [];
|
||||||
|
|
||||||
for (let i = 0; i < context.state.allTransactionTags.length; i++) {
|
for (let i = 0; i < context.state.allTransactionTags.length; i++) {
|
||||||
@@ -161,7 +161,7 @@ function updateTagDisplayOrders(context) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideTag(context, { tag, hidden }) {
|
export function hideTag(context, { tag, hidden }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
services.hideTransactionTag({
|
services.hideTransactionTag({
|
||||||
id: tag.id,
|
id: tag.id,
|
||||||
@@ -203,7 +203,7 @@ function hideTag(context, { tag, hidden }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteTag(context, { tag, beforeResolve }) {
|
export function deleteTag(context, { tag, beforeResolve }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
services.deleteTransactionTag({
|
services.deleteTransactionTag({
|
||||||
id: tag.id
|
id: tag.id
|
||||||
@@ -237,12 +237,3 @@ function deleteTag(context, { tag, beforeResolve }) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
|
||||||
loadAllTags,
|
|
||||||
saveTag,
|
|
||||||
changeTagDisplayOrder,
|
|
||||||
updateTagDisplayOrders,
|
|
||||||
hideTag,
|
|
||||||
deleteTag,
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import services from '../lib/services.js';
|
|||||||
import logger from '../lib/logger.js';
|
import logger from '../lib/logger.js';
|
||||||
import utils from '../lib/utils.js';
|
import utils from '../lib/utils.js';
|
||||||
|
|
||||||
function get2FAStatus() {
|
export function get2FAStatus() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
services.get2FAStatus().then(response => {
|
services.get2FAStatus().then(response => {
|
||||||
const data = response.data;
|
const data = response.data;
|
||||||
@@ -28,7 +28,7 @@ function get2FAStatus() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function enable2FA() {
|
export function enable2FA() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
services.enable2FA().then(response => {
|
services.enable2FA().then(response => {
|
||||||
const data = response.data;
|
const data = response.data;
|
||||||
@@ -53,7 +53,7 @@ function enable2FA() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function confirmEnable2FA(context, { secret, passcode }) {
|
export function confirmEnable2FA(context, { secret, passcode }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
services.confirmEnable2FA({
|
services.confirmEnable2FA({
|
||||||
secret: secret,
|
secret: secret,
|
||||||
@@ -85,7 +85,7 @@ function confirmEnable2FA(context, { secret, passcode }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function disable2FA(context, { password }) {
|
export function disable2FA(context, { password }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
services.disable2FA({
|
services.disable2FA({
|
||||||
password: password
|
password: password
|
||||||
@@ -112,7 +112,7 @@ function disable2FA(context, { password }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function regenerate2FARecoveryCode(context, { password }) {
|
export function regenerate2FARecoveryCode(context, { password }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
services.regenerate2FARecoveryCode({
|
services.regenerate2FARecoveryCode({
|
||||||
password: password
|
password: password
|
||||||
@@ -138,11 +138,3 @@ function regenerate2FARecoveryCode(context, { password }) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
|
||||||
get2FAStatus,
|
|
||||||
enable2FA,
|
|
||||||
confirmEnable2FA,
|
|
||||||
disable2FA,
|
|
||||||
regenerate2FARecoveryCode
|
|
||||||
}
|
|
||||||
|
|||||||
+10
-23
@@ -11,7 +11,7 @@ import {
|
|||||||
CLEAR_USER_INFO
|
CLEAR_USER_INFO
|
||||||
} from './mutations.js';
|
} from './mutations.js';
|
||||||
|
|
||||||
function authorize(context, { loginName, password }) {
|
export function authorize(context, { loginName, password }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
services.authorize({
|
services.authorize({
|
||||||
loginName: loginName,
|
loginName: loginName,
|
||||||
@@ -61,7 +61,7 @@ function authorize(context, { loginName, password }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function authorize2FA(context, { token, passcode, recoveryCode }) {
|
export function authorize2FA(context, { token, passcode, recoveryCode }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let promise = null;
|
let promise = null;
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ function authorize2FA(context, { token, passcode, recoveryCode }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function register(context, { user }) {
|
export function register(context, { user }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
services.register({
|
services.register({
|
||||||
username: user.username,
|
username: user.username,
|
||||||
@@ -165,7 +165,7 @@ function register(context, { user }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function logout(context) {
|
export function logout(context) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
services.logout().then(response => {
|
services.logout().then(response => {
|
||||||
const data = response.data;
|
const data = response.data;
|
||||||
@@ -196,7 +196,7 @@ function logout(context) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCurrentUserProfile() {
|
export function getCurrentUserProfile() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
services.getProfile().then(response => {
|
services.getProfile().then(response => {
|
||||||
const data = response.data;
|
const data = response.data;
|
||||||
@@ -221,7 +221,7 @@ function getCurrentUserProfile() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateUserProfile(context, { profile, currentPassword }) {
|
export function updateUserProfile(context, { profile, currentPassword }) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
services.updateProfile({
|
services.updateProfile({
|
||||||
password: profile.password,
|
password: profile.password,
|
||||||
@@ -260,33 +260,20 @@ function updateUserProfile(context, { profile, currentPassword }) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearUserInfoState(context) {
|
export function clearUserInfoState(context) {
|
||||||
context.commit(CLEAR_USER_INFO);
|
context.commit(CLEAR_USER_INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetState(context) {
|
export function resetState(context) {
|
||||||
context.commit(RESET_STATE);
|
context.commit(RESET_STATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
function currentUserNickname(state) {
|
export function currentUserNickname(state) {
|
||||||
const userInfo = state.currentUserInfo || {};
|
const userInfo = state.currentUserInfo || {};
|
||||||
return userInfo.nickname || userInfo.username || null;
|
return userInfo.nickname || userInfo.username || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function currentUserDefaultCurrency(state) {
|
export function currentUserDefaultCurrency(state) {
|
||||||
const userInfo = state.currentUserInfo || {};
|
const userInfo = state.currentUserInfo || {};
|
||||||
return userInfo.defaultCurrency || null;
|
return userInfo.defaultCurrency || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
|
||||||
authorize,
|
|
||||||
authorize2FA,
|
|
||||||
register,
|
|
||||||
logout,
|
|
||||||
getCurrentUserProfile,
|
|
||||||
updateUserProfile,
|
|
||||||
clearUserInfoState,
|
|
||||||
resetState,
|
|
||||||
currentUserNickname,
|
|
||||||
currentUserDefaultCurrency
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user