Skip to content

Commit

Permalink
refactors IslandMenu to collapse expanded tab; adds user ID display i…
Browse files Browse the repository at this point in the history
…n UserPanel; cleans up user retrieval API; introduces user detail page with authentication warning
  • Loading branch information
CarelessCourage committed Mar 2, 2025
1 parent e019d49 commit a3159f3
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/hub/app/components/IslandMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const hazeStrength = computed(() => {
type Tab = 'user' | 'settings'
const activeTab = ref<Tab>('user')
const expandedTab = ref(true)
const expandedTab = ref(false)
function switchTab(tab: Tab) {
if (activeTab.value === tab) {
Expand Down
2 changes: 2 additions & 0 deletions apps/hub/app/components/UserPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ const sessionAge = computed(() => {
</div>
<p>IP Adress: {{ session?.ipAddress }}</p>
<p>Session age: {{ sessionAge }}</p>
<p>{{ user?.id }}</p>

<Button size="medium" @click="signOut">Sign out</Button>
</div>
</template>
Expand Down
29 changes: 29 additions & 0 deletions apps/hub/app/pages/users/[id].vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<script setup lang="ts">
const route = useRoute()
if (!route.params.id) {
console.log('Warning! Make sure user is authenticasted!')
}
const { data } = await useFetch(`/api/users/${route.params.id}`)
</script>

<template>
<div class="user-panel">
<div class="identity">
<NuxtImg
src="https://images.unsplash.com/photo-1740475339769-664748d1193e?q=80&w=3464&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"
alt="User Image"
/>
<h2>Name: {{ data?.name }}</h2>
</div>
<div class="email">
<p>Email: {{ data?.email }}</p>
<div v-if="!data?.emailVerified" class="verified border">
<Icon name="pixelarticons:check" />
</div>
</div>
</div>
</template>

<style lang="scss"></style>
1 change: 0 additions & 1 deletion apps/hub/server/api/users/[id].get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ export default defineEventHandler(async (event) => {
})

if (!user) throw new Error('User not found')

return user
})

0 comments on commit a3159f3

Please sign in to comment.