import React, { useState } from 'react'; import { Play, AlertTriangle } from 'lucide-react'; import type { Dataset } from '../../types'; interface DataPreviewProps { dataset: Dataset; code: string; inputColumns: string[]; outputColumns: string[]; } export function DataPreview({ dataset, code, inputColumns, outputColumns }: DataPreviewProps) { const [isRunning, setIsRunning] = useState(false); const [error, setError] = useState(null); const [previewData, setPreviewData] = useState[] | null>(null); const runFeature = () => { setIsRunning(true); setError(null); // Simulate feature execution setTimeout(() => { try { // In a real implementation, this would execute the Ruby code // For now, we'll just show the original data setPreviewData(dataset.sampleData); setIsRunning(false); } catch (err) { setError(err instanceof Error ? err.message : 'An error occurred'); setIsRunning(false); } }, 1000); }; return (

Data Preview

{error && (

Feature Error

                {error}
              
)}
Input Data
{inputColumns.map((column) => ( ))} {dataset.sampleData.map((row, i) => ( {inputColumns.map((column) => ( ))} ))}
{column}
{String(row[column])}
{previewData ? 'Featureed Data' : 'Output Preview'}
{previewData ? ( {outputColumns.map((column) => ( ))} {previewData.map((row, i) => ( {outputColumns.map((column) => ( ))} ))}
{column}
{String(row[column])}
) : (
Run the feature to see the preview
)}
); }