feat: enable notify positive when user update self data
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Javier Segarra 2024-09-23 18:48:58 +00:00
parent 3cfa883642
commit a5c6d628ca
1 changed files with 32 additions and 11 deletions

View File

@ -13,12 +13,14 @@ import FetchData from 'components/FetchData.vue';
import { useClipboard } from 'src/composables/useClipboard';
import { useRole } from 'src/composables/useRole';
import VnAvatar from './ui/VnAvatar.vue';
import useNotify from 'src/composables/useNotify';
const state = useState();
const session = useSession();
const router = useRouter();
const { t, locale } = useI18n();
const { copyText } = useClipboard();
const { notify } = useNotify();
const userLocale = computed({
get() {
@ -53,6 +55,7 @@ const user = state.getUser();
const warehousesData = ref();
const companiesData = ref();
const accountBankData = ref();
const isEmployee = computed(() => useRole().isEmployee());
onMounted(async () => {
updatePreferences();
@ -70,18 +73,28 @@ function updatePreferences() {
async function saveDarkMode(value) {
const query = `/UserConfigs/${user.value.id}`;
await axios.patch(query, {
darkMode: value,
});
user.value.darkMode = value;
try {
await axios.patch(query, {
darkMode: value,
});
user.value.darkMode = value;
notify('globals.dataSaved', 'positive');
} catch (error) {
console.error(error);
}
}
async function saveLanguage(value) {
const query = `/VnUsers/${user.value.id}`;
await axios.patch(query, {
lang: value,
});
user.value.lang = value;
try {
await axios.patch(query, {
lang: value,
});
user.value.lang = value;
notify('globals.dataSaved', 'positive');
} catch (error) {
console.error(error);
}
}
function logout() {
@ -98,10 +111,18 @@ function localUserData() {
}
function saveUserData(param, value) {
axios.post('UserConfigs/setUserConfig', { [param]: value });
localUserData();
try {
axios.post('UserConfigs/setUserConfig', { [param]: value });
localUserData();
notify('globals.dataSaved', 'positive');
} catch (error) {
console.error(error);
}
}
const isEmployee = computed(() => useRole().isEmployee());
const onDataSaved = () => {
notify('globals.dataSaved', 'positive');
};
</script>
<template>