import Link from 'next/link'
import React from 'react'
import type { LinkProps } from 'next/link'
import { usePathname } from 'next/navigation'
import clsx from 'clsx'

type Props = {
  icon: React.ReactElement
  value: string
} & LinkProps & React.AnchorHTMLAttributes<HTMLAnchorElement>

function BottomNavLink({ icon, value, href, ...restProps }: Props) {
  const pathname = usePathname();
  const isActive = pathname === href;

  return (
    <Link {...restProps} href={href} className={clsx(
      'flex flex-col justify-arround items-center gap-[5px] text-disabled2',
      isActive && 'text-foreground **:stroke-foreground',
       restProps.className ?? '',
    )}>
      {icon}
      <span className={clsx(
        'text-xs2 text-disabled-text',
        isActive && 'text-foreground'
      )}>
        {value}
      </span>
    </Link>
  )
}

export default BottomNavLink
