'use client'; import { cx } from 'class-variance-authority'; import { useCallback } from 'react'; import { FilterOperation, FilterOperator } from '~/types/filters'; import { Select } from '../select'; import { Text } from '../text'; import styles from './filter-chip.module.css'; interface OperationProps { label: string; value?: FilterOperation; onChange: (operation: FilterOperation) => void; operations: FilterOperator[]; showAlternateLabel?: boolean; } export const Operation = ({ label, value, onChange, operations, showAlternateLabel = false }: OperationProps) => { const operationValue = value?.value ?? ''; const handleValueChange = useCallback( (newValue: string) => { const operation = operations.find(o => o.value === newValue); if (operation) onChange(operation); }, [operations, onChange] ); if (operations.length === 1) return ( {operations[0].label} ); return ( ); };