import { BulkSelectionOptions } from "@ax/components";
import { itemLabel } from "@ax/constants";
import type { IQueryValue } from "@ax/types";

import type { IBulkSelectedItems } from "src/hooks/bulk";

import TableHeader from "./TableHeader";

const BulkHeader = (props: IProps): JSX.Element => {
	const {
		showBulk,
		checkState,
		bulkDelete,
		selectItems,
		selectAllItems,
		totalItems,
		isScrolling,
		filterItems,
		filterValues,
		isSiteItem,
		sortItems,
		sortedListStatus,
		setHoverCheck,
		selectedItems,
		isLoading,
	} = props;

	const bulkActions = [
		{
			icon: "delete",
			text: "delete",
			action: bulkDelete,
		},
	];

	return showBulk ? (
		<BulkSelectionOptions
			checkState={checkState}
			actions={bulkActions}
			selectItems={selectItems}
			totalItems={totalItems}
			selectedItems={selectedItems}
			isLoading={isLoading}
			itemLabel={itemLabel.REDIRECT}
		/>
	) : (
		<TableHeader
			totalItems={totalItems}
			selectAllItems={selectAllItems}
			isScrolling={isScrolling}
			filterItems={filterItems}
			filterValues={filterValues}
			isSiteItem={isSiteItem}
			sortItems={sortItems}
			sortedListStatus={sortedListStatus}
			checkState={checkState}
			setHoverCheck={setHoverCheck}
		/>
	);
};

interface IProps {
	showBulk: boolean;
	checkState: any;
	bulkDelete: () => void;
	selectItems: () => void;
	selectAllItems: () => void;
	totalItems: number;
	isScrolling: boolean;
	filterItems: (filterPointer: string, filtersSelected: IQueryValue[]) => void;
	filterValues: any;
	isSiteItem: boolean;
	sortItems: (orderPointer: IQueryValue[], isAscending: boolean) => void;
	sortedListStatus: { isAscending: boolean; sortedByDate: boolean };
	setHoverCheck: (state: boolean) => void;
	selectedItems: IBulkSelectedItems;
	isLoading: boolean;
}

export default BulkHeader;
