Skip to content

Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️

1.5 KB
Raw Blame
import {ActionIcon} from '@mantine/core';
import {IconCaretDownFilled, IconCaretUpFilled} from '@tabler/icons-react';
import {useAccess} from "../../../hooks/useAccess.ts";

interface SortArrowsProps {
    upArrowEnabled: boolean;
    downArrowEnabled: boolean;
    onSortUp: () => void;
    onSortDown: () => void;
    flexDirection?: 'row' | 'column';
}

export const SortArrows = ({
                               upArrowEnabled,
                               downArrowEnabled,
                               onSortUp,
                               onSortDown,
                               flexDirection = 'row'
                           }: SortArrowsProps) => {
    const {isReadOnly} = useAccess();

    if (isReadOnly) {
        return null;
    }

    return (
        <div style={{
            display: 'flex',
            flexDirection: flexDirection,
            alignItems: 'center'
        }}>
            <ActionIcon
                onClick={upArrowEnabled ? onSortUp : undefined}
                variant="transparent"
                aria-label="Sort Up"
                color={upArrowEnabled ? 'currentColor' : '#ddd'}
            >
                <IconCaretUpFilled size={18}/>
            </ActionIcon>
            <ActionIcon
                onClick={downArrowEnabled ? onSortDown : undefined}
                variant="transparent"
                aria-label="Sort Down"
                color={downArrowEnabled ? 'currentColor' : '#ddd'}
            >
                <IconCaretDownFilled size={18}/>
            </ActionIcon>
        </div>
    );
};