show a confirmation dialog allowing the user to change the editable transaction range to "All" when unable to add or edit a transaction due to the limitation on the editable transaction range

This commit is contained in:
MaysWind
2024-09-20 00:47:53 +08:00
parent 6655d725ae
commit 5221ab481e
6 changed files with 88 additions and 5 deletions
+35 -1
View File
@@ -5,7 +5,10 @@ import { useSettingsStore } from './setting.js';
import userState from '@/lib/userstate.js';
import services from '@/lib/services.js';
import logger from '@/lib/logger.js';
import { isNumber } from '@/lib/common.js';
import {
isObject,
isNumber
} from '@/lib/common.js';
export const useUserStore = defineStore('user', {
state: () => ({
@@ -126,6 +129,37 @@ export const useUserStore = defineStore('user', {
});
});
},
updateUserTransactionEditScope({ transactionEditScope }) {
return new Promise((resolve, reject) => {
services.updateProfile({
transactionEditScope: transactionEditScope,
}).then(response => {
const data = response.data;
if (!data || !data.success || !data.result) {
reject({ message: 'Unable to update editable transaction range' });
return;
}
if (data.result.user && isObject(data.result.user)) {
const userStore = useUserStore();
userStore.storeUserBasicInfo(data.result.user);
}
resolve(data.result);
}).catch(error => {
logger.error('failed to save editable transaction range', error);
if (error.response && error.response.data && error.response.data.errorMessage) {
reject({ error: error.response.data });
} else if (!error.processed) {
reject({ message: 'Unable to update editable transaction range' });
} else {
reject(error);
}
});
});
},
updateUserAvatar({ avatarFile }) {
const self = this;