You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.2 KiB
Vue
64 lines
1.2 KiB
Vue
<template>
|
|
<App>
|
|
<Header />
|
|
<div class="flex w-full max-w-3xl flex-col gap-4">
|
|
<CardPanel
|
|
v-for="data in dashboardData"
|
|
:key="data.title"
|
|
:mode="data.mode"
|
|
:icon="data.icon"
|
|
:title="data.title"
|
|
:description="data.description"
|
|
:data="data.data" />
|
|
</div>
|
|
</App>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
definePageMeta({
|
|
middleware: ['auth'],
|
|
});
|
|
|
|
interface DashboardData {
|
|
noteCount: {
|
|
title: string;
|
|
description: string;
|
|
data: number;
|
|
mode: 'horizontal' | 'vertical';
|
|
icon: string;
|
|
};
|
|
}
|
|
|
|
const user = useSupabaseUser();
|
|
const isLoading = ref<boolean>(true);
|
|
|
|
const dashboardData: DashboardData = reactive({
|
|
user: {
|
|
title: 'Email',
|
|
description: 'User',
|
|
data: user.value?.email,
|
|
mode: 'horizontal',
|
|
icon: 'fa6-solid:envelope',
|
|
},
|
|
noteCount: {
|
|
title: 'Note Count',
|
|
description: 'The number of notes this account is currently having',
|
|
data: 0,
|
|
mode: 'horizontal',
|
|
icon: 'fa6-solid:note-sticky',
|
|
},
|
|
});
|
|
|
|
const { refresh } = await useFetch('/api/profile', {
|
|
onResponse({ response }) {
|
|
dashboardData.noteCount.data = response._data.count;
|
|
},
|
|
});
|
|
|
|
onMounted(() => {
|
|
isLoading.value = true;
|
|
refresh();
|
|
isLoading.value = false;
|
|
});
|
|
</script>
|