@@ -3,6 +3,7 @@ import { GatsbyImage, IGatsbyImageData } from "gatsby-plugin-image"
3
3
import React , { useState } from "react"
4
4
import styled from "@emotion/styled"
5
5
import { useIntl } from "react-intl"
6
+ import { Stack , Text } from "@chakra-ui/react"
6
7
7
8
// Components
8
9
import ButtonLink from "../ButtonLink"
@@ -211,9 +212,13 @@ const Layer2Onboard: React.FC<IProps> = ({
211
212
} ) => {
212
213
const intl = useIntl ( )
213
214
214
- const [ selectedCexOnboard , setSelectedCexOnboard ] = useState < CexOnboard > ( )
215
- const [ selectedExchange , setSelectedExchange ] = useState < Exchange > ( )
216
- const [ selectedL2 , setSelectedL2 ] = useState < Layer2 > ( )
215
+ const [ selectedCexOnboard , setSelectedCexOnboard ] = useState <
216
+ CexOnboard | undefined
217
+ > ( undefined )
218
+ const [ selectedExchange , setSelectedExchange ] = useState <
219
+ Exchange | undefined
220
+ > ( undefined )
221
+ const [ selectedL2 , setSelectedL2 ] = useState < Layer2 | undefined > ( undefined )
217
222
218
223
const layer2Options : Array < Layer2Option > = layer2DataCombined . map ( ( l2 ) => {
219
224
return {
@@ -243,6 +248,41 @@ const Layer2Onboard: React.FC<IProps> = ({
243
248
}
244
249
)
245
250
251
+ const formatGroupLabel = ( data ) => {
252
+ console . log ( data )
253
+ return data . label ? (
254
+ < Stack borderTop = "2px solid" m = { 0 } >
255
+ < Text mb = { 0 } mt = { 2 } textTransform = "none" color = "body" >
256
+ { data . label }
257
+ </ Text >
258
+ </ Stack >
259
+ ) : (
260
+ < > </ >
261
+ )
262
+ }
263
+
264
+ const selectExchangeOnboard = ( option : ExchangeOption | CexOnboardOption ) => {
265
+ if ( Object . hasOwn ( option , "cex" ) ) {
266
+ trackCustomEvent ( {
267
+ eventCategory : `Selected cex to onboard` ,
268
+ eventAction : `Clicked` ,
269
+ eventName : `${ option . cex . name } selected` ,
270
+ eventValue : `${ option . cex . name } ` ,
271
+ } )
272
+ setSelectedExchange ( option . cex )
273
+ setSelectedCexOnboard ( undefined )
274
+ } else {
275
+ trackCustomEvent ( {
276
+ eventCategory : `Selected cexOnboard to onboard` ,
277
+ eventAction : `Clicked` ,
278
+ eventName : `${ option . cexOnboard . name } selected` ,
279
+ eventValue : `${ option . cexOnboard . name } ` ,
280
+ } )
281
+ setSelectedCexOnboard ( option . cexOnboard )
282
+ setSelectedExchange ( undefined )
283
+ }
284
+ }
285
+
246
286
return (
247
287
< Content >
248
288
< Description >
@@ -325,39 +365,31 @@ const Layer2Onboard: React.FC<IProps> = ({
325
365
</ RightDescription >
326
366
< RightSelect >
327
367
< StyledSelect
328
- // TODO: style this label
329
368
className = "react-select-container"
330
369
classNamePrefix = "react-select"
331
370
options = { [
332
371
{
333
372
options : [ ...cexSupportOptions ] ,
334
373
} ,
335
374
{
336
- // TODO: Add cex onboard label here
337
- label : "Test ",
375
+ label :
376
+ "Don't see you exchange? Use dapps to bridge directly from exchanges to layer 2. ",
338
377
options : [ ...cexOnboardOptions ] ,
339
378
} ,
340
379
] }
341
- onChange = { ( selectedOption : ExchangeOption ) => {
342
- trackCustomEvent ( {
343
- eventCategory : `Selected cex to onboard` ,
344
- eventAction : `Clicked` ,
345
- eventName : `${ selectedOption . cex . name } selected` ,
346
- eventValue : `${ selectedOption . cex . name } ` ,
347
- } )
348
- // TODO: refactor this to use both selected exchange and selected cex onboard
349
- setSelectedExchange ( selectedOption . cex )
380
+ onChange = { ( selectedOption : ExchangeOption | CexOnboardOption ) => {
381
+ selectExchangeOnboard ( selectedOption )
350
382
} }
351
383
placeholder = { translateMessageId (
352
384
"layer-2-onboard-exchange-input-placeholder" ,
353
385
intl
354
386
) }
387
+ formatGroupLabel = { formatGroupLabel }
355
388
/>
356
389
</ RightSelect >
357
390
< EthLogo >
358
391
< Image image = { ethIcon } objectFit = "contain" alt = { ethIconAlt } />
359
392
</ EthLogo >
360
- { /* TODO: Add markdown for rendering cex onboard content */ }
361
393
{ selectedExchange && (
362
394
< RightSelected >
363
395
< SelectedContainer >
@@ -391,6 +423,21 @@ const Layer2Onboard: React.FC<IProps> = ({
391
423
</ SelectedContainer >
392
424
</ RightSelected >
393
425
) }
426
+ { selectedCexOnboard && (
427
+ < RightSelected >
428
+ < SelectedContainer >
429
+ < H3 > Supported exchanges</ H3 >
430
+ < p > { selectedCexOnboard . cex_support . join ( ", " ) } </ p >
431
+ < H3 > Supported layer 2s</ H3 >
432
+ < p > { selectedCexOnboard . network_support . join ( ", " ) } </ p >
433
+ < ButtonLink to = { selectedCexOnboard . url } >
434
+ { `${ translateMessageId ( "layer-2-go-to" , intl ) } ${
435
+ selectedCexOnboard . name
436
+ } `}
437
+ </ ButtonLink >
438
+ </ SelectedContainer >
439
+ </ RightSelected >
440
+ ) }
394
441
</ Grid >
395
442
</ Content >
396
443
)
0 commit comments