diff --git a/frontend/components/Header.vue b/frontend/components/Header.vue index c08dc1f..433f35b 100644 --- a/frontend/components/Header.vue +++ b/frontend/components/Header.vue @@ -1,74 +1,20 @@ - + - - - {{ userOption.title }} - - +const isSidebarActive = useSidebar() +const user = useUser() + +const sidebar = ref() + +type UserOption = { + title: string + icon?: string + onClick: () => void +} + +const userOptions: Array = [ + { + title: 'Github', + icon: 'github', + onClick: () => { + openUrl('https://github.com/TZGyn') + }, + }, + { + title: 'Log Out', + icon: 'mdi:logout', + onClick: async () => { + await userLogout() + useRouter().push('/login') + }, + }, + { + title: 'Profile', + icon: 'user', + onClick: () => { + useRouter().push('/profile') + }, + }, +] + +onClickOutside(sidebar, () => { + closeSidebar() +}) + + + + + + + + Account Info + + + + + {{ user }} + + + + + + + {{ userOption.title }} + + + + + + + + diff --git a/frontend/composables/utils.ts b/frontend/composables/utils.ts index 98dd157..1112e92 100644 --- a/frontend/composables/utils.ts +++ b/frontend/composables/utils.ts @@ -2,4 +2,8 @@ const openUrl = (url: string) => { window.open(url, '_blank') } -export { openUrl } +const useSidebar = () => useState('isSidebarActive', () => false) +const openSidebar = () => [(useSidebar().value = true)] +const closeSidebar = () => [(useSidebar().value = false)] + +export { closeSidebar, openSidebar, openUrl, useSidebar } diff --git a/frontend/pages/index.vue b/frontend/pages/index.vue index c16c0b3..8e420cc 100644 --- a/frontend/pages/index.vue +++ b/frontend/pages/index.vue @@ -47,6 +47,7 @@ onMounted(() => { +