import { userStore } from '@/stores'
import { defineStore } from 'pinia'

export const nav_rank = 1
export const nav_basic = 2
export const nav_english_word = 3
export const nav_english = 4
export const nav_math = 5
export const nav_chinese = 6
export const navList = [
  {
    value: nav_rank,
    label: '综合',
  },
  {
    value: nav_english_word,
    label: '单词句子',
  },
  {
    value: nav_english,
    label: '英语',
  },
  {
    value: nav_math,
    label: '数学',
  },
  {
    value: nav_chinese,
    label: '语文',
  },
]

export const useStudentManageStore = defineStore('student-manage', () => {
  const schoolId = ref('')
  const classId = ref('')
  const { userInfo } = storeToRefs(userStore())

  if (userInfo.value.isTeacher) {
    navList.unshift({
      value: nav_basic,
      label: '管理',
    })
  }
  const activeNav = ref(navList[0].value)

  const $reset = () => {
    schoolId.value = ''
    classId.value = ''
    activeNav.value = navList[0].value
  }

  return {
    $reset,
    schoolId,
    classId,
    activeNav,
  }
})
