| 1 | /** |
| 2 | * PlanListItem - 更多面板中的计划列表项 |
| 3 | * 显示计划名称、选中状态、编辑/删除操作 |
| 4 | */ |
| 5 | |
| 6 | 'use client' |
| 7 | |
| 8 | import type { PromotionPlan } from '@/api/materials/material.types' |
| 9 | import { Check, Pencil, Trash2 } from 'lucide-react' |
| 10 | import { useTransClient } from '@/app/i18n/client' |
| 11 | import { cn } from '@/utils/className' |
| 12 | |
| 13 | interface PlanListItemProps { |
| 14 | plan: PromotionPlan |
| 15 | isSelected: boolean |
| 16 | onSelect: (planId: string) => void |
| 17 | onEdit: (plan: PromotionPlan) => void |
| 18 | onDelete: (plan: PromotionPlan) => void |
| 19 | } |
| 20 | |
| 21 | function PlanListItem({ |
| 22 | plan, |
| 23 | isSelected, |
| 24 | onSelect, |
| 25 | onEdit, |
| 26 | onDelete, |
| 27 | }: PlanListItemProps) { |
| 28 | const { t } = useTransClient('brandPromotion') |
| 29 | |
| 30 | return ( |
| 31 | <div |
| 32 | className={cn( |
| 33 | 'flex items-center justify-between px-3 py-2.5 rounded-lg cursor-pointer transition-colors', |
| 34 | 'hover:bg-accent', |
| 35 | isSelected && 'bg-accent', |
| 36 | )} |
| 37 | onClick={() => onSelect(plan.id)} |
| 38 | > |
| 39 | <div className="flex items-center gap-2 min-w-0 flex-1"> |
| 40 | {isSelected && ( |
| 41 | <Check className="h-4 w-4 text-primary shrink-0" /> |
| 42 | )} |
| 43 | <span className={cn( |
| 44 | 'text-sm truncate', |
| 45 | isSelected && 'font-medium text-primary', |
| 46 | )} |
| 47 | > |
| 48 | {plan.name || plan.title} |
| 49 | </span> |
| 50 | </div> |
| 51 | <div className="flex items-center gap-1 shrink-0 ml-2"> |
| 52 | <button |
| 53 | className="p-1.5 rounded-md hover:bg-muted cursor-pointer transition-colors" |
| 54 | onClick={(e) => { |
| 55 | e.stopPropagation() |
| 56 | onEdit(plan) |
| 57 | }} |
| 58 | title={t('planTab.editPlan')} |
| 59 | > |
| 60 | <Pencil className="h-3.5 w-3.5 text-muted-foreground" /> |
| 61 | </button> |
| 62 | <button |
| 63 | className="p-1.5 rounded-md hover:bg-destructive/10 cursor-pointer transition-colors" |
| 64 | onClick={(e) => { |
| 65 | e.stopPropagation() |
| 66 | onDelete(plan) |
| 67 | }} |
| 68 | title={t('planTab.deletePlan')} |
| 69 | > |
| 70 | <Trash2 className="h-3.5 w-3.5 text-muted-foreground hover:text-destructive" /> |
| 71 | </button> |
| 72 | </div> |
| 73 | </div> |
| 74 | ) |
| 75 | } |
| 76 | |
| 77 | export default PlanListItem |
| 78 |