Files
resolutionflow/frontend/src/components/admin/CategoryRow.tsx
Michael Chihlas d1a56f0529 refactor: migrate remaining components to Design System v4
111 files across 14 directories: common, tree-editor, kb-accelerator,
copilot, assistant, analytics, library, procedural, procedural-editor,
public, script-editor, ui, admin, step-library.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 02:18:15 -04:00

120 lines
3.3 KiB
TypeScript

import { GripVertical, Edit, Archive, RotateCcw } from 'lucide-react'
import { useSortable } from '@dnd-kit/sortable'
import { CSS } from '@dnd-kit/utilities'
import { cn } from '@/lib/utils'
import type { StepCategoryListItem } from '@/types'
interface CategoryRowProps {
category: StepCategoryListItem
stepCount: number
onEdit: (category: StepCategoryListItem) => void
onArchive: (id: string) => void
onRestore: (id: string) => void
}
export function CategoryRow({
category,
stepCount,
onEdit,
onArchive,
onRestore
}: CategoryRowProps) {
const {
attributes,
listeners,
setNodeRef,
transform,
transition,
isDragging
} = useSortable({ id: category.id })
const style = {
transform: CSS.Transform.toString(transform),
transition
}
return (
<div
ref={setNodeRef}
style={style}
className={cn(
'flex items-center gap-3 bg-[#14161d] border border-[#1e2130] rounded-xl p-4',
isDragging && 'opacity-50'
)}
>
{/* Drag Handle */}
<button
type="button"
{...attributes}
{...listeners}
className="cursor-grab touch-none text-[#848b9b] hover:text-[#e2e5eb] active:cursor-grabbing"
aria-label="Drag to reorder"
>
<GripVertical className="h-5 w-5" />
</button>
{/* Category Info */}
<div className="flex-1">
<div className="flex items-center gap-2">
<h3 className="font-medium text-[#e2e5eb]">{category.name}</h3>
{!category.is_active && (
<span className="rounded-full bg-accent px-2 py-0.5 text-xs font-medium text-[#848b9b]">
Archived
</span>
)}
</div>
{category.description && (
<p className="mt-1 text-sm text-[#848b9b]">{category.description}</p>
)}
<p className="mt-1 text-xs text-[#848b9b]">
{stepCount} step{stepCount !== 1 ? 's' : ''}
</p>
</div>
{/* Actions */}
<div className="flex gap-2">
<button
type="button"
onClick={() => onEdit(category)}
className={cn(
'rounded-md border border-[#1e2130] bg-[#14161d] p-2 text-[#848b9b]',
'hover:bg-accent hover:text-[#e2e5eb]'
)}
title="Edit category"
aria-label="Edit category"
>
<Edit className="h-4 w-4" />
</button>
{category.is_active ? (
<button
type="button"
onClick={() => onArchive(category.id)}
className={cn(
'rounded-md border border-input bg-[#0c0d10] p-2 text-[#848b9b]',
'hover:bg-accent hover:text-accent-foreground'
)}
title="Archive category"
aria-label="Archive category"
>
<Archive className="h-4 w-4" />
</button>
) : (
<button
type="button"
onClick={() => onRestore(category.id)}
className={cn(
'rounded-md border border-input bg-[#0c0d10] p-2 text-[#848b9b]',
'hover:bg-accent hover:text-accent-foreground'
)}
title="Restore category"
aria-label="Restore category"
>
<RotateCcw className="h-4 w-4" />
</button>
)}
</div>
</div>
)
}