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

const ProductsSubMenu: FC = () => {
    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 border-border pb-10 px-6'>
                <Element3
                    size={24}
                    color='#da2129'
                    variant='Bold'
                />
                <div className='text-xs'>
                    محصولات
                </div>
            </div>

            <div className='flex flex-col mt-10 gap-4'>
                <SubMenuItem
                    title={'دسته بندی ها'}
                    isActive={isActive('category')}
                    link={Pages.category.list}
                />
                <SubMenuItem
                    title={'تم'}
                    isActive={isActive('theme')}
                    link={Pages.products.theme.list}
                />
                <SubMenuItem
                    title={'برند ها'}
                    isActive={isActive('brands')}
                    link={Pages.products.brands.list}
                />
                <SubMenuItem
                    title={'محصولات'}
                    isActive={isActive('list')}
                    link="/products/list"
                />
                <SubMenuItem
                    title={'گارانتی ها'}
                    isActive={isActive('warranty')}
                    link={Pages.products.warranty.list}
                />

                <SubMenuItem
                    title={'نظرات محصولات'}
                    isActive={isActive('reviews')}
                    link={Pages.products.reviews.list}
                />

                <SubMenuItem
                    title={'پرسش های محصولات'}
                    isActive={isActive('questions')}
                    link={Pages.products.questions.list}
                />
            </div>
        </div>
    )
}

export default ProductsSubMenu
