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.

Multi-row filtering for partners analytics (#3615)

Pedro Ladeirab419fedac9f6
diff --git a/apps/web/app/(ee)/admin.dub.co/(dashboard)/commissions/client.tsx b/apps/web/app/(ee)/admin.dub.co/(dashboard)/commissions/client.tsx
index 1b4244b589..55dbedba17 100644
--- a/apps/web/app/(ee)/admin.dub.co/(dashboard)/commissions/client.tsx
+++ b/apps/web/app/(ee)/admin.dub.co/(dashboard)/commissions/client.tsx
@@ -2,7 +2,7 @@
import { formatDateTooltip } from "@/lib/analytics/format-date-tooltip";
import { AnalyticsLoadingSpinner } from "@/ui/analytics/analytics-loading-spinner";
-import { FilterIconCell } from "@/ui/shared/filter-icon-cell";
+import { FilterButtonTableRow } from "@/ui/shared/filter-button-table-row";
import SimpleDateRangePicker from "@/ui/shared/simple-date-range-picker";
import {
CrownSmall,
@@ -182,21 +182,22 @@ export default function CommissionsPageClient() {
id: "program",
header: "Program",
cell: ({ row }) => (
- <FilterIconCell
- set={{ programId: row.original.id }}
- icon={
- <img
- src={row.original.logo}
- alt={row.original.name}
- width={20}
- height={20}
- className="size-4 rounded-full"
- />
- }
- >
+ <div className="flex items-center gap-1.5">
+ <img
+ src={row.original.logo}
+ alt={row.original.name}
+ width={20}
+ height={20}
+ className="size-4 rounded-full"
+ />
<span className="text-sm font-medium">{row.original.name}</span>
- </FilterIconCell>
+ </div>
),
+ meta: {
+ filterParams: ({ row }) => ({
+ programId: row.original.id,
+ }),
+ },
},
{
id: "commissions",
@@ -216,6 +217,19 @@ export default function CommissionsPageClient() {
resourceName: (plural) => `program${plural ? "s" : ""}`,
rowCount: programs?.length ?? 0,
loading: isLoading,
+ cellRight: (cell) => {
+ const meta = cell.column.columnDef.meta as
+ | {
+ filterParams?: any;
+ }
+ | undefined;
+
+ return (
+ meta?.filterParams && (
+ <FilterButtonTableRow set={meta.filterParams(cell)} />
+ )
+ );
+ },
});
return (
diff --git a/apps/web/app/(ee)/admin.dub.co/(dashboard)/payouts/client.tsx b/apps/web/app/(ee)/admin.dub.co/(dashboard)/payouts/client.tsx
index 49aa75d783..e975d0258a 100644
--- a/apps/web/app/(ee)/admin.dub.co/(dashboard)/payouts/client.tsx
+++ b/apps/web/app/(ee)/admin.dub.co/(dashboard)/payouts/client.tsx
@@ -3,7 +3,7 @@
import { formatDateTooltip } from "@/lib/analytics/format-date-tooltip";
import { AnalyticsLoadingSpinner } from "@/ui/analytics/analytics-loading-spinner";
import { PayoutStatusBadges } from "@/ui/partners/payout-status-badges";
-import { FilterIconCell } from "@/ui/shared/filter-icon-cell";
+import { FilterButtonTableRow } from "@/ui/shared/filter-button-table-row";
import SimpleDateRangePicker from "@/ui/shared/simple-date-range-picker";
import { InvoiceStatus } from "@dub/prisma/client";
import {
@@ -235,23 +235,24 @@ export default function PayoutsPageClient() {
id: "program",
header: "Program",
cell: ({ row }) => (
- <FilterIconCell
- set={{ programId: row.original.programId }}
- icon={
- <img
- src={row.original.programLogo}
- alt={row.original.programName}
- width={20}
- height={20}
- className="size-4 rounded-full"
- />
- }
- >
+ <div className="flex items-center gap-1.5">
+ <img
+ src={row.original.programLogo}
+ alt={row.original.programName}
+ width={20}
+ height={20}
+ className="size-4 rounded-full"
+ />
<span className="text-sm font-medium">
{row.original.programName}
</span>
- </FilterIconCell>
+ </div>
),
+ meta: {
+ filterParams: ({ row }) => ({
+ programId: row.original.programId,
+ }),
+ },
},
{
id: "status",
@@ -260,15 +261,18 @@ export default function PayoutsPageClient() {
const badge = PayoutStatusBadges[row.original.status];
return badge ? (
- <FilterIconCell set={{ status: row.original.status }}>
- <StatusBadge icon={badge.icon} variant={badge.variant}>
- {badge.label}
- </StatusBadge>
- </FilterIconCell>
+ <StatusBadge icon={badge.icon} variant={badge.variant}>
+ {badge.label}
+ </StatusBadge>
) : (
"-"
);
},
+ meta: {
+ filterParams: ({ row }) => ({
+ status: row.original.status,
+ }),
+ },
},
{
id: "amount",
@@ -294,6 +298,19 @@ export default function PayoutsPageClient() {
resourceName: (plural) => `invoice${plural ? "s" : ""}`,
rowCount: invoices?.length ?? 0,
loading: isLoading,
+ cellRight: (cell) => {
+ const meta = cell.column.columnDef.meta as
+ | {
+ filterParams?: any;
+ }
+ | undefined;
+
+ return (
+ meta?.filterParams && (
+ <FilterButtonTableRow set={meta.filterParams(cell)} />
+ )
+ );
+ },
});
return (
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-table.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-table.tsx
index 60e0422536..8d769f4547 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-table.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/earnings/earnings-table.tsx
@@ -5,10 +5,10 @@ import useProgramEnrollment from "@/lib/swr/use-program-enrollment";
import { PartnerEarningsResponse } from "@/lib/types";
import { CLAWBACK_REASONS_MAP } from "@/lib/zod/schemas/commissions";
import { CustomerRowItem } from "@/ui/customers/customer-row-item";
-import { CommissionTypeIcon } from "@/ui/partners/comission-type-icon";
import { CommissionStatusBadges } from "@/ui/partners/commission-status-badges";
+import { CommissionTypeBadge } from "@/ui/partners/commission-type-badge";
import { AnimatedEmptyState } from "@/ui/shared/animated-empty-state";
-import { FilterIconCell } from "@/ui/shared/filter-icon-cell";
+import { FilterButtonTableRow } from "@/ui/shared/filter-button-table-row";
import {
CopyText,
LinkLogo,
@@ -22,7 +22,6 @@ import {
} from "@dub/ui";
import { CircleDollar, Globe } from "@dub/ui/icons";
import {
- capitalize,
cn,
COUNTRIES,
currencyFormatter,
@@ -31,9 +30,16 @@ import {
getApexDomain,
getPrettyUrl,
} from "@dub/utils";
+import { Cell } from "@tanstack/react-table";
import { useParams } from "next/navigation";
import useSWR from "swr";
+type ColumnMeta = {
+ filterParams?: (
+ args: Pick<Cell<PartnerEarningsResponse, any>, "getValue">,
+ ) => Record<string, any>;
+};
+
export function EarningsTablePartner({ limit }: { limit?: number }) {
const { programSlug } = useParams();
const { programEnrollment, showDetailedAnalytics } = useProgramEnrollment();
@@ -87,30 +93,27 @@ export function EarningsTablePartner({ limit }: { limit?: number }) {
id: "type",
header: "Type",
accessorKey: "type",
- cell: ({ row }) => (
- <FilterIconCell
- set={{ type: row.original.type }}
- icon={<CommissionTypeIcon type={row.original.type} />}
- >
- {capitalize(row.original.type)}
- </FilterIconCell>
- ),
+ meta: {
+ filterParams: ({ getValue }) => ({
+ type: getValue(),
+ }),
+ },
+ cell: ({ row }) => <CommissionTypeBadge type={row.original.type} />,
},
{
id: "link",
header: "Link",
accessorKey: "link",
+ meta: {
+ filterParams: ({ row }) =>
+ row.original.link ? { linkId: row.original.link.id } : null,
+ },
cell: ({ row }) =>
row.original.link ? (
<div className="flex items-center gap-3">
- <FilterIconCell
- set={{ linkId: row.original.link.id }}
- icon={
- <LinkLogo
- apexDomain={getApexDomain(row.original.link.url)}
- className="size-4 shrink-0 sm:size-4"
- />
- }
+ <LinkLogo
+ apexDomain={getApexDomain(row.original.link.url)}
+ className="size-4 shrink-0 sm:size-4"
/>
<CopyText
value={row.original.link.shortLink}
@@ -133,20 +136,26 @@ export function EarningsTablePartner({ limit }: { limit?: number }) {
minSize: 250,
cell: ({ row }) =>
row.original.customer ? (
- <div className="flex items-center gap-3 px-4 py-2.5">
- <CustomerRowItem
- customer={row.original.customer}
- filterSet={{ customerId: row.original.customer.id }}
- href={
- showDetailedAnalytics
- ? `/programs/${programSlug}/customers/${row.original.customer.id}`
- : undefined
- }
- />
- </div>
+ <CustomerRowItem
+ customer={row.original.customer}
+ href={
+ showDetailedAnalytics
+ ? `/programs/${programSlug}/customers/${row.original.customer.id}`
+ : undefined
+ }
+ className="px-4 py-2.5"
+ />
) : (
<p className="px-4 py-2.5">-</p>
),
+ meta: {
+ filterParams: ({ row }) =>
+ row.original.customer
+ ? {
+ customerId: row.original.customer.id,
+ }
+ : null,
+ },
},
...(programEnrollment?.rewards?.some((r) => r.event === "sale")
? [
@@ -248,6 +257,15 @@ export function EarningsTablePartner({ limit }: { limit?: number }) {
},
},
],
+ cellRight: (cell) => {
+ const meta = cell.column.columnDef.meta as ColumnMeta | undefined;
+ return (
+ meta?.filterParams &&
+ meta.filterParams(cell) && (
+ <FilterButtonTableRow set={meta.filterParams(cell)} />
+ )
+ );
+ },
...(!limit && {
pagination,
onPaginationChange: setPagination,
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/analytics-partners-table.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/analytics-partners-table.tsx
index ce6ef5f7dd..c570edb1c4 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/analytics-partners-table.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/analytics-partners-table.tsx
@@ -1,8 +1,16 @@
+"use client";
+
import { AnalyticsResponse } from "@/lib/analytics/types";
import { editQueryString } from "@/lib/analytics/utils";
import { AnalyticsContext } from "@/ui/analytics/analytics-provider";
-import { PartnerRowItem } from "@/ui/partners/partner-row-item";
-import { Table, usePagination, useRouterStuff, useTable } from "@dub/ui";
+import {
+ Button,
+ Table,
+ useKeyboardShortcut,
+ usePagination,
+ useRouterStuff,
+ useTable,
+} from "@dub/ui";
import {
capitalize,
cn,
@@ -11,17 +19,62 @@ import {
fetcher,
nFormatter,
} from "@dub/utils";
-import { useRouter } from "next/navigation";
-import { useContext, useMemo } from "react";
+import { AnimatePresence, motion } from "motion/react";
+import { useCallback, useContext, useMemo, useState } from "react";
import useSWR from "swr";
+import { PartnerAnalyticsFilterCell } from "./partner-analytics-filter-cell";
export function AnalyticsPartnersTable() {
const { selectedTab, queryString } = useContext(AnalyticsContext);
- const { queryParams } = useRouterStuff();
- const router = useRouter();
+ const { queryParams, searchParams } = useRouterStuff();
+
+ const [stagedPartnerIds, setStagedPartnerIds] = useState<string[] | null>(
+ null,
+ );
const { pagination, setPagination } = usePagination(10);
+ const activePartnerIdsFromUrl = useMemo(
+ () => searchParams.get("partnerId")?.split(",").filter(Boolean) ?? [],
+ [searchParams],
+ );
+
+ const isFilterActive = searchParams.has("partnerId");
+
+ const toggleStagePartner = useCallback(
+ (partnerId: string) => {
+ setStagedPartnerIds((prev) => {
+ const base = prev ?? activePartnerIdsFromUrl;
+ const next = base.includes(partnerId)
+ ? base.filter((id) => id !== partnerId)
+ : [...base, partnerId];
+ return next.length === 0 ? null : next;
+ });
+ },
+ [activePartnerIdsFromUrl],
+ );
+
+ const applyFilter = useCallback(() => {
+ if (!stagedPartnerIds || stagedPartnerIds.length === 0) return;
+ queryParams({
+ set: { partnerId: stagedPartnerIds.join(",") },
+ del: "page",
+ });
+ setStagedPartnerIds(null);
+ }, [queryParams, stagedPartnerIds]);
+
+ const clearFilter = useCallback(() => {
+ setStagedPartnerIds(null);
+ if (searchParams.has("partnerId")) {
+ queryParams({ del: ["partnerId", "page"] });
+ }
+ }, [queryParams, searchParams]);
+
+ useKeyboardShortcut("Escape", () => setStagedPartnerIds(null), {
+ enabled: stagedPartnerIds !== null,
+ priority: 2,
+ });
+
const {
data: topPartners,
error: topPartnersError,
@@ -54,26 +107,15 @@ export function AnalyticsPartnersTable() {
minSize: 250,
cell: ({ row }) => {
const p = row.original.partner;
- const filterHref = queryParams({
- set: { partnerId: row.original.partnerId },
- del: "page",
- getNewPath: true,
- }) as string;
+ const partnerId = row.original.partnerId;
return (
- <div
- className="cursor-pointer"
- onClick={() => router.push(filterHref)}
- >
- <PartnerRowItem
- filterSet={{ partnerId: row.original.partnerId }}
- partner={{
- ...p,
- payoutsEnabledAt: p.payoutsEnabledAt
- ? new Date(p.payoutsEnabledAt)
- : null,
- }}
- />
- </div>
+ <PartnerAnalyticsFilterCell
+ partner={p}
+ partnerId={partnerId}
+ isStaged={stagedPartnerIds?.includes(partnerId) ?? false}
+ isApplied={activePartnerIdsFromUrl.includes(partnerId)}
+ onToggle={() => toggleStagePartner(partnerId)}
+ />
);
},
},
@@ -104,19 +146,22 @@ export function AnalyticsPartnersTable() {
{
id: "sales",
header: "Sales",
- accessorFn: (d) => nFormatter(d.sales),
+ accessorFn: (d: AnalyticsResponse["top_partners"]) =>
+ nFormatter(d.sales),
},
{
id: "saleAmount",
header: "Revenue",
- accessorFn: (d) => currencyFormatter(d.saleAmount),
+ accessorFn: (d: AnalyticsResponse["top_partners"]) =>
+ currencyFormatter(d.saleAmount),
},
]
: [
{
id: selectedTab,
header: `${capitalize(selectedTab)}`,
- accessorFn: (d) => nFormatter(d[selectedTab]),
+ accessorFn: (d: AnalyticsResponse["top_partners"]) =>
+ nFormatter(d[selectedTab]),
},
]),
],
@@ -132,6 +177,8 @@ export function AnalyticsPartnersTable() {
error: topPartnersError ? "Failed to load partners" : undefined,
});
+ const showFloatingBar = stagedPartnerIds !== null || isFilterActive;
+
return !topPartnersList ? (
<PartnerTableSkeleton />
) : topPartnersList.length > 0 ? (
@@ -143,7 +190,36 @@ export function AnalyticsPartnersTable() {
table={table}
containerClassName="border-none"
scrollWrapperClassName="min-h-[200px]"
- />
+ >
+ <AnimatePresence>
+ {showFloatingBar && (
+ <motion.div
+ initial={{ opacity: 0, y: 8 }}
+ animate={{ opacity: 1, y: 0 }}
+ exit={{ opacity: 0, y: 8 }}
+ transition={{ ease: "easeOut", duration: 0.15 }}
+ className="absolute bottom-0 left-0 z-20 flex h-16 w-full items-end bg-gradient-to-t from-white to-white/0"
+ >
+ <div className="flex w-full items-center justify-center gap-2 pb-2.5">
+ {stagedPartnerIds !== null && stagedPartnerIds.length > 0 && (
+ <Button
+ text="Filter"
+ variant="primary"
+ className="h-8 w-fit rounded-lg px-3 py-2"
+ onClick={applyFilter}
+ />
+ )}
+ <Button
+ text="Clear"
+ variant="secondary"
+ className="h-8 w-fit rounded-lg px-3 py-2"
+ onClick={clearFilter}
+ />
+ </div>
+ </motion.div>
+ )}
+ </AnimatePresence>
+ </Table>
</div>
) : (
<div className="text-content-muted flex h-36 items-center justify-center text-sm">
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/partner-analytics-filter-cell.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/partner-analytics-filter-cell.tsx
new file mode 100644
index 0000000000..037e8ed255
--- /dev/null
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/partner-analytics-filter-cell.tsx
@@ -0,0 +1,100 @@
+"use client";
+
+import { PartnerAvatar } from "@/ui/partners/partner-avatar";
+import { FilterBars } from "@dub/ui/icons";
+import { cn } from "@dub/utils";
+import Link from "next/link";
+import { useParams } from "next/navigation";
+
+interface PartnerAnalyticsFilterCellProps {
+ partner: {
+ id: string;
+ name: string;
+ image?: string | null;
+ };
+ partnerId: string;
+ isStaged: boolean;
+ isApplied: boolean;
+ onToggle: () => void;
+}
+
+export function PartnerAnalyticsFilterCell({
+ partner,
+ partnerId,
+ isStaged,
+ isApplied,
+ onToggle,
+}: PartnerAnalyticsFilterCellProps) {
+ const { slug } = useParams() as { slug: string };
+
+ return (
+ <div
+ role={!isApplied ? "button" : undefined}
+ tabIndex={!isApplied ? 0 : -1}
+ aria-disabled={isApplied}
+ className={cn(
+ "flex select-none items-center gap-2",
+ !isApplied && "cursor-pointer",
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-400 focus-visible:ring-offset-1",
+ )}
+ onClick={isApplied ? undefined : onToggle}
+ onKeyDown={
+ !isApplied
+ ? (e) => {
+ if (e.key === "Enter" || e.key === " ") {
+ e.preventDefault();
+ onToggle();
+ }
+ }
+ : undefined
+ }
+ >
+ <div className="relative size-6 shrink-0">
+ <div
+ className={cn(
+ "flex size-full items-center justify-center transition-all duration-200",
+ isStaged
+ ? "translate-x-3 opacity-0"
+ : "group-hover:translate-x-3 group-hover:opacity-0",
+ )}
+ >
+ <PartnerAvatar partner={partner} className="size-5" />
+ </div>
+
+ <div className="absolute inset-0 flex items-center justify-center">
+ <div
+ className={cn(
+ "flex size-6 shrink-0 items-center justify-center rounded-lg transition-all duration-200",
+ isStaged
+ ? "pointer-events-none translate-x-0 opacity-100"
+ : cn(
+ "-translate-x-3 opacity-0 group-hover:translate-x-0 group-hover:opacity-100",
+ "pointer-events-none",
+ ),
+ isStaged || isApplied
+ ? "bg-neutral-900"
+ : "border border-neutral-200 bg-white",
+ )}
+ >
+ <FilterBars
+ className={cn(
+ "size-3",
+ isStaged || isApplied ? "text-white" : "text-neutral-500",
+ )}
+ />
+ </div>
+ </div>
+ </div>
+
+ <Link
+ href={`/${slug}/program/partners/${partnerId}`}
+ target="_blank"
+ onClick={(e) => e.stopPropagation()}
+ className="min-w-0 cursor-alias truncate decoration-dotted hover:underline"
+ title={partner.name}
+ >
+ {partner.name}
+ </Link>
+ </div>
+ );
+}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/commissions-table.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/commissions-table.tsx
index a95821fdd2..7b97aaf7c8 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/commissions-table.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/commissions-table.tsx
@@ -9,13 +9,13 @@ import useWorkspace from "@/lib/swr/use-workspace";
import { CommissionResponse, FraudGroupCountByPartner } from "@/lib/types";
import { CLAWBACK_REASONS_MAP } from "@/lib/zod/schemas/commissions";
import { CustomerRowItem } from "@/ui/customers/customer-row-item";
-import { CommissionTypeIcon } from "@/ui/partners/comission-type-icon";
import { CommissionRowMenu } from "@/ui/partners/commission-row-menu";
import { CommissionStatusBadges } from "@/ui/partners/commission-status-badges";
+import { CommissionTypeBadge } from "@/ui/partners/commission-type-badge";
import { GroupColorCircle } from "@/ui/partners/groups/group-color-circle";
import { PartnerRowItem } from "@/ui/partners/partner-row-item";
import { AnimatedEmptyState } from "@/ui/shared/animated-empty-state";
-import { FilterIconCell } from "@/ui/shared/filter-icon-cell";
+import { FilterButtonTableRow } from "@/ui/shared/filter-button-table-row";
import SimpleDateRangePicker from "@/ui/shared/simple-date-range-picker";
import {
AnimatedSizeContainer,
@@ -32,7 +32,6 @@ import {
} from "@dub/ui";
import { MoneyBill2 } from "@dub/ui/icons";
import {
- capitalize,
cn,
currencyFormatter,
fetcher,
@@ -168,24 +167,31 @@ export function CommissionsTable() {
<div className="flex items-center gap-2">
<CustomerRowItem
customer={row.original.customer}
- filterSet={{ customerId: row.original.customer.id }}
href={`/${slug}/program/customers/${row.original.customer.id}`}
/>
</div>
) : (
"-"
),
+ meta: {
+ filterParams: ({ row }) =>
+ row.original.customer
+ ? {
+ customerId: row.original.customer.id,
+ }
+ : {},
+ },
},
{
id: "partner",
header: "Partner",
- cell: ({ row }) => (
- <PartnerRowItem
- filterSet={{ partnerId: row.original.partner.id }}
- partner={row.original.partner}
- />
- ),
+ cell: ({ row }) => <PartnerRowItem partner={row.original.partner} />,
maxSize: 200,
+ meta: {
+ filterParams: ({ row }) => ({
+ partnerId: row.original.partner.id,
+ }),
+ },
},
{
id: "group",
@@ -213,13 +219,13 @@ export function CommissionsTable() {
id: "type",
header: "Type",
accessorKey: "type",
+ meta: {
+ filterParams: ({ row }) => ({
+ type: row.original.type ?? "sale",
+ }),
+ },
cell: ({ row }) => (
- <FilterIconCell
- set={{ type: row.original.type }}
- icon={<CommissionTypeIcon type={row.original.type ?? "sale"} />}
- >
- {capitalize(row.original.type ?? "sale")}
- </FilterIconCell>
+ <CommissionTypeBadge type={row.original.type ?? "sale"} />
),
},
{
@@ -348,6 +354,19 @@ export function CommissionsTable() {
onPointerEnter: () =>
router.prefetch(`/${slug}/program/commissions/${row.original.id}`),
}),
+ cellRight: (cell) => {
+ const meta = cell.column.columnDef.meta as
+ | {
+ filterParams?: any;
+ }
+ | undefined;
+
+ return (
+ meta?.filterParams && (
+ <FilterButtonTableRow set={meta.filterParams(cell)} />
+ )
+ );
+ },
thClassName: "border-l-0",
tdClassName: "border-l-0",
resourceName: (p) => `commission${p ? "s" : ""}`,
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/fraud/fraud-group-table.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/fraud/fraud-group-table.tsx
index dee669ad8c..368ac5c904 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/fraud/fraud-group-table.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/fraud/fraud-group-table.tsx
@@ -13,7 +13,7 @@ import { FraudDisclaimerBanner } from "@/ui/partners/fraud-risks/fraud-disclaime
import { FraudReviewSheet } from "@/ui/partners/fraud-risks/fraud-review-sheet";
import { PartnerRowItem } from "@/ui/partners/partner-row-item";
import { AnimatedEmptyState } from "@/ui/shared/animated-empty-state";
-import { FilterIconCell } from "@/ui/shared/filter-icon-cell";
+import { FilterButtonTableRow } from "@/ui/shared/filter-button-table-row";
import {
AnimatedSizeContainer,
Badge,
@@ -129,26 +129,29 @@ export function FraudGroupTable() {
if (reason) {
return (
- <FilterIconCell set={{ type: row.original.type }}>
- <div className="flex items-center gap-2">
- <Tooltip content={reason.description}>
- <span className="cursor-help truncate underline decoration-dotted underline-offset-2">
- {reason.name}
- </span>
- </Tooltip>
- {count > 1 && (
- <Badge
- variant="gray"
- className="shrink-0 rounded-md border-none px-1.5 py-1 text-xs font-semibold text-neutral-700"
- >
- +{Number(count) - 1}
- </Badge>
- )}
- </div>
- </FilterIconCell>
+ <div className="flex items-center gap-2">
+ <Tooltip content={reason.description}>
+ <span className="cursor-help truncate underline decoration-dotted underline-offset-2">
+ {reason.name}
+ </span>
+ </Tooltip>
+ {count > 1 && (
+ <Badge
+ variant="gray"
+ className="shrink-0 rounded-md border-none px-1.5 py-1 text-xs font-semibold text-neutral-700"
+ >
+ +{Number(count) - 1}
+ </Badge>
+ )}
+ </div>
);
}
},
+ meta: {
+ filterParams: ({ row }) => ({
+ type: row.original.type,
+ }),
+ },
},
{
id: "partner",
@@ -160,7 +163,6 @@ export function FraudGroupTable() {
return (
<PartnerRowItem
- filterSet={{ partnerId: partner.id }}
partner={{
id: partner.id,
name: partner.name || "Unknown",
@@ -171,6 +173,14 @@ export function FraudGroupTable() {
/>
);
},
+ meta: {
+ filterParams: ({ row }) =>
+ row.original.partner
+ ? {
+ partnerId: row.original.partner.id,
+ }
+ : {},
+ },
},
{
id: "lastEventAt",
@@ -223,6 +233,19 @@ export function FraudGroupTable() {
scroll: false,
});
},
+ cellRight: (cell) => {
+ const meta = cell.column.columnDef.meta as
+ | {
+ filterParams?: any;
+ }
+ | undefined;
+
+ if (!meta?.filterParams) return null;
+ const params = meta.filterParams(cell);
+ if (!params || Object.keys(params).length === 0) return null;
+
+ return <FilterButtonTableRow set={params} />;
+ },
thClassName: "border-l-0",
tdClassName: "border-l-0",
resourceName: (plural) => `fraud event${plural ? "s" : ""}`,
diff --git a/apps/web/ui/analytics/events/events-table.tsx b/apps/web/ui/analytics/events/events-table.tsx
index d66ac02a41..22dcfa8fa2 100644
--- a/apps/web/ui/analytics/events/events-table.tsx
+++ b/apps/web/ui/analytics/events/events-table.tsx
@@ -6,7 +6,7 @@ import { useWorkspacePreferences } from "@/lib/swr/use-workspace-preferences";
import { ClickEvent, LeadEvent, SaleEvent } from "@/lib/types";
import { CustomerRowItem } from "@/ui/customers/customer-row-item";
import EmptyState from "@/ui/shared/empty-state";
-import { FilterIconCell } from "@/ui/shared/filter-icon-cell";
+import { FilterButtonTableRow } from "@/ui/shared/filter-button-table-row";
import {
CopyText,
EditColumnsButton,
@@ -25,13 +25,14 @@ import {
COUNTRIES,
REGIONS,
capitalize,
+ cn,
currencyFormatter,
fetcher,
formatDateTimeSmart,
getApexDomain,
getPrettyUrl,
} from "@dub/utils";
-import { ColumnDef } from "@tanstack/react-table";
+import { Cell, ColumnDef } from "@tanstack/react-table";
import { Link2 } from "lucide-react";
import Link from "next/link";
import { useParams } from "next/navigation";
@@ -130,6 +131,12 @@ const eventColumns = {
export type EventDatum = ClickEvent | LeadEvent | SaleEvent;
+type ColumnMeta = {
+ filterParams?: (
+ args: Pick<Cell<EventDatum, any>, "getValue">,
+ ) => Record<string, any>;
+};
+
export default function EventsTable({
requiresUpgrade,
upgradeOverlay,
@@ -220,17 +227,20 @@ export default function EventsTable({
minSize: 150,
size: 150,
maxSize: 150,
+ meta: {
+ filterParams: ({ getValue }) => ({
+ trigger: getValue() ?? "link",
+ }),
+ },
cell: ({ getValue }) => {
const { title, icon: Icon } = TRIGGER_DISPLAY[getValue() ?? "link"];
return (
- <FilterIconCell
- set={{ trigger: getValue() ?? "link" }}
- icon={<Icon className="size-4 shrink-0" />}
- >
+ <div className="flex items-center gap-3">
+ <Icon className="size-4 shrink-0" />
<span className="truncate" title={title}>
{title}
</span>
- </FilterIconCell>
+ </div>
);
},
},
@@ -255,22 +265,20 @@ export default function EventsTable({
minSize: 300,
size: 300,
maxSize: 400,
- cell: ({ getValue }) => {
- const customer = getValue();
- return (
- <div className="flex items-center gap-3 px-4 py-2.5">
- <FilterIconCell set={{ customerId: customer.id }} />
- <CustomerRowItem
- customer={customer}
- href={
- partnerPage
- ? `/programs/${programSlug}/customers/${customer.id}`
- : `/${slug}/customers/${customer.id}`
- }
- />
- </div>
- );
+ meta: {
+ filterParams: ({ getValue }) => ({ customerId: getValue().id }),
},
+ cell: ({ getValue }) => (
+ <CustomerRowItem
+ customer={getValue()}
+ href={
+ partnerPage
+ ? `/programs/${programSlug}/customers/${getValue().id}`
+ : `/${slug}/customers/${getValue().id}`
+ }
+ className="px-4 py-2.5"
+ />
+ ),
},
{
id: "customerName",
@@ -320,37 +328,38 @@ export default function EventsTable({
minSize: 250,
size: 250,
maxSize: 400,
+ meta: {
+ filterParams: ({ getValue }) => ({ linkId: getValue().id }),
+ },
cell: ({ getValue }) => {
- const link = getValue();
- const text = (
- <span className="truncate" title={shortLinkTitle(link)}>
- {getPrettyUrl(shortLinkTitle(link))}
- </span>
- );
- return (
- <div className="flex items-center gap-3">
- <FilterIconCell
- set={{ linkId: link.id }}
- icon={
- <LinkLogo
- apexDomain={getApexDomain(link.url)}
- className="size-4 shrink-0 sm:size-4"
- />
- }
- />
- {partnerPage ? (
- text
- ) : (
- <Link
- href={`/${slug}/links/${link.domain}/${link.key}`}
- target="_blank"
- className="cursor-alias truncate decoration-dotted hover:underline"
- >
- {text}
- </Link>
+ const content = (
+ <div
+ className={cn(
+ "flex items-center gap-3",
+ !partnerPage &&
+ "cursor-alias decoration-dotted hover:underline",
)}
+ >
+ <LinkLogo
+ apexDomain={getApexDomain(getValue().url)}
+ className="size-4 shrink-0 sm:size-4"
+ />
+ <span className="truncate" title={shortLinkTitle(getValue())}>
+ {getPrettyUrl(shortLinkTitle(getValue()))}
+ </span>
</div>
);
+
+ return partnerPage ? (
+ content
+ ) : (
+ <Link
+ href={`/${slug}/links/${getValue().domain}/${getValue().key}`}
+ target="_blank"
+ >
+ {content}
+ </Link>
+ );
},
},
{
@@ -359,16 +368,14 @@ export default function EventsTable({
accessorKey: "click.url",
minSize: 250,
size: 250,
+ meta: {
+ filterParams: ({ getValue }) => ({ url: getValue() }),
+ },
cell: ({ getValue }) => (
<div className="flex items-center gap-3">
- <FilterIconCell
- set={{ url: getValue() }}
- icon={
- <LinkLogo
- apexDomain={getApexDomain(getValue())}
- className="size-4 shrink-0 sm:size-4"
- />
- }
+ <LinkLogo
+ apexDomain={getApexDomain(getValue())}
+ className="size-4 shrink-0 sm:size-4"
/>
<CopyText
value={getValue()}
@@ -385,47 +392,45 @@ export default function EventsTable({
id: "referer",
header: "Referrer",
accessorKey: "click.referer",
+ meta: {
+ filterParams: ({ getValue }) => ({ referer: getValue() }),
+ },
cell: ({ getValue }) => (
- <FilterIconCell
- set={{ referer: getValue() }}
- icon={
- getValue() === "(direct)" ? (
- <Link2 className="h-4 w-4" />
- ) : (
- <LinkLogo
- apexDomain={getValue()}
- className="size-4 shrink-0 sm:size-4"
- />
- )
- }
- >
+ <div className="flex items-center gap-3">
+ {getValue() === "(direct)" ? (
+ <Link2 className="h-4 w-4" />
+ ) : (
+ <LinkLogo
+ apexDomain={getValue()}
+ className="size-4 shrink-0 sm:size-4"
+ />
+ )}
<CopyText
value={getValue()}
successMessage="Copied referrer to clipboard!"
>
<span className="truncate">{getValue()}</span>
</CopyText>
- </FilterIconCell>
+ </div>
),
},
{
id: "refererUrl",
header: "Referrer URL",
accessorKey: "click.refererUrl",
+ meta: {
+ filterParams: ({ getValue }) => ({ refererUrl: getValue() }),
+ },
cell: ({ getValue }) => (
- <FilterIconCell
- set={{ refererUrl: getValue() }}
- icon={
- getValue() === "(direct)" ? (
- <Link2 className="h-4 w-4" />
- ) : (
- <LinkLogo
- apexDomain={getApexDomain(getValue())}
- className="size-4 shrink-0 sm:size-4"
- />
- )
- }
- >
+ <div className="flex items-center gap-3">
+ {getValue() === "(direct)" ? (
+ <Link2 className="h-4 w-4" />
+ ) : (
+ <LinkLogo
+ apexDomain={getApexDomain(getValue())}
+ className="size-4 shrink-0 sm:size-4"
+ />
+ )}
<CopyText
value={getValue()}
successMessage="Copied referrer URL to clipboard!"
@@ -434,32 +439,34 @@ export default function EventsTable({
{getPrettyUrl(getValue())}
</span>
</CopyText>
- </FilterIconCell>
+ </div>
),
},
{
id: "country",
header: "Country",
accessorKey: "click.country",
+ meta: {
+ filterParams: ({ getValue }) => ({ country: getValue() }),
+ },
cell: ({ getValue }) => (
- <FilterIconCell
- set={{ country: getValue() }}
- icon={
- getValue() === "Unknown" ? (
- <Globe className="size-4 shrink-0" />
- ) : (
- <img
- alt={getValue()}
- src={`https://hatscripts.github.io/circle-flags/flags/${getValue().toLowerCase()}.svg`}
- className="size-4 shrink-0"
- />
- )
- }
+ <div
+ className="flex items-center gap-3"
+ title={COUNTRIES[getValue()] ?? getValue()}
>
- <span className="truncate" title={COUNTRIES[getValue()] ?? getValue()}>
+ {getValue() === "Unknown" ? (
+ <Globe className="size-4 shrink-0" />
+ ) : (
+ <img
+ alt={getValue()}
+ src={`https://hatscripts.github.io/circle-flags/flags/${getValue().toLowerCase()}.svg`}
+ className="size-4 shrink-0"
+ />
+ )}
+ <span className="truncate">
{COUNTRIES[getValue()] ?? getValue()}
</span>
- </FilterIconCell>
+ </div>
),
},
{
@@ -467,90 +474,90 @@ export default function EventsTable({
header: "City",
accessorKey: "click.city",
minSize: 160,
- cell: ({ getValue, row }) => (
- <FilterIconCell
- set={{ city: getValue() }}
- icon={
- !row.original.country ||
- row.original.country === "Unknown" ? (
+ meta: {
+ filterParams: ({ getValue }) => ({ city: getValue() }),
+ },
+ cell: ({ getValue, row }) => {
+ const country = row.original.click?.country;
+ return (
+ <div className="flex items-center gap-3" title={getValue()}>
+ {!country || country === "Unknown" ? (
<Globe className="size-4 shrink-0" />
) : (
<img
- alt={row.original.country}
- src={`https://hatscripts.github.io/circle-flags/flags/${row.original.country.toLowerCase()}.svg`}
+ alt={country}
+ src={`https://hatscripts.github.io/circle-flags/flags/${country.toLowerCase()}.svg`}
className="size-4 shrink-0"
/>
- )
- }
- >
- <span className="truncate" title={getValue()}>{getValue()}</span>
- </FilterIconCell>
- ),
+ )}
+ <span className="truncate">{getValue()}</span>
+ </div>
+ );
+ },
},
{
id: "region",
header: "Region",
accessorKey: "click.region",
minSize: 160,
- cell: ({ getValue, row }) => (
- <FilterIconCell
- set={{ region: getValue() }}
- icon={
- !row.original.country ||
- row.original.country === "Unknown" ? (
+ meta: {
+ filterParams: ({ getValue }) => ({ region: getValue() }),
+ },
+ cell: ({ getValue, row }) => {
+ const country = row.original.click?.country;
+ return (
+ <div className="flex items-center gap-3" title={getValue()}>
+ {!country || country === "Unknown" ? (
<Globe className="size-4 shrink-0" />
) : (
<img
- alt={row.original.country}
- src={`https://hatscripts.github.io/circle-flags/flags/${row.original.country.toLowerCase()}.svg`}
+ alt={country}
+ src={`https://hatscripts.github.io/circle-flags/flags/${country.toLowerCase()}.svg`}
className="size-4 shrink-0"
/>
- )
- }
- >
- <span className="truncate" title={getValue()}>
- {REGIONS[getValue()] || getValue().split("-")[1]}
- </span>
- </FilterIconCell>
- ),
+ )}
+ <span className="truncate">
+ {REGIONS[getValue()] || getValue().split("-")[1]}
+ </span>
+ </div>
+ );
+ },
},
{
id: "continent",
header: "Continent",
accessorKey: "click.continent",
+ meta: {
+ filterParams: ({ getValue }) => ({ continent: getValue() }),
+ },
cell: ({ getValue }) => (
- <FilterIconCell
- set={{ continent: getValue() }}
- icon={
- <ContinentIcon display={getValue()} className="size-4 shrink-0" />
- }
+ <div
+ className="flex items-center gap-3"
+ title={CONTINENTS[getValue()] ?? "Unknown"}
>
- <span
- className="truncate"
- title={CONTINENTS[getValue()] ?? "Unknown"}
- >
+ <ContinentIcon display={getValue()} className="size-4 shrink-0" />
+ <span className="truncate">
{CONTINENTS[getValue()] ?? "Unknown"}
</span>
- </FilterIconCell>
+ </div>
),
},
{
id: "device",
header: "Device",
accessorKey: "click.device",
+ meta: {
+ filterParams: ({ getValue }) => ({ device: getValue() }),
+ },
cell: ({ getValue }) => (
- <FilterIconCell
- set={{ device: getValue() }}
- icon={
- <DeviceIcon
- display={capitalize(getValue()) ?? getValue()}
- tab="devices"
- className="size-4 shrink-0"
- />
- }
- >
- <span className="truncate" title={getValue()}>{getValue()}</span>
- </FilterIconCell>
+ <div className="flex items-center gap-3" title={getValue()}>
+ <DeviceIcon
+ display={capitalize(getValue()) ?? getValue()}
+ tab="devices"
+ className="size-4 shrink-0"
+ />
+ <span className="truncate">{getValue()}</span>
+ </div>
),
},
{
@@ -762,6 +769,17 @@ export default function EventsTable({
},
}),
columnPinning: { right: ["menu"] },
+ cellRight: (cell) => {
+ const meta = cell.column.columnDef.meta as ColumnMeta | undefined;
+ return (
+ meta?.filterParams && (
+ <FilterButtonTableRow
+ set={meta.filterParams(cell)}
+ className="bg-[linear-gradient(to_right,transparent,white_10%)]"
+ />
+ )
+ );
+ },
tdClassName: (columnId) => (columnId === "customer" ? "p-0" : ""),
emptyState: (
<EmptyState
diff --git a/apps/web/ui/customers/customer-row-item.tsx b/apps/web/ui/customers/customer-row-item.tsx
index 839a49a31d..f64ea0fa82 100644
--- a/apps/web/ui/customers/customer-row-item.tsx
+++ b/apps/web/ui/customers/customer-row-item.tsx
@@ -1,5 +1,4 @@
import { generateRandomName } from "@/lib/names";
-import { FilterIconCell } from "@/ui/shared/filter-icon-cell";
import { cn } from "@dub/utils";
import Link from "next/link";
import React, { ComponentProps } from "react";
@@ -10,7 +9,6 @@ export function CustomerRowItem({
href,
className,
avatarClassName,
- filterSet,
}: {
customer: {
id: string;
@@ -21,21 +19,20 @@ export function CustomerRowItem({
href?: string;
className?: string;
avatarClassName?: string;
- filterSet?: Record<string, any>;
}) {
const display = customer.email || customer.name || generateRandomName();
- const avatar = (
- <CustomerAvatar
- customer={customer}
- className={cn("size-5 border border-neutral-200", avatarClassName)}
- />
- );
-
return (
<Wrapper
element={href ? Link : "div"}
- {...(href ? { href, target: "_blank" } : {})}
+ {...(href
+ ? {
+ href,
+ target: "_blank",
+ onClick: (e) => e.stopPropagation(),
+ onAuxClick: (e) => e.stopPropagation(),
+ }
+ : {})}
className={cn(
"group flex items-center justify-between gap-2",
href && "cursor-alias decoration-dotted hover:underline",
@@ -43,11 +40,10 @@ export function CustomerRowItem({
)}
>
<div className="flex items-center gap-2 truncate" title={display}>
- {filterSet ? (
- <FilterIconCell set={filterSet} icon={avatar} />
- ) : (
- <div className="shrink-0">{avatar}</div>
- )}
+ <CustomerAvatar
+ customer={customer}
+ className={cn("size-5 border border-neutral-200", avatarClassName)}
+ />
<span className="truncate">{display}</span>
</div>
</Wrapper>
diff --git a/apps/web/ui/customers/customers-table/customers-table.tsx b/apps/web/ui/customers/customers-table/customers-table.tsx
index ab63cf2781..d22eac0f6c 100644
--- a/apps/web/ui/customers/customers-table/customers-table.tsx
+++ b/apps/web/ui/customers/customers-table/customers-table.tsx
@@ -8,7 +8,7 @@ import { getCustomersQuerySchema } from "@/lib/zod/schemas/customers";
import { CustomerRowItem } from "@/ui/customers/customer-row-item";
import { PartnerRowItem } from "@/ui/partners/partner-row-item";
import { AnimatedEmptyState } from "@/ui/shared/animated-empty-state";
-import { FilterIconCell } from "@/ui/shared/filter-icon-cell";
+import { FilterButtonTableRow } from "@/ui/shared/filter-button-table-row";
import { SearchBoxPersisted } from "@/ui/shared/search-box";
import {
AnimatedSizeContainer,
@@ -38,7 +38,7 @@ import {
getApexDomain,
getPrettyUrl,
} from "@dub/utils";
-import { Row } from "@tanstack/react-table";
+import { Cell, Row } from "@tanstack/react-table";
import { Command } from "cmdk";
import Image from "next/image";
import Link from "next/link";
@@ -50,6 +50,12 @@ import * as z from "zod/v4";
import { EXAMPLE_CUSTOMER_DATA } from "./example-data";
import { useCustomerFilters } from "./use-customer-filters";
+type ColumnMeta = {
+ filterParams?: (
+ args: Pick<Cell<CustomerProps, any>, "getValue">,
+ ) => Record<string, any>;
+};
+
export function CustomersTable({
query,
isProgramPage = false,
@@ -153,22 +159,25 @@ export function CustomersTable({
header: "Country",
accessorKey: "country",
minSize: 150,
+ meta: {
+ filterParams: ({ getValue }) =>
+ getValue()
+ ? {
+ country: getValue(),
+ }
+ : undefined,
+ },
cell: ({ row }) => {
const country = row.original.country;
return (
<div className="flex items-center gap-2">
- {country ? (
- <FilterIconCell
- set={{ country }}
- icon={
- <img
- alt={`${country} flag`}
- src={`https://hatscripts.github.io/circle-flags/flags/${country.toLowerCase()}.svg`}
- className="size-4 shrink-0"
- />
- }
+ {country && (
+ <img
+ alt={`${country} flag`}
+ src={`https://hatscripts.github.io/circle-flags/flags/${country.toLowerCase()}.svg`}
+ className="size-4 shrink-0"
/>
- ) : null}
+ )}
<span className="min-w-0 truncate">
{(country ? COUNTRIES[country] : null) ?? "-"}
</span>
@@ -181,44 +190,43 @@ export function CustomersTable({
header: "Partner",
cell: ({ row }) =>
row.original.partner ? (
- <PartnerRowItem
- filterSet={{ partnerId: row.original.partner.id }}
- partner={row.original.partner}
- />
+ <PartnerRowItem partner={row.original.partner} />
) : (
"-"
),
size: 200,
+ meta: {
+ filterParams: ({ row }) =>
+ row.original.partner?.id
+ ? {
+ partnerId: row.original.partner.id,
+ }
+ : undefined,
+ },
},
{
id: "link",
header: "Link",
accessorKey: "link",
+ meta: {
+ filterParams: ({ getValue }) =>
+ getValue() ? { linkId: getValue().id } : undefined,
+ },
cell: ({ row }) =>
row.original.link ? (
- <div className="flex items-center gap-3">
- <FilterIconCell
- set={{ linkId: row.original.link.id }}
- icon={
- <LinkLogo
- apexDomain={getApexDomain(row.original.link.url)}
- className="size-4 shrink-0 sm:size-4"
- />
- }
+ <Link
+ href={`/${workspaceSlug}/links/${row.original.link.domain}/${row.original.link.key}`}
+ target="_blank"
+ className="flex cursor-alias items-center gap-3 decoration-dotted underline-offset-2 hover:underline"
+ >
+ <LinkLogo
+ apexDomain={getApexDomain(row.original.link.url)}
+ className="size-4 shrink-0 sm:size-4"
/>
- <Link
- href={`/${workspaceSlug}/links/${row.original.link.domain}/${row.original.link.key}`}
- target="_blank"
- className="cursor-alias truncate decoration-dotted underline-offset-2 hover:underline"
- >
- <span
- className="truncate"
- title={row.original.link.shortLink}
- >
- {getPrettyUrl(row.original.link.shortLink)}
- </span>
- </Link>
- </div>
+ <span className="truncate" title={row.original.link.shortLink}>
+ {getPrettyUrl(row.original.link.shortLink)}
+ </span>
+ </Link>
) : (
"-"
),
@@ -379,6 +387,13 @@ export function CustomersTable({
del: "page",
scroll: false,
}),
+ cellRight: (cell) => {
+ const meta = cell.column.columnDef.meta as ColumnMeta | undefined;
+ if (!meta?.filterParams) return null;
+ const params = meta.filterParams(cell);
+ if (!params || Object.keys(params).length === 0) return null;
+ return <FilterButtonTableRow set={params} />;
+ },
thClassName: "border-l-0",
tdClassName: "border-l-0",
resourceName: (p) => `customer${p ? "s" : ""}`,
diff --git a/apps/web/ui/partners/partner-row-item.tsx b/apps/web/ui/partners/partner-row-item.tsx
index df5e5f7a67..f46b4e4d71 100644
--- a/apps/web/ui/partners/partner-row-item.tsx
+++ b/apps/web/ui/partners/partner-row-item.tsx
@@ -1,5 +1,4 @@
import useProgram from "@/lib/swr/use-program";
-import { FilterIconCell } from "@/ui/shared/filter-icon-cell";
import { PartnerPayoutMethod } from "@dub/prisma/client";
import { CircleArrowRight, DynamicTooltipWrapper, GreekTemple } from "@dub/ui";
import { cn, formatDateTimeSmart } from "@dub/utils";
@@ -16,7 +15,6 @@ import {
interface PartnerRowItemProps {
showPermalink?: boolean;
showFraudIndicator?: boolean;
- filterSet?: Record<string, any>;
partner: {
id: string;
name: string;
@@ -170,56 +168,48 @@ export function PartnerRowItem({
partner,
showPermalink = true,
showFraudIndicator = true,
- filterSet,
}: PartnerRowItemProps) {
const { slug } = useParams();
const { statusKey, showPayoutsEnabled } = usePartnerPayoutStatus(partner);
const As = showPermalink ? Link : "div";
- const avatar = (
- <DynamicTooltipWrapper
- tooltipProps={
- statusKey
- ? {
- content: (
- <PartnerPayoutStatusTooltip
- statusKey={statusKey}
- partner={partner}
- />
- ),
- }
- : undefined
- }
- >
- <div className="relative shrink-0">
- <PartnerAvatar partner={partner} className="size-5" />
- {showPayoutsEnabled && statusKey && (
- <div
- className={cn(
- "absolute -bottom-0.5 -right-0.5 size-2 rounded-full",
- PAYOUT_STATUS_CONFIG[statusKey].indicatorColor,
- )}
- />
- )}
- </div>
- </DynamicTooltipWrapper>
- );
-
return (
<div className="flex min-w-0 items-center gap-2">
- {filterSet ? (
- <FilterIconCell set={filterSet} icon={avatar} />
- ) : (
- <div className="shrink-0">{avatar}</div>
- )}
+ <div className="shrink-0">
+ <DynamicTooltipWrapper
+ tooltipProps={
+ statusKey
+ ? {
+ content: (
+ <PartnerPayoutStatusTooltip
+ statusKey={statusKey}
+ partner={partner}
+ />
+ ),
+ }
+ : undefined
+ }
+ >
+ <div className="relative shrink-0">
+ <PartnerAvatar partner={partner} className="size-5" />
+ {showPayoutsEnabled && statusKey && (
+ <div
+ className={cn(
+ "absolute -bottom-0.5 -right-0.5 size-2 rounded-full",
+ PAYOUT_STATUS_CONFIG[statusKey].indicatorColor,
+ )}
+ />
+ )}
+ </div>
+ </DynamicTooltipWrapper>
+ </div>
<As
href={`/${slug}/program/partners/${partner.id}`}
{...(showPermalink && { target: "_blank" })}
- {...(filterSet && {
- onClick: (e: React.MouseEvent) => e.stopPropagation(),
- })}
+ onClick={showPermalink ? (e) => e.stopPropagation() : undefined}
+ onAuxClick={showPermalink ? (e) => e.stopPropagation() : undefined}
className={cn(
"min-w-0 truncate",
showPermalink && "cursor-alias decoration-dotted hover:underline",
diff --git a/apps/web/ui/shared/filter-icon-cell.tsx b/apps/web/ui/shared/filter-icon-cell.tsx
deleted file mode 100644
index de60b3d953..0000000000
--- a/apps/web/ui/shared/filter-icon-cell.tsx
+++ /dev/null
@@ -1,106 +0,0 @@
-"use client";
-
-import { useRouterStuff } from "@dub/ui";
-import { FilterBars } from "@dub/ui/icons";
-import { cn } from "@dub/utils";
-import Link from "next/link";
-import { type MouseEvent, type ReactNode } from "react";
-
-export function FilterIconCell({
- set,
- icon,
- children,
-}: {
- set: Record<string, any>;
- icon?: ReactNode;
- children?: ReactNode;
-}) {
- const { queryParams, searchParams } = useRouterStuff();
- const isActive = Object.entries(set).every(
- ([k, v]) => searchParams.get(k) === String(v),
- );
-
- const href = queryParams({ set, del: "page", getNewPath: true }) as string;
-
- const stopRowPointer = (e: MouseEvent) => e.stopPropagation();
-
- const filterButtonLink = (
- <Link
- href={href}
- onClick={stopRowPointer}
- onAuxClick={stopRowPointer}
- className={cn(
- "flex size-6 shrink-0 items-center justify-center rounded-lg transition-all duration-200",
- "-translate-x-3 opacity-0 group-hover:translate-x-0 group-hover:opacity-100",
- "pointer-events-none group-hover:pointer-events-auto",
- "focus:pointer-events-auto focus:translate-x-0 focus:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-400 focus-visible:ring-offset-1",
- isActive ? "bg-neutral-900" : "border border-neutral-200 bg-white",
- )}
- aria-label="Filter by this value"
- >
- <FilterBars
- className={cn("size-3", isActive ? "text-white" : "text-neutral-500")}
- />
- </Link>
- );
-
- // No-icon + children: filter button is absolutely positioned
- if (!icon && children) {
- return (
- <div className="relative flex items-center">
- <Link
- href={href}
- onClick={stopRowPointer}
- onAuxClick={stopRowPointer}
- className="absolute inset-0 z-0"
- aria-label="Filter by this value"
- />
-
- <div className="absolute inset-y-0 left-0 z-10 flex items-center">
- {filterButtonLink}
- </div>
-
- <div className="relative z-10 min-w-0 transition-all duration-200 group-hover:translate-x-8">
- {children}
- </div>
- </div>
- );
- }
-
- return (
- <div className={cn("flex items-center gap-3", children && "relative")}>
- {children && (
- <Link
- href={href}
- onClick={stopRowPointer}
- onAuxClick={stopRowPointer}
- className="absolute inset-0 z-0"
- aria-label="Filter by this value"
- />
- )}
-
- <div
- className={cn(
- "relative shrink-0 transition-all duration-200",
- icon ? "size-6" : "h-6 w-0 group-hover:w-6",
- )}
- style={{ zIndex: children ? 10 : undefined }}
- >
- {icon && (
- <div className="flex size-full items-center justify-center transition-all duration-200 group-hover:translate-x-3 group-hover:opacity-0">
- {icon}
- </div>
- )}
- <div className="absolute inset-0 flex items-center justify-center">
- {filterButtonLink}
- </div>
- </div>
-
- {children && (
- <div className="relative min-w-0" style={{ zIndex: 10 }}>
- {children}
- </div>
- )}
- </div>
- );
-}