'use client'; // Required for client-side interactivity

import { usePathname, useRouter } from 'next/navigation';
import React from 'react';

interface SidebarNavProps {
  items: {
    href: string;
    title: string;
  }[];
}

export function SidebarNav({ items }: SidebarNavProps) {
  const router = useRouter();
  const pathname = usePathname();

  return (
    <div className="flex flex-wrap gap-2">
      {items.map((item) => (
        <button
          key={item.href}
          onClick={() => router.push(item.href)}
          className={`px-3 py-2 rounded-md text-sm font-medium ${
            pathname === item.href ? 'bg-gray-100' : 'hover:bg-gray-50'
          }`}
        >
          {item.title}
        </button>
      ))}
    </div>
  );
}