Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

add trailingZeroDisplay: "stripIfInteger"

Steven Teycc96375c13cd
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submissions-table.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submissions-table.tsx
index 98256a6f4b..b50e49dec5 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submissions-table.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submissions-table.tsx
@@ -236,12 +236,14 @@ export function BountySubmissionsTable() {
}
const formattedValue = isCurrencyAttribute(attribute)
- ? currencyFormatter(value / 100)
- : nFormatter(value);
+ ? currencyFormatter(value / 100, {
+ maximumFractionDigits: 2,
+ })
+ : nFormatter(value, { full: true });
const formattedTarget = isCurrencyAttribute(attribute)
? currencyFormatter(target / 100)
- : nFormatter(target);
+ : nFormatter(target, { full: true });
return (
<div className="flex items-center gap-2">
diff --git a/apps/web/ui/analytics/events/events-table.tsx b/apps/web/ui/analytics/events/events-table.tsx
index 392cfeb8b1..e1d2bbb072 100644
--- a/apps/web/ui/analytics/events/events-table.tsx
+++ b/apps/web/ui/analytics/events/events-table.tsx
@@ -212,8 +212,6 @@ export default function EventsTable({
<span>
{currencyFormatter(getValue() / 100, {
maximumFractionDigits: undefined,
- // @ts-ignore – trailingZeroDisplay is a valid option but TS is outdated
- trailingZeroDisplay: "stripIfInteger",
})}
</span>
<span className="text-neutral-400">USD</span>
diff --git a/apps/web/ui/customers/customer-table/customer-table.tsx b/apps/web/ui/customers/customer-table/customer-table.tsx
index 109f40df54..ecc700c0a4 100644
--- a/apps/web/ui/customers/customer-table/customer-table.tsx
+++ b/apps/web/ui/customers/customer-table/customer-table.tsx
@@ -162,8 +162,6 @@ export function CustomerTable() {
<span>
{currencyFormatter(getValue() / 100, {
maximumFractionDigits: undefined,
- // @ts-ignore – trailingZeroDisplay is a valid option but TS is outdated
- trailingZeroDisplay: "stripIfInteger",
})}
</span>
<span className="text-neutral-400">USD</span>
diff --git a/apps/web/ui/links/link-analytics-badge.tsx b/apps/web/ui/links/link-analytics-badge.tsx
index 99dfa48685..f294a85292 100644
--- a/apps/web/ui/links/link-analytics-badge.tsx
+++ b/apps/web/ui/links/link-analytics-badge.tsx
@@ -107,8 +107,6 @@ export function LinkAnalyticsBadge({
{tab === "sales"
? currencyFormatter(value / 100, {
maximumFractionDigits: 2,
- // @ts-ignore – trailingZeroDisplay is a valid option but TS is outdated
- trailingZeroDisplay: "stripIfInteger",
})
: nFormatter(value, { full: value < INFINITY_NUMBER })}
</span>{" "}
diff --git a/apps/web/ui/partners/bounties/bounty-logic.tsx b/apps/web/ui/partners/bounties/bounty-logic.tsx
index a1fc1c0d3f..32c0fec87a 100644
--- a/apps/web/ui/partners/bounties/bounty-logic.tsx
+++ b/apps/web/ui/partners/bounties/bounty-logic.tsx
@@ -8,7 +8,7 @@ import {
InlineBadgePopoverMenu,
} from "@/ui/shared/inline-badge-popover";
import { Trophy } from "@dub/ui/icons";
-import { cn, currencyFormatter } from "@dub/utils";
+import { cn, currencyFormatter, nFormatter } from "@dub/utils";
import { useAddEditBountyForm } from "app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/add-edit-bounty-sheet";
import { useContext } from "react";
import { Controller } from "react-hook-form";
@@ -16,8 +16,8 @@ import { Controller } from "react-hook-form";
const WORKFLOW_ATTRIBUTE_LABELS: Record<WorkflowConditionAttribute, string> = {
totalLeads: "total leads",
totalConversions: "total conversions",
- totalSaleAmount: "total sale amount",
- totalCommission: "total commission",
+ totalSaleAmount: "total revenue",
+ totalCommission: "total commissions",
} as const;
export const generateBountyName = ({
@@ -32,7 +32,7 @@ export const generateBountyName = ({
const attributeLabel = WORKFLOW_ATTRIBUTE_LABELS[condition.attribute];
const valueFormatted = isCurrency
? `${currencyFormatter(condition.value / 100)} in`
- : `${condition.value}`;
+ : `${nFormatter(condition.value, { full: true })}`;
return `Earn ${rewardAmountFormatted} after generating ${valueFormatted} ${attributeLabel}`;
};
diff --git a/apps/web/ui/partners/bounties/bounty-performance.tsx b/apps/web/ui/partners/bounties/bounty-performance.tsx
index a835e5eefa..568280724a 100644
--- a/apps/web/ui/partners/bounties/bounty-performance.tsx
+++ b/apps/web/ui/partners/bounties/bounty-performance.tsx
@@ -26,12 +26,14 @@ export function BountyPerformance({
value === undefined
? "-"
: isCurrencyAttribute(attribute)
- ? currencyFormatter(value / 100)
- : nFormatter(value);
+ ? currencyFormatter(value / 100, {
+ maximumFractionDigits: 2,
+ })
+ : nFormatter(value, { full: true });
const formattedTarget = isCurrencyAttribute(attribute)
? currencyFormatter(target / 100)
- : nFormatter(target);
+ : nFormatter(target, { full: true });
const metricLabel =
WORKFLOW_ATTRIBUTE_LABELS[performanceCondition.attribute].toLowerCase();
diff --git a/apps/web/ui/partners/partner-details-sheet.tsx b/apps/web/ui/partners/partner-details-sheet.tsx
index 3d9333b76f..5e12350311 100644
--- a/apps/web/ui/partners/partner-details-sheet.tsx
+++ b/apps/web/ui/partners/partner-details-sheet.tsx
@@ -142,10 +142,10 @@ function PartnerDetailsSheetContent({ partner }: PartnerDetailsSheetProps) {
: nFormatter(partner.leads, { full: true }),
],
[
- "Sales",
- !partner.sales
+ "Conversions",
+ !partner.conversions
? "-"
- : nFormatter(partner.sales, { full: true }),
+ : nFormatter(partner.conversions, { full: true }),
],
[
"Revenue",
diff --git a/packages/utils/src/functions/currency-formatter.ts b/packages/utils/src/functions/currency-formatter.ts
index 97a7099fdf..5d727c8669 100644
--- a/packages/utils/src/functions/currency-formatter.ts
+++ b/packages/utils/src/functions/currency-formatter.ts
@@ -7,5 +7,7 @@ export const currencyFormatter = (
style: "currency",
currency: currency ?? "USD",
maximumFractionDigits: 0,
+ // @ts-ignore – trailingZeroDisplay is a valid option but TS is outdated
+ trailingZeroDisplay: "stripIfInteger",
...options,
}).format(value);