@@ -3,7 +3,7 @@ import cn from 'bem-cn-lite';
33
44import { Select , SelectOption } from '@gravity-ui/uikit' ;
55
6- import EntityStatus from " ../../../components/EntityStatus/EntityStatus" ;
6+ import EntityStatus from ' ../../../components/EntityStatus/EntityStatus' ;
77
88import { getUsageSeverityForEntityStatus } from '../utils' ;
99
@@ -27,14 +27,7 @@ interface UsageFilterProps {
2727const b = cn ( 'usage-filter' ) ;
2828
2929export const UsageFilter = ( props : UsageFilterProps ) => {
30- const {
31- className,
32- value = [ ] ,
33- groups = [ ] ,
34- onChange,
35- debounce = 200 ,
36- disabled,
37- } = props ;
30+ const { className, value = [ ] , groups = [ ] , onChange, debounce = 200 , disabled} = props ;
3831
3932 const [ filterValue , setFilterValue ] = useState ( value ) ;
4033 const timer = useRef < number > ( ) ;
@@ -50,11 +43,15 @@ export const UsageFilter = (props: UsageFilterProps) => {
5043 } ) ;
5144 } , [ value ] ) ;
5245
53- const options = useMemo ( ( ) => groups . map ( ( { threshold, count} ) => ( {
54- value : String ( threshold ) ,
55- text : `${ threshold } %` ,
56- data : { count}
57- } ) ) , [ groups ] ) ;
46+ const options = useMemo (
47+ ( ) =>
48+ groups . map ( ( { threshold, count} ) => ( {
49+ value : String ( threshold ) ,
50+ text : `${ threshold } %` ,
51+ data : { count} ,
52+ } ) ) ,
53+ [ groups ] ,
54+ ) ;
5855
5956 const handleUpdate = ( newValue : string [ ] ) => {
6057 setFilterValue ( newValue ) ;
@@ -67,17 +64,20 @@ export const UsageFilter = (props: UsageFilterProps) => {
6764
6865 const maxWidth = Math . max ( ...groups . map ( ( { count} ) => count ) ) ;
6966
70- const renderOption = ( { value, data, text} : SelectOption ) => (
67+ const renderOption = ( { value : optionValue , data, text} : SelectOption ) => (
7168 < div className = { b ( 'option' ) } >
7269 < EntityStatus
7370 className = { b ( 'option-title' ) }
74- status = { getUsageSeverityForEntityStatus ( Number ( value ) ) }
71+ status = { getUsageSeverityForEntityStatus ( Number ( optionValue ) ) }
7572 name = { text }
7673 size = "xs"
7774 />
7875 < div className = { b ( 'option-meta' ) } >
7976 { i18n ( 'groups_count' , { count : data . count } ) }
80- < div className = { b ( 'option-bar' ) } style = { { width : `${ data . count / maxWidth * 100 } %` } } />
77+ < div
78+ className = { b ( 'option-bar' ) }
79+ style = { { width : `${ ( data . count / maxWidth ) * 100 } %` } }
80+ />
8181 </ div >
8282 </ div >
8383 ) ;
0 commit comments