@@ -7,9 +7,9 @@ import type { AdvancedFilterParams } from 'types/api/advancedFilter';
77
88import { Input } from 'toolkit/chakra/input' ;
99import { PopoverCloseTriggerWrapper } from 'toolkit/chakra/popover' ;
10- import { Tag } from 'toolkit/chakra/tag' ;
1110import { ndash } from 'toolkit/utils/htmlEntities' ;
1211import TableColumnFilter from 'ui/shared/filters/TableColumnFilter' ;
12+ import TagGroupSelect from 'ui/shared/tagGroupSelect/TagGroupSelect' ;
1313
1414const FILTER_PARAM_FROM = 'amount_from' ;
1515const FILTER_PARAM_TO = 'amount_to' ;
@@ -67,8 +67,8 @@ const AmountFilter = ({ value = {}, handleFilterChange }: Props) => {
6767 handleFilterChange ( FILTER_PARAM_TO , currentValue . to ) ;
6868 } , [ handleFilterChange , currentValue ] ) ;
6969
70- const onPresetClick = React . useCallback ( ( event : React . SyntheticEvent ) => {
71- const to = ( event . currentTarget as HTMLDivElement ) . getAttribute ( 'data-id' ) as string ;
70+ const onPresetChange = React . useCallback ( ( to : string ) => {
71+ setCurrentValue ( { from : '' , to } ) ;
7272 handleFilterChange ( FILTER_PARAM_FROM , '' ) ;
7373 handleFilterChange ( FILTER_PARAM_TO , to ) ;
7474 } , [ handleFilterChange ] ) ;
@@ -84,16 +84,11 @@ const AmountFilter = ({ value = {}, handleFilterChange }: Props) => {
8484 >
8585 < PopoverCloseTriggerWrapper >
8686 < Flex gap = { 3 } >
87- { PRESETS . map ( preset => (
88- < Tag
89- key = { preset . value }
90- data-id = { preset . value }
91- onClick = { onPresetClick }
92- variant = "select"
93- >
94- { preset . name }
95- </ Tag >
96- ) ) }
87+ < TagGroupSelect < string >
88+ items = { PRESETS . map ( ( preset ) => ( { id : preset . value , title : preset . name } ) ) }
89+ onChange = { onPresetChange }
90+ value = { ( ! currentValue . from || currentValue . from === '0' ) ? PRESETS . find ( preset => preset . value === currentValue . to ) ?. value : undefined }
91+ />
9792 </ Flex >
9893 </ PopoverCloseTriggerWrapper >
9994 < Flex mt = { 3 } alignItems = "center" >
0 commit comments