|
1 | 1 | import { Avatar, Box, Typography } from "@mui/material"; |
| 2 | +import React from "react"; |
| 3 | + |
2 | 4 | import { |
3 | 5 | EmptyValueTag, |
4 | 6 | getValuePrecisionThousand, |
| 7 | + myLog, |
5 | 8 | SoursURL, |
6 | 9 | } from "@loopring-web/common-resources"; |
7 | 10 | import { CoinSource, useSettings } from "../../stores"; |
8 | 11 | import { AvatarCoin } from "../basic-lib"; |
9 | 12 | import { WithTranslation, withTranslation } from "react-i18next"; |
| 13 | +import styled from "@emotion/styled"; |
10 | 14 |
|
11 | 15 | export const AmmPairDetail = ({ |
12 | 16 | coinA, |
@@ -283,3 +287,204 @@ export const AmmAPRDetail = withTranslation("tables")( |
283 | 287 | ); |
284 | 288 | } |
285 | 289 | ) as (props: { self?: number; event?: number; fee?: number }) => JSX.Element; |
| 290 | + |
| 291 | +const TypographyStyle = styled(Typography)` |
| 292 | + .rewardItem:not(:last-child) { |
| 293 | + &:after { |
| 294 | + display: inline-flex; |
| 295 | + content: "+"; |
| 296 | + padding: 0 ${({ theme }) => theme.unit + "px"}; |
| 297 | + } |
| 298 | + } |
| 299 | +` as typeof Typography; |
| 300 | +type AmmPairDetailProps = { |
| 301 | + feeA: number | undefined; |
| 302 | + feeB: number | undefined; |
| 303 | + rewards: Array<{ tokenSymbol: string; amount: number | undefined }>; |
| 304 | + extraRewards: Array<{ tokenSymbol: string; amount: number | undefined }>; |
| 305 | + tokenMap: { [key: string]: any }; |
| 306 | + coinA: string; |
| 307 | + coinB: string; |
| 308 | +}; |
| 309 | +export const AmmRewardsDetail = withTranslation("tables")( |
| 310 | + ({ |
| 311 | + feeA, |
| 312 | + feeB, |
| 313 | + rewards, |
| 314 | + extraRewards, |
| 315 | + tokenMap, |
| 316 | + coinA, |
| 317 | + coinB, |
| 318 | + t, |
| 319 | + }: AmmPairDetailProps & WithTranslation) => { |
| 320 | + // labelRewardFee |
| 321 | + // labelRewardReward |
| 322 | + // labelRewardExtra |
| 323 | + myLog("coinB", coinB); |
| 324 | + return ( |
| 325 | + <Box padding={1.5} paddingLeft={1}> |
| 326 | + <Typography |
| 327 | + component={"span"} |
| 328 | + display={"flex"} |
| 329 | + flexDirection={"row"} |
| 330 | + justifyContent={"space-between"} |
| 331 | + alignItems={"center"} |
| 332 | + style={{ textTransform: "capitalize" }} |
| 333 | + color={"textPrimary"} |
| 334 | + > |
| 335 | + <Typography |
| 336 | + component={"span"} |
| 337 | + color={"var(--color-text-primary)"} |
| 338 | + variant={"body2"} |
| 339 | + marginLeft={1 / 2} |
| 340 | + height={20} |
| 341 | + lineHeight={"20px"} |
| 342 | + > |
| 343 | + {t("labelRewardFee")} |
| 344 | + </Typography> |
| 345 | + |
| 346 | + <TypographyStyle |
| 347 | + component={"span"} |
| 348 | + color={"var(--color-text-primary)"} |
| 349 | + variant={"body2"} |
| 350 | + height={20} |
| 351 | + marginLeft={10} |
| 352 | + lineHeight={"20px"} |
| 353 | + > |
| 354 | + <Typography component={"span"} className={"rewardItem"}> |
| 355 | + {(feeA |
| 356 | + ? getValuePrecisionThousand( |
| 357 | + feeA, |
| 358 | + tokenMap[coinA].precision, |
| 359 | + tokenMap[coinA].precision, |
| 360 | + tokenMap[coinA].precision, |
| 361 | + true |
| 362 | + ) |
| 363 | + : EmptyValueTag) + ` ${coinA}`} |
| 364 | + </Typography> |
| 365 | + <Typography component={"span"} className={"rewardItem"}> |
| 366 | + {(feeB |
| 367 | + ? getValuePrecisionThousand( |
| 368 | + feeB, |
| 369 | + tokenMap[coinB].precision, |
| 370 | + tokenMap[coinB].precision, |
| 371 | + tokenMap[coinB].precision, |
| 372 | + true |
| 373 | + ) |
| 374 | + : EmptyValueTag) + ` ${coinB}`} |
| 375 | + </Typography> |
| 376 | + </TypographyStyle> |
| 377 | + </Typography> |
| 378 | + <Typography |
| 379 | + component={"span"} |
| 380 | + display={"flex"} |
| 381 | + flexDirection={"row"} |
| 382 | + justifyContent={"space-between"} |
| 383 | + alignItems={"center"} |
| 384 | + style={{ textTransform: "capitalize" }} |
| 385 | + color={"textPrimary"} |
| 386 | + > |
| 387 | + <Typography |
| 388 | + component={"span"} |
| 389 | + color={"var(--color-text-primary)"} |
| 390 | + variant={"body2"} |
| 391 | + marginLeft={1 / 2} |
| 392 | + height={20} |
| 393 | + lineHeight={"20px"} |
| 394 | + > |
| 395 | + {t("labelRewardReward")} |
| 396 | + </Typography> |
| 397 | + <TypographyStyle |
| 398 | + component={"span"} |
| 399 | + color={"var(--color-text-primary)"} |
| 400 | + variant={"body2"} |
| 401 | + height={20} |
| 402 | + marginLeft={10} |
| 403 | + lineHeight={"20px"} |
| 404 | + > |
| 405 | + {rewards.length ? ( |
| 406 | + <> |
| 407 | + {rewards.map((item: any, index: number) => { |
| 408 | + return ( |
| 409 | + <React.Fragment key={item.id + index}> |
| 410 | + {item?.amount ? ( |
| 411 | + <Typography component={"span"} className={"rewardItem"}> |
| 412 | + {getValuePrecisionThousand( |
| 413 | + item.amount, |
| 414 | + tokenMap[item.symbol].precision, |
| 415 | + tokenMap[item.symbol].precision, |
| 416 | + tokenMap[item.symbol].precision, |
| 417 | + true |
| 418 | + )` ${coinA}`}{" "} |
| 419 | + </Typography> |
| 420 | + ) : ( |
| 421 | + <></> |
| 422 | + )} |
| 423 | + </React.Fragment> |
| 424 | + ); |
| 425 | + })} |
| 426 | + </> |
| 427 | + ) : ( |
| 428 | + EmptyValueTag |
| 429 | + )} |
| 430 | + </TypographyStyle> |
| 431 | + </Typography> |
| 432 | + <Typography |
| 433 | + component={"span"} |
| 434 | + display={"flex"} |
| 435 | + flexDirection={"row"} |
| 436 | + justifyContent={"space-between"} |
| 437 | + alignItems={"center"} |
| 438 | + style={{ textTransform: "capitalize" }} |
| 439 | + color={"textPrimary"} |
| 440 | + > |
| 441 | + <Typography |
| 442 | + component={"span"} |
| 443 | + color={"var(--color-text-primary)"} |
| 444 | + variant={"body2"} |
| 445 | + marginLeft={1 / 2} |
| 446 | + height={20} |
| 447 | + lineHeight={"20px"} |
| 448 | + > |
| 449 | + {t("labelRewardExtra")} |
| 450 | + </Typography> |
| 451 | + |
| 452 | + <TypographyStyle |
| 453 | + component={"span"} |
| 454 | + color={"var(--color-text-primary)"} |
| 455 | + variant={"body2"} |
| 456 | + height={20} |
| 457 | + marginLeft={10} |
| 458 | + lineHeight={"20px"} |
| 459 | + > |
| 460 | + {extraRewards.length ? ( |
| 461 | + <> |
| 462 | + {extraRewards.map((item: any, index: number) => { |
| 463 | + return ( |
| 464 | + <React.Fragment key={item.id + index}> |
| 465 | + {item?.amount ? ( |
| 466 | + <Typography component={"span"} className={"rewardItem"}> |
| 467 | + {getValuePrecisionThousand( |
| 468 | + item.amount, |
| 469 | + tokenMap[item.symbol].precision, |
| 470 | + tokenMap[item.symbol].precision, |
| 471 | + tokenMap[item.symbol].precision, |
| 472 | + true |
| 473 | + )` ${coinA}`}{" "} |
| 474 | + </Typography> |
| 475 | + ) : ( |
| 476 | + <></> |
| 477 | + )} |
| 478 | + </React.Fragment> |
| 479 | + ); |
| 480 | + })} |
| 481 | + </> |
| 482 | + ) : ( |
| 483 | + EmptyValueTag |
| 484 | + )} |
| 485 | + </TypographyStyle> |
| 486 | + </Typography> |
| 487 | + </Box> |
| 488 | + ); |
| 489 | + } |
| 490 | +) as (props: AmmPairDetailProps) => JSX.Element; |
0 commit comments