Skip to content

Commit ba52e68

Browse files
authored
[Dashboard] Fix: Trend markers and UB volume type dropdown (#7059)
1 parent 0eff648 commit ba52e68

File tree

4 files changed

+9
-117
lines changed

4 files changed

+9
-117
lines changed

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

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { SkeletonContainer } from "@/components/ui/skeleton";
33
import { useId, useMemo } from "react";
44
import { Area, AreaChart, ResponsiveContainer, Tooltip, XAxis } from "recharts";
55
import type { UniversalBridgeWalletStats } from "types/analytics";
6-
import { CardHeading, ChangeBadge, NoDataOverlay, chartHeight } from "./common";
6+
import { CardHeading, NoDataOverlay, chartHeight } from "./common";
77

88
type GraphDataItem = {
99
date: string;
@@ -20,7 +20,7 @@ export function PayNewCustomers(props: {
2020
/**
2121
* For each date, compute the total number of wallets that have never existed before in the time series
2222
*/
23-
const { graphData, trend } = useMemo(() => {
23+
const { graphData } = useMemo(() => {
2424
const dates = new Set<string>();
2525
for (const item of props.data) {
2626
if (!dates.has(item.date)) {
@@ -47,19 +47,7 @@ export function PayNewCustomers(props: {
4747
value: newUsers,
4848
});
4949
}
50-
const lastPeriod = newUsersData[newUsersData.length - 3];
51-
const currentPeriod = newUsersData[newUsersData.length - 2];
52-
// Calculate the percent change from last period to current period
53-
const trend =
54-
lastPeriod &&
55-
currentPeriod &&
56-
lastPeriod.value > 0 &&
57-
currentPeriod.value > 0
58-
? (currentPeriod.value - lastPeriod.value) / lastPeriod.value
59-
: lastPeriod?.value === 0 && (currentPeriod?.value || 0) > 0
60-
? 100
61-
: undefined;
62-
return { graphData: newUsersData, trend };
50+
return { graphData: newUsersData };
6351
}, [props.data, props.dateFormat]);
6452
const isEmpty = useMemo(
6553
() => graphData.length === 0 || graphData.every((x) => x.value === 0),
@@ -89,17 +77,6 @@ export function PayNewCustomers(props: {
8977
);
9078
}}
9179
/>
92-
93-
{!isEmpty && typeof trend !== "undefined" && (
94-
<SkeletonContainer
95-
loadedData={trend}
96-
className="rounded-2xl"
97-
skeletonData={1}
98-
render={(v) => {
99-
return <ChangeBadge percent={v} />;
100-
}}
101-
/>
102-
)}
10380
</div>
10481
</div>
10582
</div>
@@ -125,7 +102,7 @@ export function PayNewCustomers(props: {
125102
{payload?.date}
126103
</p>
127104
<p className="text-base text-medium">
128-
Customers: {payload?.value}
105+
New Customers: {payload?.value}
129106
</p>
130107
</div>
131108
);

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

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useMemo } from "react";
44
import { Bar, BarChart, ResponsiveContainer, Tooltip, XAxis } from "recharts";
55
import type { UniversalBridgeStats } from "types/analytics";
66
import { toUSD } from "../../../../utils/number";
7-
import { CardHeading, ChangeBadge, NoDataOverlay, chartHeight } from "./common";
7+
import { CardHeading, NoDataOverlay, chartHeight } from "./common";
88

99
type GraphData = {
1010
date: string;
@@ -24,7 +24,7 @@ export function Payouts(props: {
2424
props.data.every((x) => x.developerFeeUsdCents === 0);
2525

2626
const barColor = isEmpty ? "hsl(var(--accent))" : "hsl(var(--chart-1))";
27-
const { graphData, totalPayoutsUSD, trend } = useMemo(() => {
27+
const { graphData, totalPayoutsUSD } = useMemo(() => {
2828
const dates = new Set<string>();
2929
for (const item of props.data) {
3030
if (!dates.has(item.date)) {
@@ -49,21 +49,9 @@ export function Payouts(props: {
4949
value: total / 100,
5050
});
5151
}
52-
const lastPeriod = cleanedData[cleanedData.length - 3];
53-
const currentPeriod = cleanedData[cleanedData.length - 2];
54-
const trend =
55-
lastPeriod &&
56-
currentPeriod &&
57-
lastPeriod.value > 0 &&
58-
currentPeriod.value > 0
59-
? (currentPeriod.value - lastPeriod.value) / lastPeriod.value
60-
: lastPeriod?.value === 0 && (currentPeriod?.value || 0) > 0
61-
? 100
62-
: undefined;
6352
return {
6453
graphData: cleanedData,
6554
totalPayoutsUSD: totalPayouts / 100,
66-
trend,
6755
};
6856
}, [props.data, props.dateFormat]);
6957

@@ -93,17 +81,6 @@ export function Payouts(props: {
9381
);
9482
}}
9583
/>
96-
97-
{!isEmpty && typeof trend !== "undefined" && (
98-
<SkeletonContainer
99-
className="rounded-2xl"
100-
loadedData={trend}
101-
skeletonData={1}
102-
render={(percent) => {
103-
return <ChangeBadge percent={percent} />;
104-
}}
105-
/>
106-
)}
10784
</div>
10885

10986
<div className="relative flex w-full justify-center">

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

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@ export function TotalPayVolume(props: {
2424
};
2525
}) {
2626
const uniqueId = useId();
27-
const [successType, setSuccessType] = useState<"success" | "fail">("success");
2827
const [type, setType] = useState<"all" | "crypto" | "fiat">("all");
2928

3029
const graphData: GraphData[] | undefined = useMemo(() => {
31-
let data = (() => {
30+
const data = (() => {
3231
switch (type) {
3332
case "crypto": {
3433
return props.data?.filter((x) => x.type === "onchain");
@@ -45,13 +44,6 @@ export function TotalPayVolume(props: {
4544
}
4645
})();
4746

48-
data = (() => {
49-
if (successType === "fail") {
50-
return data.filter((x) => x.status === "failed");
51-
}
52-
return data.filter((x) => x.status === "completed");
53-
})();
54-
5547
const dates = new Set<string>();
5648
for (const item of data) {
5749
if (!dates.has(item.date)) {
@@ -72,15 +64,13 @@ export function TotalPayVolume(props: {
7264
});
7365
}
7466
return cleanedData;
75-
}, [props.data, type, successType, props.dateFormat]);
67+
}, [props.data, type, props.dateFormat]);
7668

7769
const isEmpty =
7870
graphData.length === 0 || graphData.every((x) => x.value === 0);
7971
const chartColor = isEmpty
8072
? "hsl(var(--muted-foreground))"
81-
: successType === "success"
82-
? "hsl(var(--chart-1))"
83-
: "hsl(var(--chart-3))";
73+
: "hsl(var(--chart-1))";
8474

8575
return (
8676
<div className="flex flex-1 flex-col">
@@ -104,21 +94,6 @@ export function TotalPayVolume(props: {
10494
<SelectItem value="fiat">Fiat</SelectItem>
10595
</SelectContent>
10696
</Select>
107-
108-
<Select
109-
value={successType}
110-
onValueChange={(value: "success" | "fail") => {
111-
setSuccessType(value);
112-
}}
113-
>
114-
<SelectTrigger className="bg-transparent">
115-
<SelectValue placeholder="Select" />
116-
</SelectTrigger>
117-
<SelectContent position="popper">
118-
<SelectItem value="success">Successful</SelectItem>
119-
<SelectItem value="fail">Failed</SelectItem>
120-
</SelectContent>
121-
</Select>
12297
</div>
12398
)}
12499
</div>

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

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
import { Badge } from "@/components/ui/badge";
2-
import { ToolTipLabel } from "@/components/ui/tooltip";
3-
import { ArrowDownIcon, ArrowUpIcon } from "lucide-react";
4-
51
export function NoDataOverlay() {
62
return (
73
<div className="absolute inset-0 flex items-center justify-center rounded-lg bg-card/50 text-muted-foreground text-sm backdrop-blur-sm">
@@ -14,39 +10,6 @@ export function CardHeading(props: { children: React.ReactNode }) {
1410
return <h3 className="font-medium text-base">{props.children}</h3>;
1511
}
1612

17-
export function ChangeBadge(props: { percent: number }) {
18-
const percentValue = `${props.percent.toFixed(0)}%`;
19-
let label = "No change compared to prior range";
20-
if (props.percent !== 0) {
21-
label = `
22-
${props.percent >= 0 ? "Increase" : "Decrease"} of ${percentValue} compared to prior range
23-
`;
24-
}
25-
return (
26-
<ToolTipLabel label={label}>
27-
<div>
28-
<Badge
29-
variant={props.percent >= 0 ? "success" : "destructive"}
30-
className="gap-1 px-2 py-1.5 text-sm"
31-
>
32-
{props.percent >= 0 ? (
33-
<ArrowUpIcon className="size-4 " />
34-
) : (
35-
<ArrowDownIcon className="size-4" />
36-
)}
37-
38-
{new Intl.NumberFormat("en-US", {
39-
style: "percent",
40-
minimumFractionDigits: 0,
41-
maximumFractionDigits: 0,
42-
signDisplay: "never",
43-
}).format(props.percent)}
44-
</Badge>
45-
</div>
46-
</ToolTipLabel>
47-
);
48-
}
49-
5013
export function TableData({ children }: { children: React.ReactNode }) {
5114
return <td className="px-3 py-2 text-sm">{children}</td>;
5215
}

0 commit comments

Comments
 (0)