'use client';

import { PRODUCTS, SERVICES } from '@/lib/constants';
import { SwipeNavigation } from '@/hooks/use-swipe-gesture';

interface DetailSwipeNavProps {
  type: 'product' | 'service' | 'solution';
  currentId: string;
  className?: string;
}

export function DetailSwipeNav({ type, currentId, className }: DetailSwipeNavProps) {
  let items: { id: string; title: string }[] = [];
  
  if (type === 'product') {
    items = PRODUCTS.map(p => ({ id: p.id, title: p.title }));
  } else if (type === 'service') {
    items = SERVICES.map(s => ({ id: s.id, title: s.title }));
  } else {
    return null;
  }

  const currentIndex = items.findIndex(item => item.id === currentId);
  
  if (currentIndex === -1) return null;

  const prevItem = currentIndex > 0 ? items[currentIndex - 1] : null;
  const nextItem = currentIndex < items.length - 1 ? items[currentIndex + 1] : null;

  const basePath = type === 'product' ? '/products' : type === 'service' ? '/services' : `/solutions`;

  return (
    <SwipeNavigation
      prevRoute={prevItem ? `${basePath}/${prevItem.id}` : undefined}
      nextRoute={nextItem ? `${basePath}/${nextItem.id}` : undefined}
      prevLabel={prevItem?.title || ''}
      nextLabel={nextItem?.title || ''}
      className={className}
    />
  );
}
