mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-21 02:04:26 +08:00
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[]>> {
|
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) => {
|
return new Promise((resolve, reject) => {
|
||||||
services.addTransactionCategoryBatch(req).then(response => {
|
services.addTransactionCategoryBatch(req).then(response => {
|
||||||
const data = response.data;
|
const data = response.data;
|
||||||
@@ -535,6 +566,7 @@ export const useTransactionCategoriesStore = defineStore('transactionCategories'
|
|||||||
getCategory,
|
getCategory,
|
||||||
saveCategory,
|
saveCategory,
|
||||||
addCategories,
|
addCategories,
|
||||||
|
addPresetCategories,
|
||||||
changeCategoryDisplayOrder,
|
changeCategoryDisplayOrder,
|
||||||
updateCategoryDisplayOrders,
|
updateCategoryDisplayOrders,
|
||||||
hideCategory,
|
hideCategory,
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ function save(): void {
|
|||||||
const presetCategoriesArray = categorizedArrayToPlainArray(allPresetCategories.value);
|
const presetCategoriesArray = categorizedArrayToPlainArray(allPresetCategories.value);
|
||||||
const submitCategories = localizedPresetCategoriesToTransactionCategoryCreateWithSubCategories(presetCategoriesArray);
|
const submitCategories = localizedPresetCategoriesToTransactionCategoryCreateWithSubCategories(presetCategoriesArray);
|
||||||
|
|
||||||
transactionCategoriesStore.addCategories({
|
transactionCategoriesStore.addPresetCategories({
|
||||||
categories: submitCategories
|
categories: submitCategories
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
submitting.value = false;
|
submitting.value = false;
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ function save(): void {
|
|||||||
const presetCategoriesArray = categorizedArrayToPlainArray(allPresetCategories.value);
|
const presetCategoriesArray = categorizedArrayToPlainArray(allPresetCategories.value);
|
||||||
const submitCategories = localizedPresetCategoriesToTransactionCategoryCreateWithSubCategories(presetCategoriesArray);
|
const submitCategories = localizedPresetCategoriesToTransactionCategoryCreateWithSubCategories(presetCategoriesArray);
|
||||||
|
|
||||||
transactionCategoriesStore.addCategories({
|
transactionCategoriesStore.addPresetCategories({
|
||||||
categories: submitCategories
|
categories: submitCategories
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
submitting.value = false;
|
submitting.value = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user