import React, { useState } from 'react'; import { __ } from '@/lib/i18n'; import { cn } from '@/lib/utils'; import { Button } from '@/components/ui/button'; import { Card } from '@/components/ui/card'; import { Plus, ChevronUp, ChevronDown, Trash2, GripVertical, LayoutTemplate, Type, Image, Grid3x3, Megaphone, MessageSquare, Loader2 } from 'lucide-react'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu'; interface Section { id: string; type: string; layoutVariant?: string; colorScheme?: string; props: Record; } interface SectionEditorProps { sections: Section[]; selectedSection: Section | null; onSelectSection: (section: Section | null) => void; onAddSection: (type: string) => void; onDeleteSection: (id: string) => void; onMoveSection: (id: string, direction: 'up' | 'down') => void; isTemplate: boolean; cpt?: string; isLoading: boolean; } const SECTION_TYPES = [ { type: 'hero', label: 'Hero', icon: LayoutTemplate }, { type: 'content', label: 'Content', icon: Type }, { type: 'image-text', label: 'Image + Text', icon: Image }, { type: 'feature-grid', label: 'Feature Grid', icon: Grid3x3 }, { type: 'cta-banner', label: 'CTA Banner', icon: Megaphone }, { type: 'contact-form', label: 'Contact Form', icon: MessageSquare }, ]; export function SectionEditor({ sections, selectedSection, onSelectSection, onAddSection, onDeleteSection, onMoveSection, isTemplate, cpt, isLoading, }: SectionEditorProps) { if (isLoading) { return (
); } return (
{/* Section Header */}

{__('Sections')}

{isTemplate && ( {__('Template: ')} {cpt} )}
{/* Sections List */}
{sections.map((section, index) => { const sectionType = SECTION_TYPES.find(s => s.type === section.type); const Icon = sectionType?.icon || LayoutTemplate; const hasDynamic = Object.values(section.props).some( p => typeof p === 'object' && p?.type === 'dynamic' ); return ( onSelectSection(section)} >
{sectionType?.label || section.type}
{section.layoutVariant || 'default'} {hasDynamic && ( ◆ {__('Dynamic')} )}
e.stopPropagation()}>
); })} {sections.length === 0 && (

{__('No sections yet. Add your first section.')}

)}
{/* Add Section Button */} {SECTION_TYPES.map((sectionType) => { const Icon = sectionType.icon; return ( onAddSection(sectionType.type)} > {sectionType.label} ); })}
); }