import React from 'react'
import clsx from 'clsx'
import Link from 'next/link'
import { trackCallback } from 'web/lib/service/analytics'
export type Item = {
name: string
trackingEventName?: string
href: string
key?: string
icon?: React.ComponentType<{ className?: string }>
}
export function SidebarItem(props: { item: Item; currentPage: string }) {
const { item, currentPage } = props
const isCurrentPage =
item.href != null ? item.href === currentPage : item.key === currentPage
const sidebarItem = (
{
trackCallback('sidebar: ' + item.name)
}}
className={clsx(
isCurrentPage
? 'bg-gray-200 text-gray-900'
: 'text-gray-600 hover:bg-gray-100',
'group flex items-center rounded-md px-3 py-2 text-sm font-medium'
)}
aria-current={item.href == currentPage ? 'page' : undefined}
>
{item.icon && (
)}
{item.name}
)
return {sidebarItem}
}