import React from 'react'; import { TextField, Typography, IconButton, Box } from '@mui/material'; import DeleteIcon from '@mui/icons-material/Delete'; // Import delete icon interface EditorProps { label: string; values: string[]; onValuesChange: (values: string[]) => void; } const Editor: React.FC = ({ label, values, onValuesChange }) => { const handleChange = (index: number) => (event: React.ChangeEvent) => { const newValues = [...values]; newValues[index] = event.target.value; onValuesChange(newValues); }; const handleDeleteQuestion = (index: number) => () => { const newValues = values.filter((_, i) => i !== index); // Remove the question at the specified index onValuesChange(newValues); }; return (
{/* Label with increased margin */} {label} {/* Map through each question */} {values.map((value, index) => ( {/* Bold "Question #" title */} Question {index + 1} {/* Delete button */} {/* TextField for the question */} ))}
); }; export default Editor;