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.

Move the earnings chart tooltip label into getGroupLabel

Rafiab3873e9acd1
diff --git a/apps/web/ui/partners/earnings/earnings-composite-chart.tsx b/apps/web/ui/partners/earnings/earnings-composite-chart.tsx
index 15dc72cbde..9568c6ba84 100644
--- a/apps/web/ui/partners/earnings/earnings-composite-chart.tsx
+++ b/apps/web/ui/partners/earnings/earnings-composite-chart.tsx
@@ -63,6 +63,31 @@ type EarningsCountGroup = {
logo?: string | null;
};
+// the program name, the short link, or the commission type of a chart line
+function getGroupLabel({
+ groupBy,
+ group,
+ id,
+}: {
+ groupBy: EarningsGroupBy;
+ group?: EarningsCountGroup;
+ id: string;
+}) {
+ if (groupBy === "programId" && group?.name) {
+ return group.name;
+ }
+
+ if (groupBy === "linkId" && group?.domain && group?.key) {
+ return linkConstructor({
+ domain: group.domain,
+ key: group.key,
+ pretty: true,
+ });
+ }
+
+ return capitalize(id);
+}
+
export function EarningsCompositeChart() {
const { programSlug } = useParams<{ programSlug?: string }>();
const { queryParams, searchParamsObj } = useRouterStuff();
@@ -255,17 +280,7 @@ export function EarningsCompositeChart() {
/>
)}
<span className="min-w-0 truncate font-medium text-neutral-700">
- {groupBy === "programId" && group?.name
- ? group.name
- : groupBy === "linkId" &&
- group?.domain &&
- group?.key
- ? linkConstructor({
- domain: group.domain,
- key: group.key,
- pretty: true,
- })
- : capitalize(id)}
+ {getGroupLabel({ groupBy, group, id })}
</span>
</div>
<p className="text-right text-neutral-500">