import { Teacher } from 'iconsax-react'
import { type FC } from 'react'
import { useTranslation } from 'react-i18next'
import SubMenuItem from './SubMenuItem'
import { useLocation } from 'react-router-dom'
import { Pages } from '../../config/Pages'

const LearningSubMenu: FC = () => {

    const { t } = useTranslation('global')
    const location = useLocation()

    const isActive = (name: string) => {
        return location.pathname.includes(name)
    }

    return (
        <div className='py-12'>
            <div className='flex gap-3 items-center border-b pb-10 px-6'>
                <Teacher
                    size={24}
                    color='#000'
                    variant='Bold'
                />
                <div className='text-xs'>
                    {t('sidebar.learning')}
                </div>
            </div>

            <div className='flex flex-col mt-10 gap-4'>
                <SubMenuItem
                    title={t('learning.learnings')}
                    isActive={isActive('list')}
                    link={Pages.learning.list}
                />
                <SubMenuItem
                    title={t('learning.new_learning')}
                    isActive={isActive('create')}
                    link={Pages.learning.create}
                />
                <SubMenuItem
                    title={t('learning.category_learning')}
                    isActive={isActive('category')}
                    link={Pages.learning.category}
                />
            </div>

        </div>
    )
}

export default LearningSubMenu