'use client'; import { ReactNode } from 'react'; import Link from 'next/link'; import { usePathname, useSearchParams } from 'next/navigation'; import AppLayout from './AppLayout'; interface ImportTab { id: string; label: string; href: string; description: string; } interface ImportLayoutProps { children: ReactNode; title: string; description?: string; } const importTabs: ImportTab[] = [ { id: 'manual', label: 'Manual Entry', href: '/import', description: 'Add a story by manually entering details' }, { id: 'url', label: 'Import from URL', href: '/import?mode=url', description: 'Import a single story from a website' }, { id: 'epub', label: 'Import EPUB', href: '/import/epub', description: 'Import a story from an EPUB file' }, { id: 'bulk', label: 'Bulk Import', href: '/import/bulk', description: 'Import multiple stories from a list of URLs' } ]; export default function ImportLayout({ children, title, description }: ImportLayoutProps) { const pathname = usePathname(); const searchParams = useSearchParams(); const mode = searchParams.get('mode'); // Determine which tab is active const getActiveTab = () => { if (pathname === '/import') { return mode === 'url' ? 'url' : 'manual'; } else if (pathname === '/import/epub') { return 'epub'; } else if (pathname === '/import/bulk') { return 'bulk'; } return 'manual'; }; const activeTab = getActiveTab(); return (
{/* Header */}

{title}

{description && (

{description}

)}
{/* Tab Navigation */}
{/* Tab Headers */}
{importTabs.map((tab) => (
{tab.label}
))}
{/* Tab Descriptions */}

{importTabs.find(tab => tab.id === activeTab)?.description}

{/* Tab Content */}
{children}
{/* Quick Actions */}
← Back to Library
); }