Update profile page to use element plus

main
TZGyn 2 years ago
parent b47971cc82
commit f37de440ad
Signed by: TZGyn
GPG Key ID: 122EAF77AE81FD4A

@ -9,72 +9,55 @@
: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
data: number data: number
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',
data: user.value?.email, data: user.value?.email,
mode: 'horizontal', mode: 'horizontal',
icon: 'fa6-solid:envelope', icon: 'fa6-solid:envelope',
}, },
noteCount: { noteCount: {
title: 'Note Count', title: 'Note Count',
description: 'The number of notes this account is currently having', description: 'The number of notes this account is currently having',
data: 0, data: 0,
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