refs #5655 added useUserConfig
gitea/salix-front/pipeline/head There was a failure building this commit Details

This commit is contained in:
Alexandre Riera 2023-05-11 08:55:34 +02:00
parent b674bc4d41
commit 1627f9cd36
2 changed files with 16 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import { useState } from './useState'; import { useState } from './useState';
import { useUserConfig } from './useUserConfig';
import axios from 'axios'; import axios from 'axios';
export function useRole() { export function useRole() {
@ -6,6 +7,7 @@ export function useRole() {
async function fetch() { async function fetch() {
const { data } = await axios.get('VnUsers/acl'); const { data } = await axios.get('VnUsers/acl');
const userConfig = await useUserConfig().fetch();
const roles = data.roles.map((userRoles) => userRoles.role.name); const roles = data.roles.map((userRoles) => userRoles.role.name);
const userData = { const userData = {
@ -13,7 +15,7 @@ export function useRole() {
name: data.user.name, name: data.user.name,
nickname: data.user.nickname, nickname: data.user.nickname,
lang: data.user.lang || 'es', lang: data.user.lang || 'es',
darkMode: data.user.userConfig.darkMode, darkMode: userConfig.darkMode,
}; };
state.setUser(userData); state.setUser(userData);
state.setRoles(roles); state.setRoles(roles);

View File

@ -0,0 +1,13 @@
import axios from 'axios';
export function useUserConfig() {
async function fetch() {
const { data } = await axios.get('UserConfigs/getUserConfig');
return data;
}
return {
fetch,
};
}