1
- import React from "react "
1
+ import { useTranslation } from "next-i18next "
2
2
import {
3
3
Box ,
4
- BoxProps ,
4
+ type BoxProps ,
5
5
Center ,
6
- CenterProps ,
6
+ type CenterProps ,
7
7
Divider ,
8
8
Flex ,
9
- FlexProps ,
9
+ type FlexProps ,
10
10
Heading ,
11
- HeadingProps ,
12
- TextProps ,
11
+ type HeadingProps ,
12
+ type TextProps ,
13
13
useToken ,
14
14
} from "@chakra-ui/react"
15
15
16
- import { TranslationKey } from "../utils/translations "
16
+ import type { ChildOnlyProp , TranslationKey } from "@/lib/types "
17
17
18
- import { ButtonLink } from "./Buttons"
19
- import Text from "./OldText"
20
- import Translation from "./Translation"
18
+ import { ButtonLink , type ButtonLinkProps } from "@/components/Buttons"
19
+ import Text from "@/components/OldText"
21
20
22
- const CardRow = ( { children } ) => (
23
- < Flex justifyContent = "space-between" my = { 16 } mx = { 4 } flexWrap = "wrap" >
21
+ const CardRow = ( { children } : ChildOnlyProp ) => (
22
+ < Flex justifyContent = "space-between" my = "16" mx = "4" flexWrap = "wrap" >
24
23
{ children }
25
24
</ Flex >
26
25
)
27
26
28
- const SubmitBugBountyButton = ( { children, ...props } ) => (
29
- < ButtonLink m = { 4 } to = "https://forms.gle/Gnh4gzGh66Yc3V7G8" { ...props } >
27
+ const SubmitBugBountyButton = ( { children, ...props } : ButtonLinkProps ) => (
28
+ < ButtonLink m = "4" to = "https://forms.gle/Gnh4gzGh66Yc3V7G8" { ...props } >
30
29
{ children }
31
30
</ ButtonLink >
32
31
)
@@ -45,7 +44,7 @@ const Card = ({ children, ...props }: FlexProps) => {
45
44
boxShadow = { tableBoxShadow }
46
45
border = "1px solid"
47
46
borderColor = "border"
48
- m = { 4 }
47
+ m = "4"
49
48
_hover = { {
50
49
borderRadius : "base" ,
51
50
boxShadow : "tableBoxHover" ,
@@ -97,8 +96,8 @@ const Label = ({ children, variant = "medium", ...props }: LabelProps) => {
97
96
borderBottom = "1px solid"
98
97
borderColor = "border"
99
98
fontSize = "sm"
100
- px = { 0 }
101
- py = { 1 }
99
+ px = "0"
100
+ py = "1"
102
101
textTransform = "uppercase"
103
102
{ ...variantStyleProps }
104
103
{ ...props }
@@ -108,57 +107,49 @@ const Label = ({ children, variant = "medium", ...props }: LabelProps) => {
108
107
)
109
108
}
110
109
111
- const H2 = ( { children, ...props } : HeadingProps ) => {
112
- return (
113
- < Heading
114
- fontSize = "2xl"
115
- fontStyle = "normal"
116
- fontWeight = "bold"
117
- lineHeight = "22px"
118
- letterSpacing = { 0 }
119
- p = { 4 }
120
- textAlign = "start"
121
- mb = { - 2 }
122
- mt = { 2 }
123
- { ...props }
124
- >
125
- { children }
126
- </ Heading >
127
- )
128
- }
110
+ const H2 = ( { children, ...props } : HeadingProps ) => (
111
+ < Heading
112
+ fontSize = "2xl"
113
+ fontStyle = "normal"
114
+ fontWeight = "bold"
115
+ lineHeight = "22px"
116
+ letterSpacing = "normal"
117
+ p = "4"
118
+ textAlign = "start"
119
+ mb = "-2"
120
+ mt = "2"
121
+ { ...props }
122
+ >
123
+ { children }
124
+ </ Heading >
125
+ )
129
126
130
- const Description = ( { children, ...props } : TextProps ) => {
131
- return (
132
- < Text as = "p" fontSize = "xl" px = { 4 } py = { 0 } opacity = "0.6" { ...props } >
133
- { children }
134
- </ Text >
135
- )
136
- }
127
+ const Description = ( { children, ...props } : TextProps ) => (
128
+ < Text as = "p" fontSize = "xl" px = "4" py = "0" opacity = "0.6" { ...props } >
129
+ { children }
130
+ </ Text >
131
+ )
137
132
138
- const SubHeader = ( { children, ...props } : TextProps ) => {
139
- return (
140
- < Text
141
- as = "p"
142
- textTransform = "uppercase"
143
- fontSize = "sm"
144
- ms = { 4 }
145
- mt = { 4 }
146
- mb = { 2 }
147
- opacity = "0.6"
148
- { ...props }
149
- >
150
- { children }
151
- </ Text >
152
- )
153
- }
133
+ const SubHeader = ( { children, ...props } : TextProps ) => (
134
+ < Text
135
+ as = "p"
136
+ textTransform = "uppercase"
137
+ fontSize = "sm"
138
+ ms = "4"
139
+ mt = "4"
140
+ mb = "2"
141
+ opacity = "0.6"
142
+ { ...props }
143
+ >
144
+ { children }
145
+ </ Text >
146
+ )
154
147
155
- const TextBox = ( { children, ...props } : BoxProps ) => {
156
- return (
157
- < Box m = { 4 } mt = { 2 } { ...props } >
158
- { children }
159
- </ Box >
160
- )
161
- }
148
+ const TextBox = ( { children, ...props } : BoxProps ) => (
149
+ < Box m = "4" mt = "2" { ...props } >
150
+ { children }
151
+ </ Box >
152
+ )
162
153
163
154
export interface BugBountyCardInfo {
164
155
lowLabelTranslationId ?: TranslationKey
@@ -169,13 +160,13 @@ export interface BugBountyCardInfo {
169
160
descriptionTranslationId : TranslationKey
170
161
subDescriptionTranslationId : TranslationKey
171
162
subHeader1TranslationId : TranslationKey
172
- severityList : Array < TranslationKey >
163
+ severityList : TranslationKey [ ]
173
164
subHeader2TranslationId : TranslationKey
174
165
textTranslationId : TranslationKey
175
166
styledButtonTranslationId : TranslationKey
176
167
}
177
168
178
- const bugBountyCardsInfo : Array < BugBountyCardInfo > = [
169
+ const bugBountyCardsInfo : BugBountyCardInfo [ ] = [
179
170
{
180
171
lowLabelTranslationId : "page-upgrades-bug-bounty-card-label-2" ,
181
172
h2TranslationId : "page-upgrades-bug-bounty-card-low" ,
@@ -232,67 +223,51 @@ const bugBountyCardsInfo: Array<BugBountyCardInfo> = [
232
223
} ,
233
224
]
234
225
235
- export interface IProps { }
236
-
237
- const BugBountyCards : React . FC < IProps > = ( ) => (
238
- < CardRow >
239
- { bugBountyCardsInfo . map ( ( card , idx ) => (
240
- < Card key = { `bug-bounty-card-${ idx } ` } >
241
- { card . lowLabelTranslationId && (
242
- < Label variant = "low" >
243
- < Translation id = { card . lowLabelTranslationId } />
244
- </ Label >
245
- ) }
246
- { card . mediumLabelTranslationId && (
247
- < Label variant = "medium" >
248
- < Translation id = { card . mediumLabelTranslationId } />
249
- </ Label >
250
- ) }
251
- { card . highLabelTranslationId && (
252
- < Label variant = "high" >
253
- < Translation id = { card . highLabelTranslationId } />
254
- </ Label >
255
- ) }
256
- { card . criticalLabelTranslationId && (
257
- < Label variant = "critical" >
258
- < Translation id = { card . criticalLabelTranslationId } />
259
- </ Label >
260
- ) }
261
- < H2 >
262
- < Translation id = { card . h2TranslationId } />
263
- </ H2 >
264
- < Description >
265
- < Translation id = { card . descriptionTranslationId } />
266
- </ Description >
267
- < SubHeader >
268
- < Translation id = { card . subDescriptionTranslationId } />
269
- </ SubHeader >
270
- < Divider opacity = "1" />
271
- < SubHeader >
272
- < Translation id = { card . subHeader1TranslationId } />
273
- </ SubHeader >
274
- < TextBox >
275
- < ul >
276
- { card . severityList . map ( ( listItemId ) => (
277
- < li key = { `${ listItemId } ` } >
278
- < Translation id = { listItemId } />
279
- </ li >
280
- ) ) }
281
- </ ul >
282
- </ TextBox >
283
- < Divider opacity = "1" />
284
- < SubHeader >
285
- < Translation id = { card . subHeader2TranslationId } />
286
- </ SubHeader >
287
- < TextBox >
288
- < Translation id = { card . textTranslationId } />
289
- </ TextBox >
290
- < SubmitBugBountyButton >
291
- < Translation id = { card . styledButtonTranslationId } />
292
- </ SubmitBugBountyButton >
293
- </ Card >
294
- ) ) }
295
- </ CardRow >
296
- )
226
+ const BugBountyCards = ( ) => {
227
+ const { t } = useTranslation ( "page-bug-bounty" )
228
+ return (
229
+ < CardRow >
230
+ { bugBountyCardsInfo . map ( ( card , idx ) => (
231
+ < Card key = { `bug-bounty-card-${ idx } ` } >
232
+ { card . lowLabelTranslationId && (
233
+ < Label variant = "low" > { t ( card . lowLabelTranslationId ) } </ Label >
234
+ ) }
235
+ { card . mediumLabelTranslationId && (
236
+ < Label variant = "medium" > { t ( card . mediumLabelTranslationId ) } </ Label >
237
+ ) }
238
+ { card . highLabelTranslationId && (
239
+ < Label variant = "high" > { t ( card . highLabelTranslationId ) } </ Label >
240
+ ) }
241
+ { card . criticalLabelTranslationId && (
242
+ < Label variant = "critical" >
243
+ { t ( card . criticalLabelTranslationId ) }
244
+ </ Label >
245
+ ) }
246
+ < H2 > { t ( card . h2TranslationId ) } </ H2 >
247
+ < Description > { t ( card . descriptionTranslationId ) } </ Description >
248
+ < SubHeader > { t ( card . subDescriptionTranslationId ) } </ SubHeader >
249
+ < Divider opacity = "1" />
250
+ < SubHeader > { t ( card . subHeader1TranslationId ) } </ SubHeader >
251
+ < TextBox >
252
+ < ul >
253
+ { card . severityList . map ( ( listItemId ) => (
254
+ < li key = { listItemId } >
255
+ { t ( listItemId ) }
256
+ { /* <Translation id={listItemId} /> */ }
257
+ </ li >
258
+ ) ) }
259
+ </ ul >
260
+ </ TextBox >
261
+ < Divider opacity = "1" />
262
+ < SubHeader > { t ( card . subHeader2TranslationId ) } </ SubHeader >
263
+ < TextBox > { t ( card . textTranslationId ) } </ TextBox >
264
+ < SubmitBugBountyButton >
265
+ { t ( card . styledButtonTranslationId ) }
266
+ </ SubmitBugBountyButton >
267
+ </ Card >
268
+ ) ) }
269
+ </ CardRow >
270
+ )
271
+ }
297
272
298
273
export default BugBountyCards
0 commit comments