modify error message
This commit is contained in:
@@ -331,6 +331,37 @@ export const useTransactionCategoriesStore = defineStore('transactionCategories'
|
||||
}
|
||||
|
||||
function addCategories(req: TransactionCategoryCreateBatchRequest): Promise<Record<number, TransactionCategory[]>> {
|
||||
return new Promise((resolve, reject) => {
|
||||
services.addTransactionCategoryBatch(req).then(response => {
|
||||
const data = response.data;
|
||||
|
||||
if (!data || !data.success || !data.result) {
|
||||
reject({ message: 'Unable to add category' });
|
||||
return;
|
||||
}
|
||||
|
||||
if (!transactionCategoryListStateInvalid.value) {
|
||||
updateTransactionCategoryListInvalidState(true);
|
||||
}
|
||||
|
||||
const transactionCategories = TransactionCategory.ofMap(data.result);
|
||||
|
||||
resolve(transactionCategories);
|
||||
}).catch(error => {
|
||||
logger.error('failed to add 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 category' });
|
||||
} else {
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function addPresetCategories(req: TransactionCategoryCreateBatchRequest): Promise<Record<number, TransactionCategory[]>> {
|
||||
return new Promise((resolve, reject) => {
|
||||
services.addTransactionCategoryBatch(req).then(response => {
|
||||
const data = response.data;
|
||||
@@ -535,6 +566,7 @@ export const useTransactionCategoriesStore = defineStore('transactionCategories'
|
||||
getCategory,
|
||||
saveCategory,
|
||||
addCategories,
|
||||
addPresetCategories,
|
||||
changeCategoryDisplayOrder,
|
||||
updateCategoryDisplayOrders,
|
||||
hideCategory,
|
||||
|
||||
@@ -117,7 +117,7 @@ function save(): void {
|
||||
const presetCategoriesArray = categorizedArrayToPlainArray(allPresetCategories.value);
|
||||
const submitCategories = localizedPresetCategoriesToTransactionCategoryCreateWithSubCategories(presetCategoriesArray);
|
||||
|
||||
transactionCategoriesStore.addCategories({
|
||||
transactionCategoriesStore.addPresetCategories({
|
||||
categories: submitCategories
|
||||
}).then(() => {
|
||||
submitting.value = false;
|
||||
|
||||
@@ -113,7 +113,7 @@ function save(): void {
|
||||
const presetCategoriesArray = categorizedArrayToPlainArray(allPresetCategories.value);
|
||||
const submitCategories = localizedPresetCategoriesToTransactionCategoryCreateWithSubCategories(presetCategoriesArray);
|
||||
|
||||
transactionCategoriesStore.addCategories({
|
||||
transactionCategoriesStore.addPresetCategories({
|
||||
categories: submitCategories
|
||||
}).then(() => {
|
||||
submitting.value = false;
|
||||
|
||||
Reference in New Issue
Block a user