import { itemLabel } from "@ax/constants";
import type { IBulkSelectedItems } from "@ax/hooks";

import TableHeader from "./TableHeader";

import * as S from "./style";

const BulkHeader = (props: IProps): JSX.Element => {
	const {
		showBulk,
		checkState,
		selectItems,
		totalItems,
		isScrolling,
		bulkActions,
		setHoverCheck,
		selectedItems,
		isLoading,
	} = props;

	return showBulk ? (
		<S.StyledBulkSelectionOptions
			checkState={checkState}
			actions={bulkActions}
			selectItems={selectItems}
			totalItems={totalItems}
			selectedItems={selectedItems}
			isLoading={isLoading}
			itemLabel={itemLabel.CATEGORY}
		/>
	) : (
		<TableHeader
			totalItems={totalItems}
			selectAllItems={selectItems}
			isScrolling={isScrolling}
			setHoverCheck={setHoverCheck}
			checkState={checkState}
		/>
	);
};

interface IProps {
	showBulk: boolean;
	checkState: Record<string, boolean>;
	selectItems: () => void;
	totalItems: number;
	isScrolling: boolean;
	bulkActions: { icon: string; text: string; action: () => void }[];
	setHoverCheck: (state: boolean) => void;
	selectedItems: IBulkSelectedItems;
	isLoading: boolean;
}

export default BulkHeader;
