import React from "react";

import { CheckField, TableCounter, Tooltip } from "@ax/components";
import * as S from "./style";

const TableHeader = (props: IProps): JSX.Element => {
	const { totalItems, selectAllItems, isScrolling, checkState, setHoverCheck } = props;

	return (
		<S.TableHeader isScrolling={isScrolling}>
			<S.CheckHeader>
				<Tooltip content="Select All Items" bottom>
					<CheckField
						key="selectAll"
						name="selectAll"
						value="selectAll"
						onChange={selectAllItems}
						checked={checkState.isAllSelected || checkState.hoverCheck}
						disabled={false}
						error={false}
						setHoverCheck={setHoverCheck}
					/>
				</Tooltip>
			</S.CheckHeader>
			<S.NameHeader>Name</S.NameHeader>
			<S.TransHeader>Translations</S.TransHeader>
			<S.DefaultHeader></S.DefaultHeader>
			<S.ActionsHeader>
				<TableCounter totalItems={totalItems} />
			</S.ActionsHeader>
		</S.TableHeader>
	);
};

interface IProps {
	totalItems: number;
	isScrolling: boolean;
	selectAllItems: () => void;
	checkState: Record<string, boolean>;
	setHoverCheck: (state: boolean) => void;
}

export default TableHeader;
