73 lines
2.5 KiB
TypeScript
73 lines
2.5 KiB
TypeScript
'use client'
|
|
|
|
import { useDraggable } from '@dnd-kit/core'
|
|
import { CSS } from '@dnd-kit/utilities'
|
|
import { cn } from '@/lib/utils'
|
|
import { CodeBadge } from '@/components/shared/code-badge'
|
|
import type { SoloTask } from './solo-board'
|
|
|
|
const PRIORITY_BORDER: Record<number, string> = {
|
|
1: 'border-l-4 border-l-priority-critical',
|
|
2: 'border-l-4 border-l-priority-high',
|
|
3: 'border-l-4 border-l-priority-medium',
|
|
4: 'border-l-4 border-l-priority-low',
|
|
}
|
|
|
|
interface SoloTaskCardProps {
|
|
task: SoloTask
|
|
isDemo: boolean
|
|
onClick: () => void
|
|
}
|
|
|
|
export function SoloTaskCard({ task, isDemo, onClick }: SoloTaskCardProps) {
|
|
const { attributes, listeners, setNodeRef, transform, isDragging } = useDraggable({
|
|
id: task.id,
|
|
disabled: isDemo,
|
|
})
|
|
|
|
const style = transform ? { transform: CSS.Translate.toString(transform) } : undefined
|
|
|
|
return (
|
|
<div
|
|
ref={setNodeRef}
|
|
style={style}
|
|
onClick={onClick}
|
|
className={cn(
|
|
'bg-surface-container rounded border border-border px-3 py-2 select-none transition-colors',
|
|
PRIORITY_BORDER[task.priority],
|
|
isDragging ? 'opacity-40 z-50 shadow-lg' : 'hover:bg-surface-container-high',
|
|
isDemo ? 'cursor-pointer' : 'cursor-grab active:cursor-grabbing',
|
|
)}
|
|
{...(!isDemo ? { ...attributes, ...listeners } : {})}
|
|
>
|
|
<div className="flex items-start justify-between gap-2">
|
|
<p className="text-sm text-foreground leading-snug flex-1">{task.title}</p>
|
|
{task.task_code && <CodeBadge code={task.task_code} className="shrink-0 mt-0.5" />}
|
|
</div>
|
|
<p className="text-xs text-muted-foreground mt-0.5 truncate">
|
|
{task.story_code && <span className="font-mono mr-1">{task.story_code}</span>}
|
|
{task.story_title}
|
|
</p>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export function SoloTaskCardOverlay({ task }: { task: SoloTask }) {
|
|
return (
|
|
<div
|
|
className={cn(
|
|
'bg-surface-container rounded border border-primary px-3 py-2 shadow-xl opacity-90',
|
|
PRIORITY_BORDER[task.priority],
|
|
)}
|
|
>
|
|
<div className="flex items-start justify-between gap-2">
|
|
<p className="text-sm text-foreground leading-snug flex-1">{task.title}</p>
|
|
{task.task_code && <CodeBadge code={task.task_code} className="shrink-0 mt-0.5" />}
|
|
</div>
|
|
<p className="text-xs text-muted-foreground mt-0.5 truncate">
|
|
{task.story_code && <span className="font-mono mr-1">{task.story_code}</span>}
|
|
{task.story_title}
|
|
</p>
|
|
</div>
|
|
)
|
|
}
|