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

import TableHeader from "./TableHeader";

import * as S from "./style";

const BulkListHeader = (props: IBulkHeaderProps): JSX.Element => {
	const {
		showBulk,
		checkState,
		selectItems,
		selectAllItems,
		totalItems,
		bulkActions,
		isSearching,
		setHoverCheck,
		selectedItems,
		isLoading,
	} = props;

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

export interface IBulkHeaderProps {
	showBulk: boolean;
	checkState: any;
	selectItems: () => void;
	selectAllItems: () => void;
	totalItems: number;
	bulkActions: IBulkAction[];
	isSearching: boolean;
	setHoverCheck: (state: boolean) => void;
	selectedItems: IBulkSelectedItems;
	isLoading: boolean;
}

export default BulkListHeader;
