Skip to content

Commit 6023810

Browse files
committed
fix(sidebar): only request all_clubs on binded accounts
1 parent bdcc8c3 commit 6023810

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

components/custom/sidebar.vue

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
<script setup lang="ts">
22
import { Button } from '@/components/ui/button'
33
import { cn } from '@/lib/utils'
4+
import { useClerk } from 'vue-clerk'
45
import type { AllClubs } from '~/types/api/user/all_clubs'
56
7+
const clerk = useClerk()
8+
69
const route = useRoute()
710
811
const isPresidentOrVicePresident = ref(false)
912
10-
const { data } = await useFetch<AllClubs>(`/api/user/all_clubs`, {
11-
headers: useRequestHeaders(),
12-
method: 'GET',
13-
})
14-
15-
if (data.value && (data.value?.president.length !== 0 || data.value?.vice.length !== 0)) {
16-
isPresidentOrVicePresident.value = true
13+
if (import.meta.client) {
14+
if (clerk.user?.publicMetadata.binded) {
15+
const data = await $fetch<AllClubs>(`/api/user/all_clubs`, {
16+
headers: useRequestHeaders(),
17+
method: 'GET',
18+
})
19+
if (data && (data.president.length !== 0 || data.vice.length !== 0)) {
20+
isPresidentOrVicePresident.value = true
21+
}
22+
}
1723
}
1824
</script>
1925

0 commit comments

Comments
 (0)