import { useState } from 'react' import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card' import { Button } from '@/components/ui/button' import { Badge } from '@/components/ui/badge' import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs' import { useSeedTemplates, type TemplateType } from '@/hooks/data/use-seed-templates' import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog' import { Alert, AlertDescription } from '@/components/ui/alert' import { TemplateExplorer } from './TemplateExplorer' import { toast } from 'sonner' import { Download, Package, Plus, Trash } from '@phosphor-icons/react' export function TemplateSelector() { const { templates, isLoading, clearAndLoadTemplate, mergeTemplate } = useSeedTemplates() const [selectedTemplate, setSelectedTemplate] = useState(null) const [showConfirmDialog, setShowConfirmDialog] = useState(false) const [actionType, setActionType] = useState<'replace' | 'merge'>('replace') const handleSelectTemplate = (templateId: TemplateType, action: 'replace' | 'merge') => { setSelectedTemplate(templateId) setActionType(action) setShowConfirmDialog(true) } const handleConfirmLoad = async () => { if (!selectedTemplate) return setShowConfirmDialog(false) const success = actionType === 'replace' ? await clearAndLoadTemplate(selectedTemplate) : await mergeTemplate(selectedTemplate) if (success) { toast.success(`Template loaded successfully!`, { description: `${actionType === 'replace' ? 'Replaced' : 'Merged'} with ${selectedTemplate} template` }) window.location.reload() } else { toast.error('Failed to load template', { description: 'Please try again or check the console for errors' }) } } return ( <> Load Templates Explore Templates

Project Templates

Start your project with pre-configured templates including models, components, and workflows

{templates.map((template) => (
{template.icon}
{template.name} {template.description}
{template.features.map((feature, idx) => ( {feature} ))}
))}
Load Template: Replaces all existing data with the selected template.
Merge: Adds template data to your existing project without removing current data.
{actionType === 'replace' ? 'Replace Project Data?' : 'Merge Template Data?'} {actionType === 'replace' ? ( <> This will delete all existing data and load the{' '} {selectedTemplate} template. This action cannot be undone. ) : ( <> This will add the {selectedTemplate} template data to your existing project without removing current data. )} ) }