-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.vue
55 lines (50 loc) · 1.35 KB
/
app.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<script setup>
// const user = useSupabaseUser();
const user = ref(null);
const supabase = useSupabaseClient();
const name = ref(null);
const isLoading = ref(true);
onMounted(async () => {
try {
const { data } = await supabase.auth.getSession();
// if (data) {
// user.value = data.session.user;
// }
const { data: profile } = await supabase
.from("profiles")
.select()
.eq("id", data.session.user.id)
.single();
if (profile) {
name.value = profile.full_name;
user.value = profile;
}
} catch (error) {
console.log(error);
} finally {
isLoading.value = false;
}
});
</script>
<template>
<div>
<NuxtLoadingIndicator :height="7" />
<Loading v-if="isLoading" />
<div v-else>
<ClientOnly>
<Suspense>
<div>
<Header :user="user" :name="name" />
<NuxtPage :user="user" />
</div>
<template #fallback>
<Loading />
</template>
</Suspense>
<template #placeholder>
<Loading />
</template>
</ClientOnly>
</div>
</div>
</template>