import { useState } from '@wordpress/element'; import { Button, Modal } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; import LCPDataGrid from './LCPDataGrid'; const LCPDatasetBuilder = ({ attributes }) => { const [isOpen, setIsOpen] = useState(false); const [activeTab, setActiveTab] = useState(0); // Track the active tab return ( <> setIsOpen(true)} style={{ marginBottom: '10px', width: '100%' }} > {__('Edit Dataset', 'lcp-visualize')} {isOpen && ( setIsOpen(false)} title={__('Dataset Builder', 'lcp-visualize')} style={{ width: '90vw', height: '90vh' }} > {/* Tabs */} {attributes.datasets.map((dataset, index) => ( setActiveTab(index)} // Set the active tab style={{ padding: '10px 20px', margin: '0 5px', backgroundColor: activeTab === index ? '#007cba' : '#f1f1f1', color: activeTab === index ? 'white' : 'black', border: '1px solid #ccc', borderRadius: '5px', cursor: 'pointer', transition: 'background-color 0.3s ease', }} > {dataset.name} ))} {/* Render all the LCPDataGrid components */} {attributes.datasets.map((dataset, index) => ( ))} )} > ); }; export default LCPDatasetBuilder;