import variables from 'config/variables'; import { useState } from 'react'; import Tab from './Tab'; import ReminderInfo from '../components/ReminderInfo'; import ErrorBoundary from '../../../../features/misc/modals/ErrorBoundary'; import { TAB_TYPES } from '../constants/tabConfig'; const Tabs = ({ children, navbar = false, currentTab: activeTab }) => { const [currentTab, setCurrentTab] = useState(children[0]?.props.label); const [currentName, setCurrentName] = useState(children[0]?.props.name); const [showReminder, setShowReminder] = useState(localStorage.getItem('showReminder') === 'true'); const handleTabClick = (tab, name) => { if (name !== currentName) { variables.stats.postEvent('tab', `Opened ${name}`); } setCurrentTab(tab); setCurrentName(name); }; const handleHideReminder = () => { localStorage.setItem('showReminder', 'false'); setShowReminder(false); }; // Only show sidebar for Settings tab const showSidebar = activeTab === TAB_TYPES.SETTINGS; return (
{showSidebar && (
{children.map((tab, index) => ( handleTabClick(nextTab, tab.props.name)} navbarTab={navbar} /> ))}
)}
{children.map((tab, index) => { if (tab.props.label !== currentTab) { return null; } return ( {tab.props.children} ); })}
); }; export default Tabs;