Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
fix(app): fix mainnet accounts browsing
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcnk committed Nov 15, 2023
1 parent a6b76f9 commit 945d9b2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 21 deletions.
7 changes: 6 additions & 1 deletion src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ export const generateMetadata = async (): Promise<Metadata> => {
const HomePage = async () => {
const t = await getT()
const locale = getLocale()
const coinData = await fetchCoinData({ locale })
let coinData
try {
coinData = await fetchCoinData({ locale })
} catch {
coinData = { prices: [], marketCaps: [] }
}
return (
<main className="flex-1 flex flex-col">
<div className="flex flex-col gap-4 md:gap-8">
Expand Down
40 changes: 21 additions & 19 deletions src/components/dashboard/quick-stats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ export const QuickStats = async ({
}: QuickStatsProps) => {
const t = await getT()
const priceDelta =
prices[6].price &&
Math.abs(Number(prices[6].price) - Number(prices[5].price)) /
Number(prices[6].price)
prices?.[6]?.price &&
Math.abs(Number(prices?.[6]?.price) - Number(prices?.[5]?.price)) /
Number(prices?.[6]?.price)
const capDelta =
marketCaps[6].cap &&
Math.abs(Number(marketCaps[6].cap) - Number(marketCaps[5].cap)) /
Number(marketCaps[6].cap)
marketCaps?.[6]?.cap &&
Math.abs(Number(marketCaps?.[6]?.cap) - Number(marketCaps?.[5]?.cap)) /
Number(marketCaps?.[6]?.cap)
return (
<div className="flex gap-4 md:gap-8 md:flex-row flex-col">
<Card className="flex flex-col flex-1 gap-4 p-4">
Expand All @@ -38,16 +38,17 @@ export const QuickStats = async ({
{t('dashboard.minaPrice')}
</h3>
<p className="text-xl font-semibold">
{formatCurrency({
value: Number(prices[6].price),
locale,
currency: 'USD'
})}
{prices?.[6]?.price &&
formatCurrency({
value: Number(prices?.[6]?.price),
locale,
currency: 'USD'
})}
</p>
</div>
<Badge variant="outline">
{ONE_DAY_CHANGE}
{prices[6].price > prices[5].price ? '+' : '-'}
{prices?.[6]?.price > prices?.[5]?.price ? '+' : '-'}
{toPercent(priceDelta || 0)}
</Badge>
</div>
Expand All @@ -60,17 +61,18 @@ export const QuickStats = async ({
{t('dashboard.minaMarketCap')}
</h3>
<p className="text-xl font-semibold">
{formatCurrency({
value: Number(marketCaps[6].cap),
locale,
compact: true,
currency: 'USD'
})}
{prices?.[6]?.price &&
formatCurrency({
value: Number(marketCaps?.[6]?.cap),
locale,
compact: true,
currency: 'USD'
})}
</p>
</div>
<Badge variant="outline">
{ONE_DAY_CHANGE}
{marketCaps[6].cap > marketCaps[5].cap ? '+' : '-'}
{marketCaps?.[6]?.cap > marketCaps?.[5]?.cap ? '+' : '-'}
{toPercent(capDelta || 0)}
</Badge>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/data/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const GqlUrl = {
}

export const ProxyUrl = {
[Network.MAINNET]: appUrl(`/proxy`),
[Network.MAINNET]: appUrl(`/proxy/graphql`),
[Network.DEVNET]: appUrl(`/devnet/proxy`),
[Network.BERKELEY]: appUrl(`/berkeley/proxy`),
[Network.TESTWORLD]: appUrl(`/testworld/proxy`)
Expand Down

0 comments on commit 945d9b2

Please sign in to comment.