'use client' import { useState, useCallback } from 'react' import { motion, AnimatePresence } from 'framer-motion' import { ArrowRight, ArrowLeft, Check, FileText, Edit3, Eye, Download } from 'lucide-react' import type { GeneratorSection, GeneratorData } from '@/types' import SectionEditor from './SectionEditor' import Preview from './Preview' import { nanoid } from 'nanoid' interface GeneratorWizardProps { onComplete?: (data: GeneratorData) => void } type Step = 'basic' | 'sections' | 'preview' const TEMPLATES = [ { id: 'empty', name: 'Empty', description: 'Start from scratch', sections: [], }, { id: 'basic-docs', name: 'Basic Documentation', description: 'Standard documentation structure', sections: [ { id: nanoid(), title: 'Getting Started', content: 'Quick start guide for new users...' }, { id: nanoid(), title: 'Installation', content: 'How to install and configure...' }, { id: nanoid(), title: 'Usage', content: 'Basic usage examples...' }, { id: nanoid(), title: 'API Reference', content: 'API documentation...' }, ], }, { id: 'api-reference', name: 'API Reference', description: 'For API documentation', sections: [ { id: nanoid(), title: 'Authentication', content: 'How to authenticate requests...' }, { id: nanoid(), title: 'Endpoints', content: 'List of available endpoints...' }, { id: nanoid(), title: 'Request Format', content: 'How to format API requests...' }, { id: nanoid(), title: 'Response Format', content: 'API response structure...' }, { id: nanoid(), title: 'Error Handling', content: 'Error codes and handling...' }, ], }, { id: 'product-docs', name: 'Product Documentation', description: 'For product/service docs', sections: [ { id: nanoid(), title: 'Overview', content: 'Product overview and key features...' }, { id: nanoid(), title: 'Features', content: 'Detailed feature descriptions...' }, { id: nanoid(), title: 'Pricing', content: 'Pricing tiers and options...' }, { id: nanoid(), title: 'FAQ', content: 'Frequently asked questions...' }, { id: nanoid(), title: 'Support', content: 'How to get support...' }, ], }, ] export default function GeneratorWizard({ onComplete }: GeneratorWizardProps) { const [step, setStep] = useState('basic') const [data, setData] = useState({ siteName: '', description: '', url: '', sections: [], }) const [selectedTemplate, setSelectedTemplate] = useState('empty') const handleBasicSubmit = useCallback((e: React.FormEvent) => { e.preventDefault() // Apply template sections if template was selected const template = TEMPLATES.find(t => t.id === selectedTemplate) if (template && template.sections.length > 0 && data.sections.length === 0) { setData(prev => ({ ...prev, sections: template.sections.map(s => ({ ...s, id: nanoid() })), })) } setStep('sections') }, [selectedTemplate, data.sections.length]) const handleSectionsChange = useCallback((sections: GeneratorSection[]) => { setData(prev => ({ ...prev, sections })) }, []) const handleComplete = useCallback(() => { onComplete?.(data) }, [data, onComplete]) const canProceedToSections = data.siteName.trim().length > 0 const canProceedToPreview = data.sections.length > 0 return (
{/* Progress Steps */}
{[ { id: 'basic', label: 'Basic Info', icon: FileText }, { id: 'sections', label: 'Sections', icon: Edit3 }, { id: 'preview', label: 'Preview', icon: Eye }, ].map((s, index) => (
{index < 2 && ( )}
))}
{/* Step Content */} {/* Step 1: Basic Info */} {step === 'basic' && (

Basic Information

setData(prev => ({ ...prev, siteName: e.target.value }))} placeholder="My Documentation" className="w-full px-4 py-3 bg-black border border-neutral-700 rounded-xl text-white placeholder-neutral-500 focus:border-neutral-500 focus:outline-none" required />