import React, { ReactNode } from 'react'; import { HiArrowDown, HiArrowUp } from 'react-icons/hi'; import { RiArrowUpDownFill } from 'react-icons/ri'; import { useTheme } from '../../../hooks/theme'; import { Container } from './styles'; type SortType = { direction: string; dataIndex: string; }; type HeaderCellProps = { isAction?: boolean; dataIndex?: string; isSort?: boolean; sort?: SortType; onSort?: (sort: SortType) => void; children: ReactNode; align?: string; }; export function HeaderCell({ isAction, dataIndex = '', isSort, sort, onSort, children, align, }: HeaderCellProps): JSX.Element { const { colorScheme } = useTheme(); function toggleDirection(): void { if (onSort) { if (!sort?.direction) { onSort({ dataIndex, direction: 'ASC' }); } if (sort?.direction === 'ASC') { onSort({ dataIndex, direction: 'DESC' }); } if (sort?.direction === 'DESC') { onSort({ dataIndex, direction: '' }); } } } return ( {children} {isSort && onSort && !sort?.direction && ( )} {isSort && onSort && sort?.direction === 'ASC' && ( )} {isSort && onSort && sort?.direction === 'DESC' && ( )} ); }