import React from 'react';
import classNames from 'classnames';
import { SessionButton } from './SessionButton';
const Tab = ({
isSelected,
label,
onSelect,
type,
}: {
isSelected: boolean;
label: string;
onSelect?: (event: number) => void;
type: number;
}) => {
const handleClick = onSelect
? () => {
onSelect(type);
}
: undefined;
return (
{label}
);
};
interface Props {
onTabSelected: any;
selectedTab: number;
labels: Array;
notificationCount?: number;
buttonLabel?: string;
buttonClicked?: any;
}
interface State {
selectedTab: number;
}
export class LeftPaneSectionHeader extends React.Component {
constructor(props: any) {
super(props);
this.state = { selectedTab: 0 };
}
public render() {
return this.renderTabs();
}
private renderTabs() {
const { selectedTab } = this.state;
const {
labels,
buttonLabel,
buttonClicked,
notificationCount,
} = this.props;
const children = [];
//loop to create children
for (let i = 0; i < labels.length; i++) {
children.push(
);
}
if (buttonLabel && !notificationCount) {
children.push(
);
} else if (buttonLabel && notificationCount && notificationCount > 0) {
const shortenedNotificationCount =
notificationCount > 9 ? 9 : notificationCount;
children.push(
{shortenedNotificationCount}
);
} else if (notificationCount && notificationCount > 0) {
const shortenedNotificationCount =
notificationCount > 9 ? 9 : notificationCount;
children.push(
{shortenedNotificationCount}
);
}
//Create the parent and add the children
return {children}
;
}
private readonly handleTabSelect = (tabType: number): void => {
this.setState({
selectedTab: tabType,
});
if (this.props.onTabSelected) {
this.props.onTabSelected(tabType);
}
};
}