Skip to content

Commit a48bcd6

Browse files
authored
Advanced filter: amount (#3208)
1 parent 5a49ad8 commit a48bcd6

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed
-16 Bytes
Loading
-25 Bytes
Loading

ui/advancedFilter/filters/AmountFilter.tsx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import type { AdvancedFilterParams } from 'types/api/advancedFilter';
77

88
import { Input } from 'toolkit/chakra/input';
99
import { PopoverCloseTriggerWrapper } from 'toolkit/chakra/popover';
10-
import { Tag } from 'toolkit/chakra/tag';
1110
import { ndash } from 'toolkit/utils/htmlEntities';
1211
import TableColumnFilter from 'ui/shared/filters/TableColumnFilter';
12+
import TagGroupSelect from 'ui/shared/tagGroupSelect/TagGroupSelect';
1313

1414
const FILTER_PARAM_FROM = 'amount_from';
1515
const 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

Comments
 (0)