Skip to content

Commit e3bdae9

Browse files
authored
Merge pull request #249 from MobulaFi/dev
fix: crash on symbol undefined & clearing empty data
2 parents 1fb33f0 + 85c8b85 commit e3bdae9

File tree

4 files changed

+29
-11
lines changed

4 files changed

+29
-11
lines changed

src/features/data/chains/components/box-left/index.tsx

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { Spinner } from "components/spinner";
21
import dynamic from "next/dynamic";
32
import React from "react";
3+
import { BsDatabaseX } from "react-icons/bs";
4+
import { SmallFont } from "../../../../../components/fonts";
45
import { useChains } from "../../context-manager";
56
import { getChainName } from "../../utils";
67
import { BoxTitle } from "../box-title";
@@ -12,9 +13,13 @@ const EChart = dynamic(() => import("../../../../../lib/echart/line"), {
1213
export const LeftBox = () => {
1314
const { chain, pairs } = useChains();
1415
const chainName = getChainName(pairs?.[0]?.pair?.blockchain);
16+
const isValidData =
17+
chain?.volume_history?.length &&
18+
chain?.volume_history?.[chain?.volume_history?.length - 1 || 0]?.[1];
19+
1520
const titleInfo = {
1621
value: chain?.volume_history?.[chain?.volume_history?.length - 1]?.[1],
17-
dollar: true,
22+
dollar: isValidData ? true : false,
1823
percentage: chain?.volume_change_24h,
1924
title: `${chainName} DeFi Volume`,
2025
};
@@ -25,7 +30,7 @@ export const LeftBox = () => {
2530
min-w-[407px] md:min-w-full w-[31.5%] mr-2.5 lg:w-full transition duration-500 md:overflow-visible py-2.5"
2631
>
2732
<BoxTitle data={titleInfo} />
28-
{chain?.volume_history?.length > 0 ? (
33+
{isValidData > 0 ? (
2934
<div className="w-[95%] mx-auto h-[210px] lg:h-[190px] -mt-[40px]">
3035
<EChart
3136
data={chain?.volume_history || []}
@@ -36,8 +41,9 @@ export const LeftBox = () => {
3641
/>
3742
</div>
3843
) : (
39-
<div className="h-[200px] w-full flex items-center justify-center">
40-
<Spinner extraCss="w-[30px] h-[30px]" />
44+
<div className="h-[200px] w-full flex items-center flex-col justify-center">
45+
<BsDatabaseX className="text-light-font-100 dark:text-dark-font-100 text-2xl mb-2.5" />
46+
<SmallFont>No data available</SmallFont>
4147
</div>
4248
)}
4349
</div>

src/features/data/chains/components/box-middle/index.tsx

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { Spinner } from "components/spinner";
21
import dynamic from "next/dynamic";
32
import React from "react";
3+
import { BsDatabaseX } from "react-icons/bs";
4+
import { SmallFont } from "../../../../../components/fonts";
45
import { useChains } from "../../context-manager";
56
import { getChainName } from "../../utils";
67
import { BoxTitle } from "../box-title";
@@ -18,14 +19,18 @@ export const MiddleBox = () => {
1819
percentage: chain?.tokens_change_total,
1920
title: `${chainName} Active Tokens`,
2021
};
22+
const isValidData =
23+
chain?.tokens_history?.length &&
24+
chain?.tokens_history?.[chain?.tokens_history?.length - 1 || 0]?.[1];
25+
2126
return (
2227
<div
2328
className={`flex flex-col h-[200px] lg:h-[175px] rounded-xl bg-light-bg-secondary dark:bg-dark-bg-secondary border
2429
border-light-border-primary dark:border-dark-border-primary py-2.5 relative
2530
min-w-[407px] md:min-w-full w-[31.5%] lg:w-full transition duration-500 mx-2.5 md:mx-0`}
2631
>
2732
<BoxTitle data={titleInfo} />
28-
{chain?.tokens_history?.length > 0 ? (
33+
{isValidData ? (
2934
<div className="w-[95%] mx-auto h-[210px] -mt-[40px]">
3035
<EChart
3136
data={chain?.tokens_history || []}
@@ -37,8 +42,9 @@ export const MiddleBox = () => {
3742
/>
3843
</div>
3944
) : (
40-
<div className="h-[200px] w-full flex items-center justify-center">
41-
<Spinner extraCss="w-[30px] h-[30px]" />
45+
<div className="h-[200px] w-full flex items-center flex-col justify-center">
46+
<BsDatabaseX className="text-light-font-100 dark:text-dark-font-100 text-2xl mb-2.5" />
47+
<SmallFont>No data available</SmallFont>
4248
</div>
4349
)}
4450
</div>

src/features/data/chains/components/box-right/index.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import dynamic from "next/dynamic";
2+
import React from "react";
23
import { BsDatabaseX } from "react-icons/bs";
34
import { SmallFont } from "../../../../../components/fonts";
45
import { useChains } from "../../context-manager";
@@ -29,7 +30,9 @@ export const RightBox = () => {
2930
>
3031
<BoxTitle data={titleInfo} />
3132
{chain?.liquidity_history?.length > 0 &&
32-
chain?.liquidity_history?.[0]?.[1] > 0 ? (
33+
chain?.liquidity_history?.[
34+
chain?.liquidity_history?.length - 1 || 0
35+
]?.[1] > 0 ? (
3336
<div className="w-[95%] mx-auto h-[210px] -mt-[40px]">
3437
<EChart
3538
data={chain?.liquidity_history || []}

src/features/user/portfolio/components/category/activity/index.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,10 @@ export const Activity = ({
158158
// ETH is ETH vs Stable
159159
// Other is Other vs Stable or ETH
160160
const ethSymbols = useMemo(
161-
() => Object.values(blockchainsIdContent).map((entry) => entry.eth.symbol),
161+
() =>
162+
Object.values(blockchainsIdContent)
163+
.filter((entry) => entry.eth)
164+
.map((entry) => entry.eth?.symbol),
162165
[]
163166
);
164167

0 commit comments

Comments
 (0)