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

View File

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

View File

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

View File

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

View File

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