Skip to content

Commit ff565cb

Browse files
authored
Fix: Trend badge formatting (#7007)
1 parent 816aa61 commit ff565cb

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,13 @@ export function PayNewCustomers(props: {
4949
}
5050
const lastPeriod = newUsersData[newUsersData.length - 2];
5151
const currentPeriod = newUsersData[newUsersData.length - 1];
52+
// Calculate the percent change from last period to current period
5253
const trend =
5354
lastPeriod && currentPeriod && lastPeriod.value > 0
5455
? (currentPeriod.value - lastPeriod.value) / lastPeriod.value
55-
: 0;
56+
: lastPeriod?.value === 0
57+
? 100
58+
: 0;
5659
return { graphData: newUsersData, trend };
5760
}, [props.data, props.dateFormat]);
5861
const isEmpty = useMemo(

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ export function Payouts(props: {
5454
const trend =
5555
lastPeriod && currentPeriod && lastPeriod.value > 0
5656
? (currentPeriod.value - lastPeriod.value) / lastPeriod.value
57-
: 0;
57+
: lastPeriod?.value === 0
58+
? 100
59+
: 0;
5860
return {
5961
graphData: cleanedData,
6062
totalPayoutsUSD: totalPayouts / 100,

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@ export function ChangeBadge(props: { percent: number }) {
3434
) : (
3535
<ArrowDownIcon className="size-4" />
3636
)}
37-
{percentValue}
37+
38+
{new Intl.NumberFormat("en-US", {
39+
style: "percent",
40+
minimumFractionDigits: 0,
41+
maximumFractionDigits: 0,
42+
signDisplay: "never",
43+
}).format(props.percent)}
3844
</Badge>
3945
</div>
4046
</ToolTipLabel>

0 commit comments

Comments
 (0)