import React from 'react' import DynamicRenderer from './DynamicRenderer' import { useComponents } from '@/contexts/ComponentContext' import { Loading } from '../shared' export interface ComponentPreviewProps { componentName?: string className?: string } const ComponentPreview: React.FC = ({ componentName, className = '' }) => { const { components, loading } = useComponents() if (!componentName) { return
Bileşen ismi yok.
} // components dizisinin varlığını kontrol et if (loading || !components || !Array.isArray(components)) { return (
) } // Belirtilen bileşeni bul const component = components.find((c) => c.name === componentName && c.isActive) let dependencies: string[] = [] if (component?.dependencies) { try { // JSON string mi? if (component.dependencies.startsWith('[')) { dependencies = JSON.parse(component.dependencies) } else { // Virgülle ayrılmış düz metin dependencies = component.dependencies.split(',').map((d) => d.trim()) } } catch (err) { console.error('Dependency parse hatası:', err) dependencies = [] } } return (
) } export default ComponentPreview