Compare commits

...

3 Commits

@ -1,6 +1,7 @@
<template> <template>
<el-card>
<div <div
class="bg-secondary flex h-fit w-full justify-start gap-8 p-4 text-center" class="flex h-fit w-full justify-start gap-8 text-center"
:class="props.mode === 'horizontal' ? 'flex-row' : 'flex-col'"> :class="props.mode === 'horizontal' ? 'flex-row' : 'flex-col'">
<div class="flex flex-row items-center justify-start gap-4"> <div class="flex flex-row items-center justify-start gap-4">
<Icon :name="props.icon" /> <Icon :name="props.icon" />
@ -13,18 +14,18 @@
{{ props.data }} {{ props.data }}
</div> </div>
</div> </div>
<div class="flex flex-row items-center gap-4"> </div>
</div> </div>
</el-card>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
interface Props { interface Props {
mode: 'horizontal' | 'vertical' mode: 'horizontal' | 'vertical'
icon: string icon: string
title: string title: string
description?: string description?: string
data: string | number data: string | number
} }
const props = defineProps<Props>() const props = defineProps<Props>()
</script> </script>

@ -1,3 +1,8 @@
<script setup lang="ts">
const router = useRouter()
const user = useSupabaseUser()
</script>
<template> <template>
<div <div
class="flex h-fit w-full flex-row items-center justify-center border-b border-[var(--el-border-color)] p-2"> class="flex h-fit w-full flex-row items-center justify-center border-b border-[var(--el-border-color)] p-2">
@ -23,6 +28,17 @@
<el-dropdown-item @click="navigateTo('/profile')" <el-dropdown-item @click="navigateTo('/profile')"
>Profile</el-dropdown-item >Profile</el-dropdown-item
> >
<el-dropdown-item
v-if="user"
class="danger"
@click="userSignOut()"
>Sign Out</el-dropdown-item
>
<el-dropdown-item
v-else
@click="router.push('/login')"
>Sign In</el-dropdown-item
>
</el-dropdown-menu> </el-dropdown-menu>
</template> </template>
</el-dropdown> </el-dropdown>
@ -35,4 +51,7 @@
:deep(.el-dropdown-menu__item) { :deep(.el-dropdown-menu__item) {
@apply px-8; @apply px-8;
} }
:deep(.el-dropdown-menu__item:not(.is-disabled):focus.danger) {
@apply bg-[--el-color-danger-light-9] text-[--el-color-danger];
}
</style> </style>

@ -9,33 +9,16 @@
:title="data.title" :title="data.title"
:description="data.description" :description="data.description"
:data="data.data" /> :data="data.data" />
<div class="flex gap-4">
<button
v-if="user"
@click="userSignOut()"
class="w-fit rounded-md p-2 font-bold transition duration-500 ease-out hover:bg-red-500 hover:text-black">
<Icon name="fa6-solid:arrow-right-from-bracket" />
Sign Out
</button>
<button
v-else
@click="router.push('/login')"
class="w-fit rounded-md p-2 font-bold transition duration-500 ease-out hover:bg-blue-500 hover:text-black">
<Icon name="fa6-solid:arrow-right-to-bracket" />
Log In
</button>
</div>
</template> </template>
</NuxtLayout> </NuxtLayout>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
definePageMeta({ definePageMeta({
middleware: ['auth'], middleware: ['auth'],
}) })
interface DashboardData { interface DashboardData {
noteCount: { noteCount: {
title: string title: string
description: string description: string
@ -43,13 +26,13 @@
mode: 'horizontal' | 'vertical' mode: 'horizontal' | 'vertical'
icon: string icon: string
} }
} }
const router = useRouter() const router = useRouter()
const user = useSupabaseUser() const user = useSupabaseUser()
const isLoading = ref<boolean>(true) const isLoading = ref<boolean>(true)
const dashboardData: DashboardData = reactive({ const dashboardData: DashboardData = reactive({
user: { user: {
title: 'Email', title: 'Email',
description: 'User', description: 'User',
@ -64,17 +47,17 @@
mode: 'horizontal', mode: 'horizontal',
icon: 'fa6-solid:note-sticky', icon: 'fa6-solid:note-sticky',
}, },
}) })
const { refresh } = await useFetch('/api/profile', { const { refresh } = await useFetch('/api/profile', {
onResponse({ response }) { onResponse({ response }) {
dashboardData.noteCount.data = response._data.count dashboardData.noteCount.data = response._data.count
}, },
}) })
onMounted(() => { onMounted(() => {
isLoading.value = true isLoading.value = true
refresh() refresh()
isLoading.value = false isLoading.value = false
}) })
</script> </script>

Loading…
Cancel
Save