'use client'; import Link from 'next/link'; import Image from 'next/image'; import { Button } from '@/components/ui/button'; import { Switch } from '@/components/ui/switch'; import { Edit2, ExternalLink, CheckCircle, XCircle } from 'lucide-react'; import type { Plan } from '@/types/form'; import { DeletePlanButton } from '@/components/templates/TouristPlan/components/DeletePlanButton'; import { DuplicatePlanButton } from '@/components/templates/TouristPlan/components/DuplicatePlanButton'; import { cn } from '@/lib/utils'; interface PlanListProps { plans: Plan[]; togglePublished: (id: string, currentState: boolean) => void; deletePlan: (id: string) => Promise; duplicatePlan: (id: string) => Promise; } // Componente para los botones de acción function ActionButtons({ planId, planTitle, categoryAlias, articleAlias, onDelete, onDuplicate }: { planId: string; planTitle: string; categoryAlias: string; articleAlias: string; onDelete: (id: string) => Promise; onDuplicate: (id: string) => Promise; }) { return (
); } // Componente para el estado de publicación function PublicationStatus({ isPublished }: { isPublished: boolean }) { return (
{isPublished ? (
Publicado
) : (
Borrador
)}
); } export function PlanList({ plans, togglePublished, deletePlan, duplicatePlan }: PlanListProps) { return (
{plans.map((plan, index) => { // Generar un ID único para cada plan basado en su ID y posición const planKey = `plan-${plan.id}-${index}`; return (
{/* Miniatura de imagen */}
{plan.mainImage?.url ? ( {plan.mainTitle} ) : (
Sin imagen
)}

{plan.mainTitle}

{plan.destination} {plan.categoryAlias}
{plan.published ? 'Publicado' : 'Borrador'} togglePublished(plan.id, plan.published)} className="data-[state=checked]:bg-teal-500" />
); })}
); }