From 1627f9cd36951e07412c74165eddfaac5312f392 Mon Sep 17 00:00:00 2001 From: alexandre Date: Thu, 11 May 2023 08:55:34 +0200 Subject: [PATCH] refs #5655 added useUserConfig --- src/composables/useRole.js | 4 +++- src/composables/useUserConfig.js | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 src/composables/useUserConfig.js diff --git a/src/composables/useRole.js b/src/composables/useRole.js index a781785a0..0184b23da 100644 --- a/src/composables/useRole.js +++ b/src/composables/useRole.js @@ -1,4 +1,5 @@ import { useState } from './useState'; +import { useUserConfig } from './useUserConfig'; import axios from 'axios'; export function useRole() { @@ -6,6 +7,7 @@ export function useRole() { async function fetch() { const { data } = await axios.get('VnUsers/acl'); + const userConfig = await useUserConfig().fetch(); const roles = data.roles.map((userRoles) => userRoles.role.name); const userData = { @@ -13,7 +15,7 @@ export function useRole() { name: data.user.name, nickname: data.user.nickname, lang: data.user.lang || 'es', - darkMode: data.user.userConfig.darkMode, + darkMode: userConfig.darkMode, }; state.setUser(userData); state.setRoles(roles); diff --git a/src/composables/useUserConfig.js b/src/composables/useUserConfig.js new file mode 100644 index 000000000..0e4837aeb --- /dev/null +++ b/src/composables/useUserConfig.js @@ -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, + }; +}