diff --git a/frontend/src/components/step-library/StepCard.tsx b/frontend/src/components/step-library/StepCard.tsx index 5a37e672..a4be0efc 100644 --- a/frontend/src/components/step-library/StepCard.tsx +++ b/frontend/src/components/step-library/StepCard.tsx @@ -1,11 +1,15 @@ -import { Star, User, Calendar, TrendingUp, Eye, Plus, HelpCircle, Zap, CheckCircle } from 'lucide-react' +import { Star, User, Calendar, TrendingUp, Eye, Plus, HelpCircle, Zap, CheckCircle, Pencil, Trash2, Bookmark } 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 + 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 = { @@ -20,12 +24,14 @@ const stepTypeColors = { solution: 'bg-emerald-400/10 text-emerald-400 border-emerald-400/20' } -export function StepCard({ step, onPreview, onInsert }: StepCardProps) { +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 */} @@ -118,26 +124,70 @@ export function StepCard({ step, onPreview, onInsert }: StepCardProps) { {/* Actions */}
- - + {(onEdit || onDelete || onSave) ? ( + isOwn ? ( + // Own step: Preview + Edit + Delete icon + <> + + + + + ) : ( + // Others' step: Preview + Save + <> + + + + ) + ) : ( + // Session context (original): Preview + Insert + <> + + + + )}
)