import { Star, User, Calendar, TrendingUp, Eye, Plus, HelpCircle, Zap, CheckCircle, Pencil, Trash2, Bookmark, Lock } from 'lucide-react' import { cn } from '@/lib/utils' import type { StepListItem } from '@/types/step' interface StepCardProps { step: StepListItem onPreview: (step: StepListItem) => void onInsert?: (step: StepListItem) => void // session context (now optional) onEdit?: (step: StepListItem) => void // library page onDelete?: (step: StepListItem) => void // library page — NOTE: pass full StepListItem, not just ID onSave?: (step: StepListItem) => void // library page (save copy to My Steps) currentUserId?: string // to determine ownership } const stepTypeIcons = { decision: HelpCircle, action: Zap, solution: CheckCircle } const stepTypeColors = { decision: 'bg-blue-400/10 text-blue-400 border-blue-400/20', action: 'bg-yellow-400/10 text-yellow-400 border-yellow-400/20', solution: 'bg-emerald-400/10 text-emerald-400 border-emerald-400/20' } export function StepCard({ step, onPreview, onInsert, onEdit, onDelete, onSave, currentUserId }: StepCardProps) { const Icon = stepTypeIcons[step.step_type as keyof typeof stepTypeIcons] || HelpCircle const hasRating = step.rating_count > 0 const visibleTags = step.tags.slice(0, 3) const remainingTags = step.tags.length - 3 const isOwn = currentUserId ? step.created_by === currentUserId : false return (
{/* Header */}
{/* Step Type Badge */} {step.step_type} {/* Featured Badge */} {step.is_featured && ( Featured )} {/* From Flow Badge */} {step.is_flow_synced && ( From Flow )}
{/* Title */}

{step.title}

{/* Metadata */}
{/* Category */} {step.category_name && (
📁 {step.category_name}
)} {/* Rating */}
{hasRating ? ( {step.rating_average.toFixed(1)} ({step.rating_count} {step.rating_count === 1 ? 'rating' : 'ratings'}) ) : ( Not rated )}
{/* Usage Count */}
Used {step.usage_count} {step.usage_count === 1 ? 'time' : 'times'}
{/* Author & Date */}
{step.author_name || 'Unknown'}
{new Date(step.created_at).toLocaleDateString()}
{/* Tags */} {step.tags.length > 0 && (
{visibleTags.map(tag => ( {tag} ))} {remainingTags > 0 && ( +{remainingTags} more )}
)} {/* Actions */}
{(onEdit || onDelete || onSave) ? ( isOwn ? ( step.is_flow_synced ? ( // Flow-synced step: Preview + lock (read-only) <> ) : ( // Own step: Preview + Edit + Delete icon <> ) ) : ( // Others' step: Preview + Save <> ) ) : ( // Session context (original): Preview + Insert <> )}
) }