diff --git a/src/locales/en.js b/src/locales/en.js index 5454907b..ccd978a6 100644 --- a/src/locales/en.js +++ b/src/locales/en.js @@ -587,8 +587,10 @@ export default { 'Show Account Balance': 'Show Account Balance', 'Enable Animate': 'Enable Animate', 'Enable Auto Dark Mode': 'Enable Auto Dark Mode', + 'Use preset transaction categories': 'Use preset transaction categories', + 'Preset Categories': 'Preset Categories', 'You have been successfully registered': 'You have been successfully registered', - 'Do you want to initialize transaction categories now?': 'Do you want to initialize transaction categories now?', + 'You have been successfully registered, but something wrong with adding preset categories. You can re-add preset categories in settings page anytime.': 'You have been successfully registered, but something wrong with adding preset categories. You can re-add preset categories in settings page anytime.', 'Unable to sign up': 'Unable to sign up', 'User registration is disabled': 'User registration is disabled', 'Unable to get user profile': 'Unable to get user profile', @@ -638,8 +640,9 @@ export default { 'Unable to get category': 'Unable to get category', 'Unable to add category': 'Unable to add category', 'Unable to save category': 'Unable to save category', + 'Unable to add preset categories': 'Unable to add preset categories', 'You have added a new category': 'You have added a new category', - 'You have added default categories': 'You have added default categories', + 'You have added preset categories': 'You have added preset categories', 'You have saved this category': 'You have saved this category', 'Transaction Tags': 'Transaction Tags', 'Tag Title': 'Tag Title', diff --git a/src/locales/zh_Hans.js b/src/locales/zh_Hans.js index d81d248f..1bd6f4e5 100644 --- a/src/locales/zh_Hans.js +++ b/src/locales/zh_Hans.js @@ -587,8 +587,10 @@ export default { 'Show Account Balance': '显示账户余额', 'Enable Animate': '启用动画', 'Enable Auto Dark Mode': '启用自动深色模式', + 'Use preset transaction categories': '使用预设交易分类', + 'Preset Categories': '预设分类', 'You have been successfully registered': '注册成功', - 'Do you want to initialize transaction categories now?': '您是否想现在初始化交易分类?', + 'You have been successfully registered, but something wrong with adding preset categories. You can re-add preset categories in settings page anytime.': '注册成功,但是添加预设分类时出错。您可以随时在设置页面中重新添加预设分类。', 'Unable to sign up': '无法注册', 'User registration is disabled': '用户注册已禁用', 'Unable to get user profile': '无法获取用户信息', @@ -638,8 +640,9 @@ export default { 'Unable to get category': '无法获取分类', 'Unable to add category': '无法添加分类', 'Unable to save category': '无法保存分类', + 'Unable to add preset categories': '无法添加预设分类', 'You have added a new category': '您已经添加新分类', - 'You have added default categories': '您已经添加默认分类', + 'You have added preset categories': '您已经添加预设分类', 'You have saved this category': '您已经保存该分类', 'Transaction Tags': '交易标签', 'Tag Title': '标签标题', diff --git a/src/store/index.js b/src/store/index.js index 9b650312..71118ea1 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -18,6 +18,7 @@ import { UPDATE_ACCOUNT_LIST_INVALID_STATE, LOAD_TRANSACTION_CATEGORY_LIST, + UPDATE_TRANSACTION_CATEGORY_LIST_INVALID_STATE, LOAD_TRANSACTION_TAG_LIST, ADD_TAG_TO_TRANSACTION_TAG_LIST, @@ -33,6 +34,7 @@ import twoFactorAuth from './twoFactorAuth.js'; import token from './token.js'; import exchangeRates from './exchangeRates.js'; import account from './account.js'; +import transactionCategory from './transactionCategory.js'; import transactionTag from './transactionTag.js'; const stores = { @@ -46,6 +48,7 @@ const stores = { accountListStateInvalid: true, allTransactionCategories: [], allTransactionCategoriesMap: {}, + transactionCategoryListStateInvalid: true, allTransactionTags: [], allTransactionTagsMap: {}, transactionTagListStateInvalid: true, @@ -209,6 +212,9 @@ const stores = { state.allTransactionCategoriesMap[category.id] = category; } }, + [UPDATE_TRANSACTION_CATEGORY_LIST_INVALID_STATE] (state, invalidState) { + state.transactionCategoryListStateInvalid = invalidState; + }, [LOAD_TRANSACTION_TAG_LIST] (state, tags) { state.allTransactionTags = tags; state.allTransactionTagsMap = {}; @@ -265,16 +271,20 @@ const stores = { updateUserProfile: user.updateUserProfile, clearUserInfoState: user.clearUserInfoState, resetState: user.resetState, + get2FAStatus: twoFactorAuth.get2FAStatus, enable2FA: twoFactorAuth.enable2FA, confirmEnable2FA: twoFactorAuth.confirmEnable2FA, disable2FA: twoFactorAuth.disable2FA, regenerate2FARecoveryCode: twoFactorAuth.regenerate2FARecoveryCode, + getAllTokens: token.getAllTokens, refreshTokenAndRevokeOldToken: token.refreshTokenAndRevokeOldToken, revokeToken: token.revokeToken, revokeAllTokens: token.revokeAllTokens, + getLatestExchangeRates: exchangeRates.getLatestExchangeRates, + loadAllAccounts: account.loadAllAccounts, saveAccount: account.saveAccount, getAccount: account.getAccount, @@ -282,6 +292,9 @@ const stores = { updateAccountDisplayOrders: account.updateAccountDisplayOrders, hideAccount: account.hideAccount, deleteAccount: account.deleteAccount, + + addTransactionCategoryBatch: transactionCategory.addTransactionCategoryBatch, + loadAllTags: transactionTag.loadAllTags, saveTag: transactionTag.saveTag, changeTagDisplayOrder: transactionTag.changeTagDisplayOrder, diff --git a/src/store/mutations.js b/src/store/mutations.js index b4e04373..f808d6bc 100644 --- a/src/store/mutations.js +++ b/src/store/mutations.js @@ -14,6 +14,7 @@ export const REMOVE_ACCOUNT_FROM_ACCOUNT_LIST = 'REMOVE_ACCOUNT_FROM_ACCOUNT_LIS export const UPDATE_ACCOUNT_LIST_INVALID_STATE = 'UPDATE_ACCOUNT_LIST_INVALID_STATE'; export const LOAD_TRANSACTION_CATEGORY_LIST = 'LOAD_TRANSACTION_CATEGORY_LIST'; +export const UPDATE_TRANSACTION_CATEGORY_LIST_INVALID_STATE = 'UPDATE_TRANSACTION_CATEGORY_LIST_INVALID_STATE'; export const LOAD_TRANSACTION_TAG_LIST = 'LOAD_TRANSACTION_TAG_LIST'; export const ADD_TAG_TO_TRANSACTION_TAG_LIST = 'ADD_TAG_TO_TRANSACTION_TAG_LIST'; diff --git a/src/store/transactionCategory.js b/src/store/transactionCategory.js new file mode 100644 index 00000000..d6c3a4f2 --- /dev/null +++ b/src/store/transactionCategory.js @@ -0,0 +1,39 @@ +import services from '../lib/services.js'; +import logger from '../lib/logger.js'; + +import { + UPDATE_TRANSACTION_CATEGORY_LIST_INVALID_STATE, +} from './mutations.js'; + +function addTransactionCategoryBatch(context, { categories }) { + return new Promise((resolve, reject) => { + services.addTransactionCategoryBatch({ + categories: categories + }).then(response => { + const data = response.data; + + if (!data || !data.success || !data.result) { + reject({ message: 'Unable to add preset categories' }); + return; + } + + context.commit(UPDATE_TRANSACTION_CATEGORY_LIST_INVALID_STATE); + + resolve(data.result); + }).catch(error => { + logger.error('failed to add preset categories', error); + + if (error.response && error.response.data && error.response.data.errorMessage) { + reject({ error: error.response.data }); + } else if (!error.processed) { + reject({ message: 'Unable to add preset categories' }); + } else { + reject(error); + } + }); + }); +} + +export default { + addTransactionCategoryBatch, +} diff --git a/src/views/mobile/Signup.vue b/src/views/mobile/Signup.vue index 3359cefa..89dd0d42 100644 --- a/src/views/mobile/Signup.vue +++ b/src/views/mobile/Signup.vue @@ -70,7 +70,20 @@ + + + +