import { DndContext, DragOverlay, closestCenter } from '@dnd-kit/core'; import { SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable'; import { useTranslation } from 'react-i18next'; import { GripVertical } from 'lucide-react'; import { Table, TableBody, TableHead, TableHeader, TableRow } from '@/components/ui/table'; import { OfferingRow } from './OfferingRow'; import { useOfferingsDnd } from '../hooks/useOfferingsDnd'; import type { OfferingAdminDto } from '../services/types'; interface OfferingsListProps { offerings: OfferingAdminDto[]; onDeleteRequested: (offering: OfferingAdminDto) => void; } export function OfferingsList({ offerings, onDeleteRequested }: OfferingsListProps) { const { t } = useTranslation(); const { items, sensors, activeItem, handleDragStart, handleDragEnd } = useOfferingsDnd(offerings); return ( {t('offerings.table.title')} {t('offerings.table.price')} {t('offerings.table.featured')} {t('offerings.table.actions')} o.id)} strategy={verticalListSortingStrategy}> {items.map((offering, index) => ( onDeleteRequested(offering)} /> ))}
{/* Rendered in a portal outside document flow, so the dragged item's position never grows the page's scrollable area the way transforming a table row in place would (a real browser behavior with in-place transforms, not a bug in dnd-kit itself). */} {activeItem && (
{activeItem.title} {activeItem.price}
)}
); }