@@ -2,11 +2,12 @@ import { Button, Divider, H4, H5 } from '@blueprintjs/core'
2
2
import { Popover2 } from '@blueprintjs/popover2'
3
3
4
4
import clsx from 'clsx'
5
+ import { useAtomValue } from 'jotai'
5
6
import { FC , ImgHTMLAttributes , useEffect , useMemo } from 'react'
6
7
7
8
import { PROFESSIONS } from 'models/operator'
8
9
9
- import { useTranslation } from '../../../../../i18n/i18n'
10
+ import { languageAtom , useTranslation } from '../../../../../i18n/i18n'
10
11
import {
11
12
DEFAULTPROFID ,
12
13
DEFAULTSUBPROFID ,
@@ -25,6 +26,7 @@ export const ProfClassificationWithFilters: FC<
25
26
ProfClassificationWithFiltersProp
26
27
> = ( { toTop } ) => {
27
28
const t = useTranslation ( )
29
+ const language = useAtomValue ( languageAtom )
28
30
const {
29
31
useProfFilterState : [ { selectedProf } , setProfFilter ] ,
30
32
usePaginationFilterState : [ _ , setPaginationFilter ] ,
@@ -36,19 +38,31 @@ export const ProfClassificationWithFilters: FC<
36
38
id : DEFAULTPROFID . ALL ,
37
39
name : t . components . editor . operator . sheet . sheetOperator
38
40
. ProfClassificationWithFilters . all ,
41
+ name_en :
42
+ t . components . editor . operator . sheet . sheetOperator
43
+ . ProfClassificationWithFilters . all ,
39
44
sub : [ ] ,
40
45
} ,
41
46
{
42
47
id : DEFAULTPROFID . FAV ,
43
48
name : t . components . editor . operator . sheet . sheetOperator
44
49
. ProfClassificationWithFilters . favorites ,
50
+ name_en :
51
+ t . components . editor . operator . sheet . sheetOperator
52
+ . ProfClassificationWithFilters . favorites ,
45
53
sub : [ ] ,
46
54
} ,
47
- ...PROFESSIONS ,
55
+ ...PROFESSIONS . map ( ( profession ) => ( {
56
+ ...profession ,
57
+ name_en : profession . name_en || profession . name ,
58
+ } ) ) ,
48
59
{
49
60
id : DEFAULTPROFID . OTHERS ,
50
61
name : t . components . editor . operator . sheet . sheetOperator
51
62
. ProfClassificationWithFilters . others ,
63
+ name_en :
64
+ t . components . editor . operator . sheet . sheetOperator
65
+ . ProfClassificationWithFilters . others ,
52
66
sub : [ ] ,
53
67
} ,
54
68
] ,
@@ -60,11 +74,17 @@ export const ProfClassificationWithFilters: FC<
60
74
id : DEFAULTSUBPROFID . ALL ,
61
75
name : t . components . editor . operator . sheet . sheetOperator
62
76
. ProfClassificationWithFilters . all ,
77
+ name_en :
78
+ t . components . editor . operator . sheet . sheetOperator
79
+ . ProfClassificationWithFilters . all ,
63
80
} ,
64
81
{
65
82
id : DEFAULTSUBPROFID . SELECTED ,
66
83
name : t . components . editor . operator . sheet . sheetOperator
67
84
. ProfClassificationWithFilters . selected ,
85
+ name_en :
86
+ t . components . editor . operator . sheet . sheetOperator
87
+ . ProfClassificationWithFilters . selected ,
68
88
} ,
69
89
...( formattedProfessions . find ( ( { id } ) => id === selectedProf [ 0 ] ) ?. sub ||
70
90
[ ] ) ,
@@ -95,16 +115,16 @@ export const ProfClassificationWithFilters: FC<
95
115
return (
96
116
< div className = "flex flex-row-reverse relative h-full" >
97
117
< ul className = "h-full flex flex-col w-6 sm:w-12" >
98
- { formattedProfessions . map ( ( { id , name } ) => (
118
+ { formattedProfessions . map ( ( prof ) => (
99
119
< ProfIcon
100
- key = { id }
101
- profId = { id }
102
- name = { name }
103
- selected = { selectedProf . includes ( id ) }
120
+ key = { prof . id }
121
+ profId = { prof . id }
122
+ name = { language === 'en' && prof . name_en ? prof . name_en : prof . name }
123
+ selected = { selectedProf . includes ( prof . id ) }
104
124
onProfClick = { ( ) =>
105
125
setProfFilter ( ( prev ) => ( {
106
126
...prev ,
107
- selectedProf : [ id , DEFAULTSUBPROFID . ALL ] ,
127
+ selectedProf : [ prof . id , DEFAULTSUBPROFID . ALL ] ,
108
128
} ) )
109
129
}
110
130
/>
@@ -113,22 +133,27 @@ export const ProfClassificationWithFilters: FC<
113
133
< Divider className = "mr-0" />
114
134
< div className = "h-full flex flex-col justify-center items-end absolute right-full sm:relative sm:left-0" >
115
135
< ul >
116
- { subProfs . map ( ( { id , name } ) => (
117
- < li key = { id } >
136
+ { subProfs . map ( ( subProf ) => (
137
+ < li key = { subProf . id } >
118
138
< H4
119
139
className = { clsx (
120
140
'truncate cursor-pointer my-3 opacity-50 hover:underline hover:opacity-90' ,
121
- selectedProf . includes ( id ) && '!opacity-100 underline' ,
122
- name . length > 3 && '!text-base' ,
141
+ selectedProf . includes ( subProf . id ) && '!opacity-100 underline' ,
142
+ ( language === 'en' && subProf . name_en
143
+ ? subProf . name_en
144
+ : subProf . name
145
+ ) . length > 3 && '!text-base' ,
123
146
) }
124
147
onClick = { ( ) =>
125
148
setProfFilter ( ( { selectedProf, ...rest } ) => ( {
126
- selectedProf : [ selectedProf [ 0 ] , id ] ,
149
+ selectedProf : [ selectedProf [ 0 ] , subProf . id ] ,
127
150
...rest ,
128
151
} ) )
129
152
}
130
153
>
131
- { name }
154
+ { language === 'en' && subProf . name_en
155
+ ? subProf . name_en
156
+ : subProf . name }
132
157
</ H4 >
133
158
</ li >
134
159
) ) }
0 commit comments