0
0
Fork 0
salix-front-mindshore-fork2/src/composables/useUserConfig.js

28 lines
716 B
JavaScript
Raw Normal View History

2023-05-11 06:55:34 +00:00
import axios from 'axios';
import { useState } from './useState';
2023-12-13 13:19:42 +00:00
import useNotify from './useNotify';
2023-05-11 06:55:34 +00:00
export function useUserConfig() {
const state = useState();
2023-12-13 13:19:42 +00:00
const { notify } = useNotify();
2023-05-11 06:55:34 +00:00
async function fetch() {
2023-12-13 13:19:42 +00:00
try {
const { data } = await axios.get('UserConfigs/getUserConfig');
const user = state.getUser().value;
user.darkMode = data.darkMode;
user.companyFk = data.companyFk;
state.setUser(user);
return data;
} catch (error) {
notify('errors.userConfig', 'negative');
2023-12-13 13:19:42 +00:00
console.error('Error fetching user config:', error);
}
2023-05-11 06:55:34 +00:00
}
return {
fetch,
};
}