'use client'; import { CaretDownIcon, CaretSortIcon, CaretUpIcon, } from '@radix-ui/react-icons'; import { Flex, IconButton, Table } from '@radix-ui/themes'; import * as TankPerformanceSort from '../../../../stores/tankPerformanceSort'; import { tankPerformanceSortTypeNames, tankPerformanceSortTypeNamesArray, } from '../../../../stores/tankPerformanceSort/constants'; export function Header() { const sort = TankPerformanceSort.use(); const store = TankPerformanceSort.useStore(); return ( Tank {tankPerformanceSortTypeNamesArray.map((type) => { const isSelected = sort.type === type; return ( {tankPerformanceSortTypeNames[type]} { if (isSelected) { store.setState({ direction: -sort.direction as 1 | -1 }); } else { store.setState({ type, direction: -1 }); } }} > {!isSelected && } {isSelected && ( <> {sort.direction === 1 && } {sort.direction === -1 && } )} ); })} ); }