#8031 - Enable notify positive when user update self data #750
|
@ -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) {
|
||||
jsegarra marked this conversation as resolved
|
||||
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) {
|
||||
jsegarra marked this conversation as resolved
alexm
commented
Con un try catch para un console.log, el usuario no se dará cuenta si falla Con un try catch para un console.log, el usuario no se dará cuenta si falla
|
||||
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) {
|
||||
jsegarra marked this conversation as resolved
alexm
commented
Con un try catch para un console.log, el usuario no se dará cuenta si falla Con un try catch para un console.log, el usuario no se dará cuenta si falla
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
const isEmployee = computed(() => useRole().isEmployee());
|
||||
|
||||
const onDataSaved = () => {
|
||||
jsegarra marked this conversation as resolved
alexm
commented
No se llama nunca No se llama nunca
|
||||
notify('globals.dataSaved', 'positive');
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
Loading…
Reference in New Issue
Con un try catch para un console.log, el usuario no se dará cuenta si falla