import { Icon } from 'Components/Icons';
import React, { memo, ReactNode, useState } from 'react';
import { areEqual } from 'Utils/equalityChecks';
import { width } from 'Utils/screen';
import { Tab } from '../Tab';
import classes from './forms.tabs.module.css';
interface Props {
id?: string;
className?: string;
children?: ReactNode;
}
const createTabs = (activeTab: string, onTabClick: (e: any) => void) => (
<>
<>
Contract Forms
>
>
);
/*
In order to override bootstraps active class on tabs, there is a click event onTabClick, which will get the name of the tab that was clicked
and then trigger a re-render. Note in the createTabs method above, where the active class is added or not, based on which tab was clicked.
*/
const FormTabs = ({ id = 'tabs', className, children }: Props) => {
// We want to set the initial active tab to the first tab in the incoming tabList
const [activeTab, setActiveTab] = useState('contract-forms-tab');
const onTabClick = (e: any) => {
// Occasionally, e.currentTarget is undefined. Set the current activeTab if we run into this bug
setActiveTab(e?.currentTarget?.id || activeTab);
};
return (
{createTabs(activeTab, onTabClick)}
{children}
);
};
FormTabs.defaultProps = {
id: undefined,
className: undefined,
children: undefined,
};
const FormTabsMemo = memo(FormTabs, areEqual);
export { FormTabsMemo as FormTabs };