Skip to content

Commit 32ae834

Browse files
committed
feat(sidebar): do not show pages only available to presidents to non-presidents
1 parent 7b9f0cc commit 32ae834

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

components/custom/sidebar.vue

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
<script setup lang="ts">
22
import { Button } from '@/components/ui/button'
33
import { cn } from '@/lib/utils'
4+
import type { AllClubs } from '~/types/api/user/all_clubs'
45
56
const route = useRoute()
7+
8+
const isPresident = ref(false)
9+
10+
const { data } = await useAsyncData<AllClubs>('classroomStatuses', () => {
11+
return $fetch<AllClubs>(`/api/user/all_clubs`, {
12+
headers: useRequestHeaders(),
13+
method: 'GET',
14+
})
15+
})
16+
17+
if (data.value?.president.length !== 0) {
18+
isPresident.value = true
19+
}
620
</script>
721

822
<template>
@@ -55,14 +69,14 @@ const route = useRoute()
5569
CAS管理
5670
</h2>
5771
<div class="mt-2">
58-
<NuxtLink to="/manage/reservation">
72+
<NuxtLink v-if="isPresident" to="/manage/reservation">
5973
<Button :variant="route.name === 'manage-reservation' ? 'secondary' : 'ghost'" class="w-full justify-start">
6074
<Icon class="mr-2 h-4 w-4" name="material-symbols:calendar-today-outline" />
6175
预约教室
6276
</Button>
6377
</NuxtLink>
6478
<NuxtLink to="/manage/manage">
65-
<Button :variant="route.name === 'manage-manage' ? 'secondary' : 'ghost'" class="w-full justify-start">
79+
<Button v-if="isPresident" :variant="route.name === 'manage-manage' ? 'secondary' : 'ghost'" class="w-full justify-start">
6680
<Icon class="mr-2 h-4 w-4" name="material-symbols:calendar-today-outline" />
6781
管理预约
6882
</Button>
@@ -74,7 +88,7 @@ const route = useRoute()
7488
</Button>
7589
</NuxtLink>
7690
<NuxtLink to="/manage/record">
77-
<Button :variant="route.name === 'manage-record' ? 'secondary' : 'ghost'" class="w-full justify-start mt-1">
91+
<Button v-if="isPresident" :variant="route.name === 'manage-record' ? 'secondary' : 'ghost'" class="w-full justify-start mt-1">
7892
<Icon class="mr-2 h-4 w-4" name="charm:tick-double" />
7993
活动记录
8094
</Button>

0 commit comments

Comments
 (0)