The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add tooltips to performance metrics in partners table for better clarity
Kiran K4f70f1d0a74c
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/partners-table.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/partners-table.tsxindex ac1c8e8648..228ca9939d 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/partners-table.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/partners-table.tsx@@ -290,18 +290,30 @@ export function PartnersTable() {{id: "netRevenue",header: "Net Revenue",+ meta: {+ headerTooltip:+ "Net revenue after commissions. \n`Total Sale Amount - Total Commissions`",+ },accessorFn: (d: EnrolledPartnerProps) =>currencyFormatter(d.netRevenue / 100),},{id: "earningsPerClick",header: "Earnings/Click",+ meta: {+ headerTooltip:+ "Average earnings per click. \n`Total Sale Amount ÷ Total Clicks`",+ },accessorFn: (d: EnrolledPartnerProps) =>currencyFormatter(d.earningsPerClick / 100),},{id: "averageLifetimeValue",header: "Avg LTV",+ meta: {+ headerTooltip:+ "Average lifetime value per conversion. \n`Total Sale Amount ÷ Total Conversions`",+ },accessorFn: (d: EnrolledPartnerProps) =>d.averageLifetimeValue? currencyFormatter(d.averageLifetimeValue / 100)@@ -310,6 +322,10 @@ export function PartnersTable() {{id: "clickToLeadRate",header: "Click → Lead",+ meta: {+ headerTooltip:+ "Percentage of clicks that become leads. \n`Total Leads ÷ Total Clicks`",+ },accessorFn: (d: EnrolledPartnerProps) =>d.clickToLeadRate? `${(d.clickToLeadRate * 100).toFixed(2)}%`@@ -318,6 +334,10 @@ export function PartnersTable() {{id: "clickToConversionRate",header: "Click → Conv",+ meta: {+ headerTooltip:+ "Percentage of clicks that convert. \n`Total Conversions ÷ Total Clicks`",+ },accessorFn: (d: EnrolledPartnerProps) =>d.clickToConversionRate? `${(d.clickToConversionRate * 100).toFixed(2)}%`@@ -326,6 +346,10 @@ export function PartnersTable() {{id: "leadToConversionRate",header: "Lead → Conv",+ meta: {+ headerTooltip:+ "Percentage of leads that convert. \n`Total Conversions ÷ Total Leads`",+ },accessorFn: (d: EnrolledPartnerProps) =>d.leadToConversionRate? `${(d.leadToConversionRate * 100).toFixed(2)}%`@@ -334,6 +358,10 @@ export function PartnersTable() {{id: "returnOnAdSpend",header: "ROAS",+ meta: {+ headerTooltip:+ "Return on ad spend ratio. \n`Total Sale Amount ÷ Total Commissions`",+ },accessorFn: (d: EnrolledPartnerProps) =>d.returnOnAdSpend? `${(d.returnOnAdSpend * 100).toFixed(2)}%`diff --git a/packages/ui/src/table/table.tsx b/packages/ui/src/table/table.tsxindex 610bfbd3c6..c227df37cc 100644--- a/packages/ui/src/table/table.tsx+++ b/packages/ui/src/table/table.tsx@@ -19,10 +19,12 @@ import {useRef,useState,type JSX,+ type ReactNode,} from "react";import { Button } from "../button";import { Checkbox } from "../checkbox";import { LoadingSpinner, SortOrder } from "../icons";+import { Tooltip } from "../tooltip";import { SelectionToolbar } from "./selection-toolbar";import { TableProps, UseTableProps } from "./types";@@ -469,10 +471,21 @@ export function Table<T>({>{header.isPlaceholder? null- : flexRender(- header.column.columnDef.header,- header.getContext(),- )}+ : (() => {+ const headerContent = flexRender(+ header.column.columnDef.header,+ header.getContext(),+ );+ const headerTooltip =+ (header.column.columnDef.meta as any)+ ?.headerTooltip;++ return (+ <HeaderWithTooltip tooltip={headerTooltip}>+ {headerContent}+ </HeaderWithTooltip>+ );+ })()}{isSortableColumn &&sortBy === header.column.id && (<SortOrder@@ -683,3 +696,24 @@ const getCommonPinningStyles = (column: Column<any>): CSSProperties => {position: isPinned ? "sticky" : "relative",};};++// Component to wrap header content with optional tooltip+function HeaderWithTooltip({+ children,+ tooltip,+}: {+ children: ReactNode;+ tooltip?: string;+}) {+ if (!tooltip) {+ return <>{children}</>;+ }++ return (+ <Tooltip content={tooltip}>+ <span className="cursor-help underline decoration-dotted underline-offset-2">+ {children}+ </span>+ </Tooltip>+ );+}