-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssessmentTemplateItem.tsx
More file actions
59 lines (52 loc) · 2.33 KB
/
AssessmentTemplateItem.tsx
File metadata and controls
59 lines (52 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
'use client';
import { CodeXml, GripVertical, Type } from 'lucide-react';
import { cn } from '@/lib/utils/cn.utils';
import { SortableItemHandle, useSortableItemContext } from '@/lib/components/ui/sortable';
import type { AssessmentSection } from '@/lib/types/assessment-template.types';
interface AssessmentTemplateItemProps {
section: AssessmentSection;
isSelected: boolean;
onSelect: () => void;
}
export default function AssessmentTemplateItem({
section,
isSelected,
onSelect,
}: AssessmentTemplateItemProps) {
const { isDragging } = useSortableItemContext('AssessmentTemplateItem');
const SectionIcon = section.type === 'task' ? CodeXml : Type;
const title = section.type === 'task' ? section.taskTemplate.title : '';
const estimatedTime = section.type === 'task' ? section.taskTemplate.estimatedTime : 0;
return (
<div className={cn('group relative px-5 py-1', isSelected && 'is-selected')}>
<SortableItemHandle
className={cn(
'absolute top-1/2 left-[3px] -translate-y-1/2 opacity-0 transition-opacity',
isDragging && 'opacity-100',
!isSelected && !isDragging && 'group-hover:opacity-100'
)}
>
<GripVertical className="text-sarge-gray-300 size-[15px]" />
</SortableItemHandle>
<div
className={cn(
'flex w-full cursor-pointer items-center justify-between rounded-lg border px-3 py-2',
isDragging
? 'border-sarge-primary-100 bg-sarge-primary-gray-50'
: isSelected
? 'border-sarge-primary-100 bg-sarge-primary-100'
: 'border-sarge-gray-200 hover:border-sarge-primary-100 hover:bg-sarge-gray-50'
)}
onClick={onSelect}
>
<div className="flex min-w-0 items-center gap-2">
<SectionIcon className="text-sarge-gray-700 size-5 shrink-0" />
<span className="text-label-xs truncate">{title}</span>
</div>
{estimatedTime > 0 && (
<span className="text-label-xs ml-2 shrink-0">{estimatedTime} minutes</span>
)}
</div>
</div>
);
}