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