teacher.vue 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <template>
  2. <div
  3. v-if="!data"
  4. class="w-full h-full flex items-center justify-center show"
  5. >
  6. <ILoader class="w-16 h-16 text-foreground" />
  7. </div>
  8. <div
  9. v-else
  10. class="flex flex-col gap-2 p-4 show"
  11. >
  12. <div
  13. v-for="teacher in data"
  14. :key="teacher.id"
  15. class="bg-primary hover:bg-opacity-80 text-black rounded-md text-xl py-2 font-semibold duration-150 text-center"
  16. @click="[user.data.teacher_id = teacher.id, router.push('/timetable')]"
  17. v-text="teacher.title"
  18. />
  19. </div>
  20. </template>
  21. <script setup lang="ts">
  22. import { useUser } from '~/store/useUser'
  23. definePageMeta({
  24. name: 'Выберите преподавателя',
  25. middleware: ['user-only'],
  26. })
  27. const user = useUser()
  28. const api = useApi()
  29. const router = useRouter()
  30. const data = ref(null)
  31. if (!(Object.hasOwn(user.data, 'is_student') && Object.hasOwn(user.data, 'branch_id'))) {
  32. router.push('/setup/branch')
  33. }
  34. onMounted(async () => {
  35. data.value = await api.get(`/teachers/${user.data.branch_id}`)
  36. })
  37. </script>