Fix menu query
gitea/hedera-web/pipeline/pr-beta This commit looks good Details

This commit is contained in:
William Buezas 2025-04-11 11:28:16 +02:00
parent 48f00a9400
commit 5907d53aa7
5 changed files with 14 additions and 8 deletions

View File

@ -30,7 +30,7 @@ const toggleLeftDrawer = () => {
onMounted(async () => {
await appStore.loadConfig();
await appStore.getMenuLinks();
await appStore.getMenuLinks(userStore?.userId);
appStore.isHeaderMounted = true;
});
@ -41,7 +41,7 @@ const logout = async () => {
const logoutSupplantedUser = async () => {
await userStore.logoutSupplantedUser();
await appStore.getMenuLinks();
await appStore.getMenuLinks(userStore?.userId);
refreshContentKey.value++;
};
</script>

View File

@ -90,7 +90,7 @@ const getConnections = async () => {
const supplantUser = async user => {
try {
await userStore.supplantUser(user);
await appStore.getMenuLinks();
await appStore.getMenuLinks(userStore?.userId);
router.push({ name: 'confirmedOrders' });
} catch (error) {
console.error('Error supplanting user:', error);

View File

@ -27,7 +27,7 @@ const onSearch = data => (users.value = data || []);
const supplantUser = async user => {
try {
await userStore.supplantUser(user);
await appStore.getMenuLinks();
await appStore.getMenuLinks(userStore?.userId);
router.push({ name: 'confirmedOrders' });
} catch (error) {
console.error('Error supplanting user:', error);

View File

@ -31,9 +31,12 @@ export const useAppStore = defineStore('hedera', {
]
}),
actions: {
async getMenuLinks() {
const { data: sections } = await api.get('MyMenus');
async getMenuLinks(userId) {
const { data: sections } = await api.get('/MyMenus/getSections', {
params: {
userId
}
});
if (!sections) return;
const sectionMap = new Map();

View File

@ -296,6 +296,8 @@ export const useUserStore = defineStore('user', () => {
tokenConfig.value = null;
};
const userId = computed(() => user.value?.id);
watch(
[mainUser, supplantedUser],
() => (user.value = supplantedUser.value || mainUser.value),
@ -336,6 +338,7 @@ export const useUserStore = defineStore('user', () => {
updateUserLang,
init,
$reset,
onLogin
onLogin,
userId
};
});