import orderActive from '@/static/images/home-active.png'
import order from '@/static/images/home.png'
import taskActive from '@/static/images/assignment-active.png'
import task from '@/static/images/assignment.png'
import clientInActive from '@/static/images/client-inactive.png'
import clientActive from '@/static/images/client-active.png'
import contractActive from '@/static/images/contract-active.png'
import contractInActive from '@/static/images/contract-inactive.png'
import profileInActive from '@/static/images/profile-inactive.png'
import profileActive from '@/static/images/profile-active.png'
import { type TabBarProp } from '@/stores/tabbar'
import { useUserStore } from '@/stores/user'
import cache from '@/utils/cache'
import { ROLEINDEX } from '@/enums/cacheEnums'
import { computed } from 'vue'
import { ApprenticeEnum } from '@/enums/businessEnums'
export interface RoleItem {
    name: string
    ids: number[]
    tabBarList: TabBarProp[]
}

export function useRoleData() {
    const roles: RoleItem[] = [
        {
            name: '电销老师',
            ids: [5],
            tabBarList: [
                {
                    text: '首页',
                    path: '/pages/telesale/home/index',
                    inactiveIcon: clientInActive,
                    activeIcon: clientActive
                },
                {
                    text: '总结模板',
                    path: '/pages/telesale/summary/index',
                    inactiveIcon: contractInActive,
                    activeIcon: contractActive
                },
                {
                    text: '个人中心',
                    path: '/pages/telesale/my/index',
                    inactiveIcon: profileInActive,
                    activeIcon: profileActive
                }
            ]
        },
        {
            name: '招生老师',
            ids: [6],
            tabBarList: [
                {
                    text: '首页',
                    inactiveIcon: order,
                    activeIcon: orderActive,
                    path: '/pages/recruitsale/home/index'
                },
                {
                    text: '总结模板',
                    path: '/pages/recruitsale/summary/index',
                    inactiveIcon: task,
                    activeIcon: taskActive
                },
                {
                    text: '个人中心',
                    path: '/pages/recruitsale/my/index',
                    inactiveIcon: profileInActive,
                    activeIcon: profileActive
                }
            ]
        }
    ]
    return {
        roles
    }
}

export function useRoleActiveId() {
    const userStore = useUserStore()
    const { userInfo } = userStore
    const roleIndex = cache.get(ROLEINDEX)
    const activeRoleId = computed(() => {
        const roleArr = userInfo.roles
        return roleArr[roleIndex || 0]?.id
    })
    return {
        activeRoleId
    }
}

export function useJudgeApprentice() {
    const userStore = useUserStore()
    const { userInfo } = userStore
    if (typeof userInfo.isApprentice == undefined) return false
    return userInfo?.isApprentice === ApprenticeEnum.NO ? false : true
}
