Skip to content

Commit 478ff96

Browse files
committed
fix: empty states
1 parent becd948 commit 478ff96

File tree

6 files changed

+19
-19
lines changed

6 files changed

+19
-19
lines changed

apps/dashboard/src/@/api/universal-bridge/developer.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,5 @@ export async function getPayments(props: {
230230
}
231231

232232
const json = await res.json();
233-
console.log("json", json);
234233
return json as PaymentsResponse;
235234
}

apps/dashboard/src/components/pay/PayAnalytics/components/PaymentsSuccessRate.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function PaymentsSuccessRate(props: {
2121
}) {
2222
const [type, setType] = useState<PayVolumeType>("all");
2323
const isEmpty = useMemo(() => {
24-
return props.data.length === 0;
24+
return props.data.length === 0 || props.data.every((x) => x.count === 0);
2525
}, [props.data]);
2626
const graphData = useMemo(() => {
2727
let succeeded = 0;
@@ -77,9 +77,9 @@ export function PaymentsSuccessRate(props: {
7777
</Select>
7878
</div>
7979

80-
<div className="flex flex-1 flex-col justify-center">
80+
<div className="relative flex flex-1 flex-col justify-center">
8181
<div className="h-10" />
82-
{isEmpty ? (
82+
{isEmpty || graphData.total === 0 ? (
8383
<EmptyBar />
8484
) : (
8585
<SkeletonContainer

apps/dashboard/src/components/pay/PayAnalytics/components/Payouts.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,11 @@ export function Payouts(props: {
7373
<div className="mb-5 flex items-center gap-3">
7474
<SkeletonContainer
7575
loadedData={
76-
props.data && props.data.length > 0
77-
? toUSD(totalPayoutsUSD)
78-
: undefined
76+
!props.data
77+
? undefined
78+
: props.data.length > 0
79+
? toUSD(totalPayoutsUSD)
80+
: "NA"
7981
}
8082
skeletonData="$20"
8183
render={(value) => {
@@ -101,7 +103,7 @@ export function Payouts(props: {
101103

102104
<div className="relative flex w-full justify-center">
103105
<ResponsiveContainer width="100%" height={chartHeight}>
104-
<BarChart data={graphData || emptyGraphData}>
106+
<BarChart data={isEmpty ? emptyGraphData : graphData}>
105107
<Tooltip
106108
content={(x) => {
107109
const payload = x.payload?.[0]?.payload as

apps/dashboard/src/components/pay/PayAnalytics/components/TotalPayVolume.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
import { useId, useMemo, useState } from "react";
1010
import { Area, AreaChart, ResponsiveContainer, Tooltip, XAxis } from "recharts";
1111
import type { UniversalBridgeStats } from "types/analytics";
12-
import { CardHeading, chartHeight } from "./common";
12+
import { CardHeading, NoDataOverlay, chartHeight } from "./common";
1313

1414
type GraphData = {
1515
date: string;
@@ -127,7 +127,7 @@ export function TotalPayVolume(props: {
127127

128128
<div className="relative flex w-full flex-1 justify-center">
129129
<ResponsiveContainer width="100%" height={chartHeight}>
130-
<AreaChart data={graphData || emptyGraphData}>
130+
<AreaChart data={isEmpty ? emptyGraphData : graphData}>
131131
<defs>
132132
<linearGradient id={uniqueId} x1="0" y1="0" x2="0" y2="1">
133133
<stop offset="5%" stopColor={chartColor} stopOpacity={0.4} />
@@ -177,6 +177,7 @@ export function TotalPayVolume(props: {
177177
)}
178178
</AreaChart>
179179
</ResponsiveContainer>
180+
{isEmpty && <NoDataOverlay />}
180181
</div>
181182
</div>
182183
);

apps/dashboard/src/components/pay/PayAnalytics/components/TotalVolumePieChart.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function TotalVolumePieChart(props: {
1717
}) {
1818
const data = props.data;
1919
const isEmpty =
20-
!data || data.length === 0 || data.every((x) => x.amountUsdCents === 0);
20+
data.length === 0 || data.every((x) => x.amountUsdCents === 0);
2121
const skeletonData: VolData[] = [
2222
{
2323
name: "Crypto",
@@ -87,9 +87,11 @@ export function TotalVolumePieChart(props: {
8787

8888
<SkeletonContainer
8989
loadedData={
90-
data && data.length > 0
91-
? toUSD(cryptoTotalUSD + fiatTotalUSD)
92-
: undefined
90+
!data
91+
? undefined
92+
: data.length > 0
93+
? toUSD(cryptoTotalUSD + fiatTotalUSD)
94+
: "NA"
9395
}
9496
skeletonData="$100"
9597
render={(totalAmount) => {
@@ -117,9 +119,7 @@ export function TotalVolumePieChart(props: {
117119
color={v.color}
118120
label={v.name}
119121
amount={
120-
data && data.length > 0
121-
? toUSD(isEmpty ? 0 : v.amount)
122-
: undefined
122+
!data ? undefined : data.length > 0 ? toUSD(v.amount) : "NA"
123123
}
124124
/>
125125
))}

apps/dashboard/src/components/pay/PayAnalytics/components/common.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import { Badge } from "@/components/ui/badge";
22
import { ToolTipLabel } from "@/components/ui/tooltip";
33
import { ArrowDownIcon, ArrowUpIcon } from "lucide-react";
44

5-
import {} from "@/components/ui/select";
6-
75
export function NoDataOverlay() {
86
return (
97
<div className="absolute inset-0 flex items-center justify-center rounded-lg bg-card/50 text-muted-foreground text-sm backdrop-blur-sm">

0 commit comments

Comments
 (0)