Skip to content

Commit 62eb95d

Browse files
refactor 3
1 parent 0c1610f commit 62eb95d

File tree

3 files changed

+25
-27
lines changed

3 files changed

+25
-27
lines changed

src/components/Shared/StatusFilter/StatusFilter.tsx

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import React from 'react';
22
import { useTranslation } from 'react-i18next';
33
import { Select } from '@ui5/webcomponents-react';
4-
import RenderOption from './RenderOption';
4+
import StatusFilterOption, {
5+
StatusFilterOptionProps,
6+
} from './StatusFilterOption';
57

68
interface StatusFilterProps {
79
column: {
@@ -10,32 +12,28 @@ interface StatusFilterProps {
1012
};
1113
}
1214

13-
interface OptionConfig {
14-
value: string;
15-
iconName: string;
16-
color: string;
17-
labelKey: string;
18-
}
15+
const options: Pick<
16+
StatusFilterOptionProps,
17+
'value' | 'iconName' | 'color' | 'labelKey'
18+
>[] = [
19+
{ value: 'all', iconName: 'filter', color: 'gray', labelKey: 'All' },
20+
{
21+
value: 'true',
22+
iconName: 'sys-enter-2',
23+
color: 'green',
24+
labelKey: 'Enabled',
25+
},
26+
{
27+
value: 'false',
28+
iconName: 'sys-cancel-2',
29+
color: 'red',
30+
labelKey: 'Disabled',
31+
},
32+
];
1933

2034
const StatusFilter: React.FC<StatusFilterProps> = ({ column }) => {
2135
const { t } = useTranslation();
2236

23-
const options: OptionConfig[] = [
24-
{ value: 'all', iconName: 'filter', color: 'gray', labelKey: 'All' },
25-
{
26-
value: 'true',
27-
iconName: 'sys-enter-2',
28-
color: 'green',
29-
labelKey: 'Enabled',
30-
},
31-
{
32-
value: 'false',
33-
iconName: 'sys-cancel-2',
34-
color: 'red',
35-
labelKey: 'Disabled',
36-
},
37-
];
38-
3937
const handleChange = (
4038
e: CustomEvent<{ selectedOption: { dataset?: { value?: string } } }>,
4139
) => {
@@ -46,7 +44,7 @@ const StatusFilter: React.FC<StatusFilterProps> = ({ column }) => {
4644
return (
4745
<Select onChange={handleChange}>
4846
{options.map((option) => (
49-
<RenderOption
47+
<StatusFilterOption
5048
key={option.value}
5149
{...option}
5250
t={t}

src/components/Shared/StatusFilter/StatusFilter.module.css renamed to src/components/Shared/StatusFilter/StatusFilterOption.module.css

File renamed without changes.

src/components/Shared/StatusFilter/RenderOption.tsx renamed to src/components/Shared/StatusFilter/StatusFilterOption.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React from 'react';
22
import { Option, Icon } from '@ui5/webcomponents-react';
3-
import styles from './StatusFilter.module.css';
3+
import styles from './StatusFilterOption.module.css';
44

5-
interface RenderOptionProps {
5+
export interface StatusFilterOptionProps {
66
value: string;
77
iconName: string;
88
color: string;
@@ -11,7 +11,7 @@ interface RenderOptionProps {
1111
isSelected: boolean;
1212
}
1313

14-
const RenderOption: React.FC<RenderOptionProps> = ({
14+
const RenderOption: React.FC<StatusFilterOptionProps> = ({
1515
value,
1616
iconName,
1717
color,

0 commit comments

Comments
 (0)