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.

Stats block filtering (#3592)

Pedro Ladeiraced1a10ca8b5
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 55dbedba17..1b4244b589 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 { FilterButtonTableRow } from "@/ui/shared/filter-button-table-row";
+import { FilterIconCell } from "@/ui/shared/filter-icon-cell";
import SimpleDateRangePicker from "@/ui/shared/simple-date-range-picker";
import {
CrownSmall,
@@ -182,22 +182,21 @@ export default function CommissionsPageClient() {
id: "program",
header: "Program",
cell: ({ row }) => (
- <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"
- />
+ <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"
+ />
+ }
+ >
<span className="text-sm font-medium">{row.original.name}</span>
- </div>
+ </FilterIconCell>
),
- meta: {
- filterParams: ({ row }) => ({
- programId: row.original.id,
- }),
- },
},
{
id: "commissions",
@@ -217,19 +216,6 @@ 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 e975d0258a..49aa75d783 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 { FilterButtonTableRow } from "@/ui/shared/filter-button-table-row";
+import { FilterIconCell } from "@/ui/shared/filter-icon-cell";
import SimpleDateRangePicker from "@/ui/shared/simple-date-range-picker";
import { InvoiceStatus } from "@dub/prisma/client";
import {
@@ -235,24 +235,23 @@ export default function PayoutsPageClient() {
id: "program",
header: "Program",
cell: ({ row }) => (
- <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"
- />
+ <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"
+ />
+ }
+ >
<span className="text-sm font-medium">
{row.original.programName}
</span>
- </div>
+ </FilterIconCell>
),
- meta: {
- filterParams: ({ row }) => ({
- programId: row.original.programId,
- }),
- },
},
{
id: "status",
@@ -261,18 +260,15 @@ export default function PayoutsPageClient() {
const badge = PayoutStatusBadges[row.original.status];
return badge ? (
- <StatusBadge icon={badge.icon} variant={badge.variant}>
- {badge.label}
- </StatusBadge>
+ <FilterIconCell set={{ status: row.original.status }}>
+ <StatusBadge icon={badge.icon} variant={badge.variant}>
+ {badge.label}
+ </StatusBadge>
+ </FilterIconCell>
) : (
"-"
);
},
- meta: {
- filterParams: ({ row }) => ({
- status: row.original.status,
- }),
- },
},
{
id: "amount",
@@ -298,19 +294,6 @@ 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 8d769f4547..60e0422536 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 { FilterButtonTableRow } from "@/ui/shared/filter-button-table-row";
+import { FilterIconCell } from "@/ui/shared/filter-icon-cell";
import {
CopyText,
LinkLogo,
@@ -22,6 +22,7 @@ import {
} from "@dub/ui";
import { CircleDollar, Globe } from "@dub/ui/icons";
import {
+ capitalize,
cn,
COUNTRIES,
currencyFormatter,
@@ -30,16 +31,9 @@ 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();
@@ -93,27 +87,30 @@ export function EarningsTablePartner({ limit }: { limit?: number }) {
id: "type",
header: "Type",
accessorKey: "type",
- meta: {
- filterParams: ({ getValue }) => ({
- type: getValue(),
- }),
- },
- cell: ({ row }) => <CommissionTypeBadge type={row.original.type} />,
+ cell: ({ row }) => (
+ <FilterIconCell
+ set={{ type: row.original.type }}
+ icon={<CommissionTypeIcon type={row.original.type} />}
+ >
+ {capitalize(row.original.type)}
+ </FilterIconCell>
+ ),
},
{
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">
- <LinkLogo
- apexDomain={getApexDomain(row.original.link.url)}
- className="size-4 shrink-0 sm:size-4"
+ <FilterIconCell
+ set={{ linkId: row.original.link.id }}
+ icon={
+ <LinkLogo
+ apexDomain={getApexDomain(row.original.link.url)}
+ className="size-4 shrink-0 sm:size-4"
+ />
+ }
/>
<CopyText
value={row.original.link.shortLink}
@@ -136,26 +133,20 @@ export function EarningsTablePartner({ limit }: { limit?: number }) {
minSize: 250,
cell: ({ row }) =>
row.original.customer ? (
- <CustomerRowItem
- customer={row.original.customer}
- href={
- showDetailedAnalytics
- ? `/programs/${programSlug}/customers/${row.original.customer.id}`
- : undefined
- }
- className="px-4 py-2.5"
- />
+ <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>
) : (
<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")
? [
@@ -257,15 +248,6 @@ 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 cf34e188d8..ce6ef5f7dd 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
@@ -2,8 +2,7 @@ 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 { FilterButtonTableRow } from "@/ui/shared/filter-button-table-row";
-import { Table, usePagination, useTable } from "@dub/ui";
+import { Table, usePagination, useRouterStuff, useTable } from "@dub/ui";
import {
capitalize,
cn,
@@ -12,11 +11,14 @@ import {
fetcher,
nFormatter,
} from "@dub/utils";
+import { useRouter } from "next/navigation";
import { useContext, useMemo } from "react";
import useSWR from "swr";
export function AnalyticsPartnersTable() {
const { selectedTab, queryString } = useContext(AnalyticsContext);
+ const { queryParams } = useRouterStuff();
+ const router = useRouter();
const { pagination, setPagination } = usePagination(10);
@@ -52,22 +54,28 @@ 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;
return (
- <PartnerRowItem
- partner={{
- ...p,
- payoutsEnabledAt: p.payoutsEnabledAt
- ? new Date(p.payoutsEnabledAt)
- : null,
- }}
- />
+ <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>
);
},
- meta: {
- filterParams: ({ row }) => ({
- partnerId: row.original.partnerId,
- }),
- },
},
{
id: "location",
@@ -112,19 +120,6 @@ export function AnalyticsPartnersTable() {
},
]),
],
- cellRight: (cell) => {
- const meta = cell.column.columnDef.meta as
- | {
- filterParams?: any;
- }
- | undefined;
-
- return (
- meta?.filterParams && (
- <FilterButtonTableRow set={meta.filterParams(cell)} />
- )
- );
- },
pagination,
onPaginationChange: setPagination,
sortableColumns: ["clicks", "leads", "saleAmount"],
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 fbecff45aa..a95821fdd2 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 { FilterButtonTableRow } from "@/ui/shared/filter-button-table-row";
+import { FilterIconCell } from "@/ui/shared/filter-icon-cell";
import SimpleDateRangePicker from "@/ui/shared/simple-date-range-picker";
import {
AnimatedSizeContainer,
@@ -32,6 +32,7 @@ import {
} from "@dub/ui";
import { MoneyBill2 } from "@dub/ui/icons";
import {
+ capitalize,
cn,
currencyFormatter,
fetcher,
@@ -164,34 +165,27 @@ export function CommissionsTable() {
maxSize: 250,
cell: ({ row }) =>
row.original.customer ? (
- <CustomerRowItem
- customer={row.original.customer}
- href={`/${slug}/program/customers/${row.original.customer.id}`}
- />
+ <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 }) => {
- return <PartnerRowItem partner={row.original.partner} />;
- },
+ cell: ({ row }) => (
+ <PartnerRowItem
+ filterSet={{ partnerId: row.original.partner.id }}
+ partner={row.original.partner}
+ />
+ ),
maxSize: 200,
- meta: {
- filterParams: ({ row }) => ({
- partnerId: row.original.partner.id,
- }),
- },
},
{
id: "group",
@@ -220,13 +214,13 @@ export function CommissionsTable() {
header: "Type",
accessorKey: "type",
cell: ({ row }) => (
- <CommissionTypeBadge type={row.original.type ?? "sale"} />
+ <FilterIconCell
+ set={{ type: row.original.type }}
+ icon={<CommissionTypeIcon type={row.original.type ?? "sale"} />}
+ >
+ {capitalize(row.original.type ?? "sale")}
+ </FilterIconCell>
),
- meta: {
- filterParams: ({ row }) => ({
- type: row.original.type,
- }),
- },
},
{
id: "amount",
@@ -327,19 +321,6 @@ export function CommissionsTable() {
data: commissions || [],
columns,
columnPinning: { right: ["menu"] },
- cellRight: (cell) => {
- const meta = cell.column.columnDef.meta as
- | {
- filterParams?: any;
- }
- | undefined;
-
- return (
- meta?.filterParams && (
- <FilterButtonTableRow set={meta.filterParams(cell)} />
- )
- );
- },
pagination,
onPaginationChange: setPagination,
columnVisibility,
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 773cf1b02c..dee669ad8c 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 { FilterButtonTableRow } from "@/ui/shared/filter-button-table-row";
+import { FilterIconCell } from "@/ui/shared/filter-icon-cell";
import {
AnimatedSizeContainer,
Badge,
@@ -129,34 +129,26 @@ export function FraudGroupTable() {
if (reason) {
return (
- <div className="flex items-center gap-2">
- <Tooltip content={reason.description}>
- <span
- className={cn(
- "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 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>
);
}
},
- meta: {
- filterParams: ({ row }) => ({
- type: row.original.type,
- }),
- },
},
{
id: "partner",
@@ -168,6 +160,7 @@ export function FraudGroupTable() {
return (
<PartnerRowItem
+ filterSet={{ partnerId: partner.id }}
partner={{
id: partner.id,
name: partner.name || "Unknown",
@@ -178,14 +171,6 @@ export function FraudGroupTable() {
/>
);
},
- meta: {
- filterParams: ({ row }) =>
- row.original.partner
- ? {
- partnerId: row.original.partner.id,
- }
- : {},
- },
},
{
id: "lastEventAt",
@@ -215,19 +200,6 @@ export function FraudGroupTable() {
},
],
columnPinning: { right: ["menu"] },
- cellRight: (cell) => {
- const meta = cell.column.columnDef.meta as
- | {
- filterParams?: any;
- }
- | undefined;
-
- return (
- meta?.filterParams && (
- <FilterButtonTableRow set={meta.filterParams(cell)} />
- )
- );
- },
pagination,
onPaginationChange: setPagination,
sortableColumns: ["createdAt", "type"],
diff --git a/apps/web/ui/analytics/analytics-card.tsx b/apps/web/ui/analytics/analytics-card.tsx
index c87e157aa3..61e4036cef 100644
--- a/apps/web/ui/analytics/analytics-card.tsx
+++ b/apps/web/ui/analytics/analytics-card.tsx
@@ -29,6 +29,8 @@ export function AnalyticsCard<T extends string>({
onSelectSubTab,
expandLimit,
dataLength,
+ isFilterActive,
+ onClearFilter,
children,
className,
}: {
@@ -42,6 +44,8 @@ export function AnalyticsCard<T extends string>({
| ((subTabId: string) => void);
expandLimit: number;
dataLength?: number;
+ isFilterActive?: boolean;
+ onClearFilter?: () => void;
children: (props: {
limit?: number;
event?: EventType;
@@ -178,17 +182,31 @@ export function AnalyticsCard<T extends string>({
setShowModal,
})}
</div>
- {showViewAll && (
+ {/* View All when filtered: modal shows full list (items not on card). */}
+ {(showViewAll || isFilterActive) && (
<div className="absolute bottom-0 left-0 z-10 flex w-full items-end">
<div className="pointer-events-none absolute bottom-0 left-0 h-48 w-full bg-gradient-to-t from-white" />
- <button
- onClick={() => setShowModal(true)}
- className="group relative flex w-full items-center justify-center py-4"
- >
- <div className="rounded-md border border-neutral-200 bg-white px-2.5 py-1 text-sm text-neutral-950 group-hover:bg-neutral-100 group-active:border-neutral-300">
+ <div className="relative flex w-full items-center justify-center gap-2 py-4">
+ <button
+ onClick={() => setShowModal(true)}
+ className={cn(
+ "h-8 w-fit rounded-lg px-3 text-sm transition-colors",
+ isFilterActive
+ ? "text-content-inverted hover:bg-inverted hover:ring-border-subtle border-black bg-black hover:ring-4"
+ : "border border-neutral-200 bg-white text-neutral-950 hover:bg-neutral-100 active:border-neutral-300",
+ )}
+ >
View All
- </div>
- </button>
+ </button>
+ {isFilterActive && onClearFilter && (
+ <button
+ onClick={onClearFilter}
+ className="h-8 w-fit rounded-lg border border-neutral-200 bg-white px-3 text-sm text-neutral-600 transition-colors hover:bg-neutral-50 active:border-neutral-300"
+ >
+ Clear
+ </button>
+ )}
+ </div>
</div>
)}
</div>
diff --git a/apps/web/ui/analytics/bar-list.tsx b/apps/web/ui/analytics/bar-list.tsx
index a7e7d6b96c..f0a050e1f1 100644
--- a/apps/web/ui/analytics/bar-list.tsx
+++ b/apps/web/ui/analytics/bar-list.tsx
@@ -1,19 +1,22 @@
"use client";
import { LinkProps } from "@/lib/types";
-import { Tooltip, useMediaQuery } from "@dub/ui";
+import { Button, Tooltip, useKeyboardShortcut, useMediaQuery } from "@dub/ui";
+import { FilterBars } from "@dub/ui/icons";
import { cn, getPrettyUrl } from "@dub/utils";
import NumberFlow, { NumberFlowGroup } from "@number-flow/react";
import { Search } from "lucide-react";
-import { motion } from "motion/react";
-import Link from "next/link";
+import { AnimatePresence, motion } from "motion/react";
+import { useRouter } from "next/navigation";
import {
ComponentProps,
Dispatch,
memo,
ReactNode,
SetStateAction,
+ useCallback,
useContext,
+ useEffect,
useMemo,
useState,
} from "react";
@@ -26,33 +29,92 @@ export function BarList({
tab,
unit,
data,
+ allData,
barBackground,
hoverBackground,
+ filterSelectedBackground = "bg-neutral-900",
+ filterSelectedHoverBackground,
+ filterHoverClass,
maxValue,
setShowModal,
limit,
+ selectedFilterValues,
+ activeFilterValues,
+ onToggleFilter,
+ onClearFilter,
+ onClearSelection,
+ onApplyFilterValues,
}: {
tab: string;
unit: string;
data: {
icon: ReactNode;
title: string;
+ filterValue?: string;
+ value: number;
+ linkId?: string;
+ /** When set without filter UI (e.g. billing usage modal), row navigates here */
href?: string;
+ }[];
+ allData?: {
+ icon: ReactNode;
+ title: string;
+ filterValue?: string;
value: number;
linkId?: string;
+ href?: string;
}[];
maxValue: number;
barBackground: string;
hoverBackground: string;
+ filterSelectedBackground?: string;
+ filterSelectedHoverBackground?: string;
+ filterHoverClass?: string;
setShowModal: Dispatch<SetStateAction<boolean>>;
limit?: number;
+ selectedFilterValues?: string[];
+ activeFilterValues?: string[];
+ onToggleFilter?: (val: string) => void;
+ onClearFilter?: () => void;
+ onClearSelection?: () => void;
+ onApplyFilterValues?: (values: string[]) => void;
}) {
const [search, setSearch] = useState("");
+ const [modalSelectedValues, setModalSelectedValues] = useState<string[]>(
+ activeFilterValues ?? [],
+ );
+
+ useEffect(() => {
+ if (!limit) {
+ setModalSelectedValues(activeFilterValues ?? []);
+ }
+ }, [activeFilterValues, limit]);
+
+ const handleModalToggle = useCallback((val: string) => {
+ setModalSelectedValues((prev) =>
+ prev.includes(val) ? prev.filter((v) => v !== val) : [...prev, val],
+ );
+ }, []);
+
+ const hasSelection = (selectedFilterValues?.length ?? 0) > 0;
+ const hasModalSelection = modalSelectedValues.length > 0;
+
+ useKeyboardShortcut("Escape", () => onClearSelection?.(), {
+ priority: 2,
+ enabled: hasSelection && !!onClearSelection,
+ });
+
+ // Collapsed card: selection UI is staging-only (new picks before Apply).
+ const effectiveSelectedValues = !limit
+ ? modalSelectedValues
+ : selectedFilterValues;
+
+ const sourceData = !limit && allData ? allData : data;
// Calculate total sum for percentage calculations
const totalSum = useMemo(
- () => data.reduce((sum, item) => sum + item.value, 0),
- [data],
+ () => sourceData.reduce((sum, item) => sum + item.value, 0),
+ [sourceData],
);
// TODO: mock pagination for better perf in React
@@ -61,12 +123,12 @@ export function BarList({
return data.slice(0, limit);
} else {
return search
- ? data.filter((d) =>
+ ? sourceData.filter((d) =>
d.title.toLowerCase().includes(search.toLowerCase()),
)
- : data;
+ : sourceData;
}
- }, [data, limit, search]);
+ }, [data, sourceData, limit, search]);
const { isMobile } = useMediaQuery();
@@ -81,9 +143,54 @@ export function BarList({
setShowModal,
barBackground,
hoverBackground,
+ filterSelectedBackground,
+ filterSelectedHoverBackground,
+ filterHoverClass,
limit,
+ isSelected: data.filterValue
+ ? (effectiveSelectedValues ?? []).includes(data.filterValue)
+ : false,
+ isActivelyFiltered:
+ !!limit &&
+ !!data.filterValue &&
+ (activeFilterValues ?? []).includes(data.filterValue),
+ onFilterClick: data.filterValue
+ ? !limit
+ ? () => handleModalToggle(data.filterValue!)
+ : onToggleFilter
+ ? () => onToggleFilter(data.filterValue!)
+ : undefined
+ : undefined,
}));
+ const filterButtons = hasSelection &&
+ onApplyFilterValues &&
+ onClearFilter && (
+ <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 w-full items-end"
+ >
+ <div className="pointer-events-none absolute bottom-0 left-0 h-48 w-full bg-gradient-to-t from-white" />
+ <div className="relative flex w-full items-center justify-center gap-2 py-4">
+ <Button
+ text="Filter"
+ variant="primary"
+ className="h-8 w-fit rounded-lg px-3 py-2"
+ onClick={() => onApplyFilterValues(selectedFilterValues ?? [])}
+ />
+ <Button
+ text="Clear"
+ variant="secondary"
+ className="h-8 w-fit rounded-lg px-3 py-2"
+ onClick={onClearFilter}
+ />
+ </div>
+ </motion.div>
+ );
+
const bars = (
<NumberFlowGroup>
<div className="relative grid h-full auto-rows-min grid-cols-1">
@@ -111,7 +218,12 @@ export function BarList({
);
if (limit) {
- return bars;
+ return (
+ <>
+ {bars}
+ <AnimatePresence>{filterButtons}</AnimatePresence>
+ </>
+ );
} else {
return (
<>
@@ -127,7 +239,35 @@ export function BarList({
onChange={(e) => setSearch(e.target.value)}
/>
</div>
- <div className="h-[50vh] overflow-auto pb-4 md:h-[40vh]">{bars}</div>
+ <div className="relative">
+ <div className="h-[50vh] overflow-auto pb-4 md:h-[40vh]">{bars}</div>
+ {hasModalSelection && onApplyFilterValues && (
+ <div className="pointer-events-none absolute bottom-0 left-0 right-0 flex h-[130px] items-end justify-center bg-gradient-to-t from-white from-40% to-white/0 pb-4">
+ <div className="pointer-events-auto flex items-center gap-2">
+ <Button
+ text="Filter"
+ variant="primary"
+ className="h-8 w-fit rounded-lg px-3 py-2"
+ onClick={() => {
+ onApplyFilterValues(modalSelectedValues);
+ setShowModal(false);
+ }}
+ />
+
+ <Button
+ text="Clear"
+ variant="secondary"
+ className="h-8 w-fit rounded-lg px-3 py-2"
+ onClick={() => {
+ setModalSelectedValues([]);
+ onClearFilter?.();
+ setShowModal(false);
+ }}
+ />
+ </div>
+ </div>
+ )}
+ </div>
</>
);
}
@@ -136,7 +276,6 @@ export function BarList({
export function LineItem({
icon,
title,
- href,
value,
totalSum,
tab,
@@ -144,12 +283,18 @@ export function LineItem({
setShowModal,
barBackground,
hoverBackground,
+ filterSelectedBackground = "bg-neutral-900",
+ filterSelectedHoverBackground,
+ filterHoverClass,
linkData,
limit,
+ isSelected,
+ isActivelyFiltered,
+ onFilterClick,
+ href,
}: {
icon: ReactNode;
title: string;
- href?: string;
value: number;
totalSum: number;
tab: string;
@@ -157,42 +302,136 @@ export function LineItem({
setShowModal: Dispatch<SetStateAction<boolean>>;
barBackground: string;
hoverBackground: string;
+ filterSelectedBackground?: string;
+ filterSelectedHoverBackground?: string;
+ filterHoverClass?: string;
linkData?: LinkProps;
limit?: number;
+ isSelected?: boolean;
+ isActivelyFiltered?: boolean;
+ onFilterClick?: () => void;
+ href?: string;
}) {
- const lineItem = useMemo(() => {
- return (
- <div className="z-10 flex items-center space-x-4 overflow-hidden px-3">
- {icon}
- <div className="truncate text-sm text-neutral-800">
- {getPrettyUrl(title)}
- </div>
- </div>
- );
- }, [icon, tab, title]);
-
+ const [isHovered, setIsHovered] = useState(false);
+ const [filterButtonHovered, setFilterButtonHovered] = useState(false);
+ const [tooltipResetKey, setTooltipResetKey] = useState(0);
const { saleUnit } = useContext(AnalyticsContext);
+ const router = useRouter();
- const As = href ? Link : "div";
-
- // Calculate percentage against total sum and round to 1 decimal
const percentage = Math.round((value / totalSum) * 1000) / 10;
-
- // Check if we're in modal view - if limit is undefined, we're in the modal view
const isModalView = !limit;
+ const lineItem = (
+ <div className="z-10 flex items-center space-x-4 overflow-hidden px-3">
+ {onFilterClick ? (
+ <button
+ onClick={(e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ if (!isActivelyFiltered) onFilterClick();
+ }}
+ onMouseEnter={() => {
+ setFilterButtonHovered(true);
+ setTooltipResetKey((k) => k + 1);
+ }}
+ onMouseLeave={() => setFilterButtonHovered(false)}
+ aria-label={`${isSelected ? "Remove" : "Add"} filter: ${title}`}
+ aria-pressed={isSelected}
+ className="relative size-6 shrink-0 cursor-pointer"
+ >
+ <div
+ className={cn(
+ "flex size-full items-center justify-center transition-all duration-200",
+ isSelected || isHovered ? "translate-x-3 opacity-0" : "",
+ )}
+ >
+ {icon}
+ </div>
+ <div
+ className={cn(
+ "absolute inset-0 flex items-center justify-center rounded-lg transition-all duration-200",
+ isSelected
+ ? cn(
+ "translate-x-0 opacity-100",
+ filterSelectedBackground,
+ filterSelectedHoverBackground,
+ )
+ : isHovered
+ ? cn(
+ "translate-x-0 opacity-100",
+ isActivelyFiltered
+ ? cn(
+ filterSelectedBackground,
+ filterSelectedHoverBackground,
+ )
+ : filterHoverClass,
+ )
+ : "-translate-x-3 opacity-0",
+ )}
+ >
+ <FilterBars
+ className={cn(
+ "size-3",
+ isSelected || isActivelyFiltered
+ ? "text-white"
+ : "text-neutral-500",
+ )}
+ />
+ </div>
+ </button>
+ ) : (
+ <div className="flex size-6 shrink-0 items-center justify-center">
+ {icon}
+ </div>
+ )}
+ {tab === "links" && linkData ? (
+ <Tooltip
+ key={tooltipResetKey}
+ content={<LinkPreviewTooltip data={linkData} />}
+ disabled={filterButtonHovered}
+ >
+ <div className="truncate text-sm text-neutral-800">
+ {getPrettyUrl(title)}
+ </div>
+ </Tooltip>
+ ) : tab === "urls" ? (
+ <Tooltip
+ key={tooltipResetKey}
+ content={`[${title}](${title})`}
+ contentClassName="max-w-lg"
+ disabled={filterButtonHovered}
+ >
+ <div className="truncate text-sm text-neutral-800">
+ {getPrettyUrl(title)}
+ </div>
+ </Tooltip>
+ ) : (
+ <div className="truncate text-sm text-neutral-800">
+ {getPrettyUrl(title)}
+ </div>
+ )}
+ </div>
+ );
+
+ const rowClickable =
+ (onFilterClick && !isActivelyFiltered) || (!!href && !onFilterClick);
+
return (
- // @ts-ignore - we know if it's a Link it'll get its href
- <As
- {...(href && {
- href,
- scroll: false,
- onClick: () => setShowModal(false),
- })}
+ <div
+ onMouseEnter={() => setIsHovered(true)}
+ onMouseLeave={() => setIsHovered(false)}
+ onClick={() => {
+ if (onFilterClick && !isActivelyFiltered) {
+ onFilterClick();
+ } else if (href && !onFilterClick) {
+ router.push(href);
+ setShowModal(false);
+ }
+ }}
className={cn(
- `block min-w-0 border-l-2 border-transparent px-4 py-1 transition-all`,
- href && hoverBackground,
- isModalView ? "group" : "",
+ "group block min-w-0 border-l-2 border-transparent px-4 py-1 transition-all",
+ rowClickable && "cursor-pointer",
+ hoverBackground,
)}
>
<div
@@ -213,20 +452,7 @@ export function LineItem({
animate={{ transform: "scaleX(1)" }}
/>
<div className="relative z-10 flex h-8 w-full min-w-0 max-w-[calc(100%-2rem)] items-center transition-[max-width] duration-300 ease-in-out group-hover:max-w-[calc(100%-5rem)]">
- {tab === "links" && linkData ? (
- <Tooltip content={<LinkPreviewTooltip data={linkData} />}>
- {lineItem}
- </Tooltip>
- ) : tab === "urls" ? (
- <Tooltip
- content={`[${title}](${title})`}
- contentClassName="max-w-lg"
- >
- {lineItem}
- </Tooltip>
- ) : (
- lineItem
- )}
+ {lineItem}
</div>
<div className="z-10 flex items-center">
<NumberFlow
@@ -270,7 +496,7 @@ export function LineItem({
</div>
</div>
</div>
- </As>
+ </div>
);
}
diff --git a/apps/web/ui/analytics/device-section.tsx b/apps/web/ui/analytics/device-section.tsx
index f7b6aae744..fd613b4dae 100644
--- a/apps/web/ui/analytics/device-section.tsx
+++ b/apps/web/ui/analytics/device-section.tsx
@@ -2,7 +2,7 @@ import { SINGULAR_ANALYTICS_ENDPOINTS } from "@/lib/analytics/constants";
import { DeviceTabs } from "@/lib/analytics/types";
import { useRouterStuff } from "@dub/ui";
import { Cube, CursorRays, MobilePhone, Window } from "@dub/ui/icons";
-import { useContext, useState } from "react";
+import { useCallback, useContext, useEffect, useMemo, useState } from "react";
import { AnalyticsCard } from "./analytics-card";
import { AnalyticsLoadingSpinner } from "./analytics-loading-spinner";
import { AnalyticsContext } from "./analytics-provider";
@@ -19,8 +19,46 @@ export function DeviceSection() {
const [tab, setTab] = useState<DeviceTabs>("devices");
const { data } = useAnalyticsFilterOption(tab);
+ const { data: allData } = useAnalyticsFilterOption(tab, {
+ omitGroupByFilterKey: true,
+ });
const singularTabName = SINGULAR_ANALYTICS_ENDPOINTS[tab];
+ const [selectedItems, setSelectedItems] = useState<string[]>([]);
+
+ useEffect(() => {
+ setSelectedItems([]);
+ }, [tab]);
+
+ const onToggleFilter = useCallback((val: string) => {
+ setSelectedItems((prev) =>
+ prev.includes(val) ? prev.filter((v) => v !== val) : [...prev, val],
+ );
+ }, []);
+
+ const onApplyFilterValues = useCallback(
+ (values: string[]) => {
+ if (values.length === 0) {
+ queryParams({ del: singularTabName });
+ } else {
+ queryParams({ set: { [singularTabName]: values.join(",") } });
+ }
+ setSelectedItems([]);
+ },
+ [singularTabName, queryParams],
+ );
+
+ const isFilterActive = searchParams.has(singularTabName);
+ const activeFilterValues = useMemo(
+ () => searchParams.get(singularTabName)?.split(",") ?? [],
+ [singularTabName, searchParams],
+ );
+
+ const onClearFilter = useCallback(() => {
+ setSelectedItems([]);
+ if (isFilterActive) queryParams({ del: singularTabName });
+ }, [singularTabName, queryParams, isFilterActive]);
+
return (
<AnalyticsCard
tabs={[
@@ -33,6 +71,8 @@ export function DeviceSection() {
onSelectTab={setTab}
expandLimit={8}
dataLength={data?.length}
+ isFilterActive={isFilterActive}
+ onClearFilter={onClearFilter}
>
{({ limit, setShowModal }) =>
data ? (
@@ -53,25 +93,42 @@ export function DeviceSection() {
tab === "triggers"
? TRIGGER_DISPLAY[d.trigger].title
: d[singularTabName],
- href: queryParams({
- ...(searchParams.has(singularTabName)
- ? { del: singularTabName }
- : {
- set: {
- [singularTabName]: d[singularTabName],
- },
- }),
- getNewPath: true,
- }) as string,
+ filterValue: d[singularTabName],
value: d[dataKey] || 0,
}))
?.sort((a, b) => b.value - a.value) || []
}
+ allData={allData
+ ?.map((d) => ({
+ icon: (
+ <DeviceIcon
+ display={d[singularTabName]}
+ tab={tab}
+ className="h-4 w-4"
+ />
+ ),
+ title:
+ tab === "triggers"
+ ? TRIGGER_DISPLAY[d.trigger].title
+ : d[singularTabName],
+ filterValue: d[singularTabName],
+ value: d[dataKey] || 0,
+ }))
+ ?.sort((a, b) => b.value - a.value)}
unit={selectedTab}
- maxValue={Math.max(...data?.map((d) => d[dataKey] ?? 0)) ?? 0}
+ maxValue={Math.max(...data.map((d) => d[dataKey] ?? 0)) ?? 0}
barBackground="bg-green-100"
hoverBackground="hover:bg-gradient-to-r hover:from-green-50 hover:to-transparent hover:border-green-500"
+ filterSelectedBackground="bg-green-600"
+ filterSelectedHoverBackground="hover:bg-green-700"
+ filterHoverClass="bg-white border border-green-200"
setShowModal={setShowModal}
+ selectedFilterValues={selectedItems}
+ activeFilterValues={activeFilterValues}
+ onToggleFilter={onToggleFilter}
+ onClearFilter={onClearFilter}
+ onClearSelection={() => setSelectedItems([])}
+ onApplyFilterValues={onApplyFilterValues}
{...(limit && { limit })}
/>
) : (
diff --git a/apps/web/ui/analytics/events/events-table.tsx b/apps/web/ui/analytics/events/events-table.tsx
index 80b2bee974..d66ac02a41 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 { FilterButtonTableRow } from "@/ui/shared/filter-button-table-row";
+import { FilterIconCell } from "@/ui/shared/filter-icon-cell";
import {
CopyText,
EditColumnsButton,
@@ -25,14 +25,13 @@ import {
COUNTRIES,
REGIONS,
capitalize,
- cn,
currencyFormatter,
fetcher,
formatDateTimeSmart,
getApexDomain,
getPrettyUrl,
} from "@dub/utils";
-import { Cell, ColumnDef } from "@tanstack/react-table";
+import { ColumnDef } from "@tanstack/react-table";
import { Link2 } from "lucide-react";
import Link from "next/link";
import { useParams } from "next/navigation";
@@ -131,12 +130,6 @@ 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,
@@ -227,20 +220,17 @@ 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 (
- <div className="flex items-center gap-3">
- <Icon className="size-4 shrink-0" />
+ <FilterIconCell
+ set={{ trigger: getValue() ?? "link" }}
+ icon={<Icon className="size-4 shrink-0" />}
+ >
<span className="truncate" title={title}>
{title}
</span>
- </div>
+ </FilterIconCell>
);
},
},
@@ -265,21 +255,21 @@ export default function EventsTable({
minSize: 300,
size: 300,
maxSize: 400,
- cell: ({ getValue }) => (
- <CustomerRowItem
- customer={getValue()}
- href={
- partnerPage
- ? `/programs/${programSlug}/customers/${getValue().id}`
- : `/${slug}/customers/${getValue().id}`
- }
- className="px-4 py-2.5"
- />
- ),
- meta: {
- filterParams: ({ getValue }) => ({
- customerId: getValue().id,
- }),
+ 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>
+ );
},
},
{
@@ -330,40 +320,37 @@ export default function EventsTable({
minSize: 250,
size: 250,
maxSize: 400,
- meta: {
- filterParams: ({ getValue }) => ({
- linkId: getValue().id,
- }),
- },
cell: ({ getValue }) => {
- 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"
+ 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"
+ />
+ }
/>
- <span className="truncate" title={shortLinkTitle(getValue())}>
- {getPrettyUrl(shortLinkTitle(getValue()))}
- </span>
+ {partnerPage ? (
+ text
+ ) : (
+ <Link
+ href={`/${slug}/links/${link.domain}/${link.key}`}
+ target="_blank"
+ className="cursor-alias truncate decoration-dotted hover:underline"
+ >
+ {text}
+ </Link>
+ )}
</div>
);
-
- return partnerPage ? (
- content
- ) : (
- <Link
- href={`/${slug}/links/${getValue().domain}/${getValue().key}`}
- target="_blank"
- >
- {content}
- </Link>
- );
},
},
{
@@ -372,14 +359,16 @@ 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">
- <LinkLogo
- apexDomain={getApexDomain(getValue())}
- className="size-4 shrink-0 sm:size-4"
+ <FilterIconCell
+ set={{ url: getValue() }}
+ icon={
+ <LinkLogo
+ apexDomain={getApexDomain(getValue())}
+ className="size-4 shrink-0 sm:size-4"
+ />
+ }
/>
<CopyText
value={getValue()}
@@ -396,45 +385,47 @@ export default function EventsTable({
id: "referer",
header: "Referrer",
accessorKey: "click.referer",
- meta: {
- filterParams: ({ getValue }) => ({ referer: getValue() }),
- },
cell: ({ getValue }) => (
- <div className="flex items-center gap-3" title={getValue()}>
- {getValue() === "(direct)" ? (
- <Link2 className="h-4 w-4" />
- ) : (
- <LinkLogo
- apexDomain={getValue()}
- className="size-4 shrink-0 sm:size-4"
- />
- )}
+ <FilterIconCell
+ set={{ referer: getValue() }}
+ icon={
+ 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>
- </div>
+ </FilterIconCell>
),
},
{
id: "refererUrl",
header: "Referrer URL",
accessorKey: "click.refererUrl",
- meta: {
- filterParams: ({ getValue }) => ({ refererUrl: getValue() }),
- },
cell: ({ getValue }) => (
- <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"
- />
- )}
+ <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"
+ />
+ )
+ }
+ >
<CopyText
value={getValue()}
successMessage="Copied referrer URL to clipboard!"
@@ -443,119 +434,123 @@ export default function EventsTable({
{getPrettyUrl(getValue())}
</span>
</CopyText>
- </div>
+ </FilterIconCell>
),
},
{
id: "country",
header: "Country",
accessorKey: "click.country",
- meta: {
- filterParams: ({ getValue }) => ({ country: getValue() }),
- },
cell: ({ getValue }) => (
- <div
- className="flex items-center gap-3"
- title={COUNTRIES[getValue()] ?? 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"
+ />
+ )
+ }
>
- {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">
+ <span className="truncate" title={COUNTRIES[getValue()] ?? getValue()}>
{COUNTRIES[getValue()] ?? getValue()}
</span>
- </div>
+ </FilterIconCell>
),
},
{
id: "city",
header: "City",
accessorKey: "click.city",
- meta: {
- filterParams: ({ getValue }) => ({ city: getValue() }),
- },
minSize: 160,
cell: ({ getValue, row }) => (
- <div className="flex items-center gap-3" title={getValue()}>
- {!row.original.country || row.original.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`}
- className="size-4 shrink-0"
- />
- )}
- <span className="truncate">{getValue()}</span>
- </div>
+ <FilterIconCell
+ set={{ city: getValue() }}
+ icon={
+ !row.original.country ||
+ row.original.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`}
+ className="size-4 shrink-0"
+ />
+ )
+ }
+ >
+ <span className="truncate" title={getValue()}>{getValue()}</span>
+ </FilterIconCell>
),
},
{
id: "region",
header: "Region",
accessorKey: "click.region",
- meta: {
- filterParams: ({ getValue }) => ({ region: getValue() }),
- },
minSize: 160,
cell: ({ getValue, row }) => (
- <div className="flex items-center gap-3" title={getValue()}>
- {!row.original.country || row.original.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`}
- className="size-4 shrink-0"
- />
- )}
- <span className="truncate">
+ <FilterIconCell
+ set={{ region: getValue() }}
+ icon={
+ !row.original.country ||
+ row.original.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`}
+ className="size-4 shrink-0"
+ />
+ )
+ }
+ >
+ <span className="truncate" title={getValue()}>
{REGIONS[getValue()] || getValue().split("-")[1]}
</span>
- </div>
+ </FilterIconCell>
),
},
{
id: "continent",
header: "Continent",
accessorKey: "click.continent",
- meta: {
- filterParams: ({ getValue }) => ({ continent: getValue() }),
- },
cell: ({ getValue }) => (
- <div
- className="flex items-center gap-3"
- title={CONTINENTS[getValue()] ?? "Unknown"}
+ <FilterIconCell
+ set={{ continent: getValue() }}
+ icon={
+ <ContinentIcon display={getValue()} className="size-4 shrink-0" />
+ }
>
- <ContinentIcon display={getValue()} className="size-4 shrink-0" />
- <span className="truncate">
+ <span
+ className="truncate"
+ title={CONTINENTS[getValue()] ?? "Unknown"}
+ >
{CONTINENTS[getValue()] ?? "Unknown"}
</span>
- </div>
+ </FilterIconCell>
),
},
{
id: "device",
header: "Device",
accessorKey: "click.device",
- meta: {
- filterParams: ({ getValue }) => ({ device: getValue() }),
- },
cell: ({ getValue }) => (
- <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>
+ <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>
),
},
{
@@ -767,17 +762,6 @@ 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/analytics/location-section.tsx b/apps/web/ui/analytics/location-section.tsx
index 709cddf37f..e29da4b3d2 100644
--- a/apps/web/ui/analytics/location-section.tsx
+++ b/apps/web/ui/analytics/location-section.tsx
@@ -7,7 +7,7 @@ import {
OfficeBuilding,
} from "@dub/ui/icons";
import { CONTINENTS, COUNTRIES, REGIONS } from "@dub/utils";
-import { useContext, useState } from "react";
+import { useCallback, useContext, useEffect, useMemo, useState } from "react";
import { AnalyticsCard } from "./analytics-card";
import { AnalyticsLoadingSpinner } from "./analytics-loading-spinner";
import { AnalyticsContext } from "./analytics-provider";
@@ -26,8 +26,46 @@ export function LocationSection() {
>("countries");
const { data } = useAnalyticsFilterOption(tab);
+ const { data: allData } = useAnalyticsFilterOption(tab, {
+ omitGroupByFilterKey: true,
+ });
const singularTabName = SINGULAR_ANALYTICS_ENDPOINTS[tab];
+ const [selectedItems, setSelectedItems] = useState<string[]>([]);
+
+ useEffect(() => {
+ setSelectedItems([]);
+ }, [tab]);
+
+ const onToggleFilter = useCallback((val: string) => {
+ setSelectedItems((prev) =>
+ prev.includes(val) ? prev.filter((v) => v !== val) : [...prev, val],
+ );
+ }, []);
+
+ const onApplyFilterValues = useCallback(
+ (values: string[]) => {
+ if (values.length === 0) {
+ queryParams({ del: singularTabName });
+ } else {
+ queryParams({ set: { [singularTabName]: values.join(",") } });
+ }
+ setSelectedItems([]);
+ },
+ [singularTabName, queryParams],
+ );
+
+ const isFilterActive = searchParams.has(singularTabName);
+ const activeFilterValues = useMemo(
+ () => searchParams.get(singularTabName)?.split(",") ?? [],
+ [singularTabName, searchParams],
+ );
+
+ const onClearFilter = useCallback(() => {
+ setSelectedItems([]);
+ if (isFilterActive) queryParams({ del: singularTabName });
+ }, [singularTabName, queryParams, isFilterActive]);
+
return (
<AnalyticsCard
tabs={[
@@ -40,6 +78,8 @@ export function LocationSection() {
onSelectTab={setTab}
expandLimit={8}
dataLength={data?.length}
+ isFilterActive={isFilterActive}
+ onClearFilter={onClearFilter}
>
{({ limit, setShowModal }) =>
data ? (
@@ -73,25 +113,55 @@ export function LocationSection() {
? COUNTRIES[d.country]
: d.region.split("-")[1])
}`,
- href: queryParams({
- ...(searchParams.has(singularTabName)
- ? { del: singularTabName }
- : {
- set: {
- [singularTabName]: d[singularTabName],
- },
- }),
- getNewPath: true,
- }) as string,
+ filterValue: d[singularTabName],
value: d[dataKey] || 0,
}))
?.sort((a, b) => b.value - a.value) || []
}
+ allData={allData
+ ?.map((d) => ({
+ icon:
+ tab === "continents" ? (
+ <ContinentIcon
+ display={d.continent}
+ className="size-4 rounded-full border border-cyan-500"
+ />
+ ) : (
+ <img
+ alt={d.country}
+ src={`https://hatscripts.github.io/circle-flags/flags/${d.country.toLowerCase()}.svg`}
+ className="size-4 shrink-0"
+ />
+ ),
+ title:
+ tab === "continents"
+ ? CONTINENTS[d.continent]
+ : tab === "countries"
+ ? COUNTRIES[d.country]
+ : `${tab === "cities" ? `${d.city}, ` : ""}${
+ REGIONS[d.region] ||
+ (d.region.endsWith("-Unknown")
+ ? COUNTRIES[d.country]
+ : d.region.split("-")[1])
+ }`,
+ filterValue: d[singularTabName],
+ value: d[dataKey] || 0,
+ }))
+ ?.sort((a, b) => b.value - a.value)}
unit={selectedTab}
- maxValue={Math.max(...data?.map((d) => d[dataKey] ?? 0)) ?? 0}
+ maxValue={Math.max(...data.map((d) => d[dataKey] ?? 0)) ?? 0}
barBackground="bg-blue-100"
hoverBackground="hover:bg-gradient-to-r hover:from-blue-50 hover:to-transparent hover:border-blue-500"
+ filterSelectedBackground="bg-blue-600"
+ filterSelectedHoverBackground="hover:bg-blue-700"
+ filterHoverClass="bg-white border border-blue-200"
setShowModal={setShowModal}
+ selectedFilterValues={selectedItems}
+ activeFilterValues={activeFilterValues}
+ onToggleFilter={onToggleFilter}
+ onClearFilter={onClearFilter}
+ onClearSelection={() => setSelectedItems([])}
+ onApplyFilterValues={onApplyFilterValues}
{...(limit && { limit })}
/>
) : (
diff --git a/apps/web/ui/analytics/partner-section.tsx b/apps/web/ui/analytics/partner-section.tsx
index d787a64fda..78aabef2c5 100644
--- a/apps/web/ui/analytics/partner-section.tsx
+++ b/apps/web/ui/analytics/partner-section.tsx
@@ -3,7 +3,7 @@ import { useWorkspacePreferences } from "@/lib/swr/use-workspace-preferences";
import { LinkLogo, useRouterStuff } from "@dub/ui";
import { Hyperlink, Users6 } from "@dub/ui/icons";
import { getApexDomain } from "@dub/utils";
-import { useCallback, useContext, useMemo, useState } from "react";
+import { useCallback, useContext, useEffect, useMemo, useState } from "react";
import TagBadge from "../links/tag-badge";
import { GroupColorCircle } from "../partners/groups/group-color-circle";
import { AnalyticsCard } from "./analytics-card";
@@ -63,6 +63,7 @@ export function PartnerSection() {
const [tab, setTab] = useState<TabId>("segments");
const [subtab, setSubtab] = useState<Subtab>(TAB_CONFIG[tab].defaultSubtab);
+ const [selectedItems, setSelectedItems] = useState<string[]>([]);
// Reset subtab when tab changes to ensure it's valid for the new tab
const handleTabChange = (newTab: TabId) => {
@@ -70,12 +71,70 @@ export function PartnerSection() {
setSubtab(TAB_CONFIG[newTab].defaultSubtab);
};
+ useEffect(() => {
+ setSelectedItems([]);
+ }, [tab, subtab]);
+
+ const isFilterActive = useMemo(() => {
+ if (subtab === "groups") return searchParams.has("groupId");
+ if (subtab === "tags") return searchParams.has("tagId");
+ if (subtab === "short_links") return searchParams.has("linkId");
+ if (subtab === "destination_urls") return searchParams.has("url");
+ return false;
+ }, [subtab, searchParams]);
+
+ const activeFilterValues = useMemo(() => {
+ if (subtab === "groups")
+ return searchParams.get("groupId")?.split(",") ?? [];
+ if (subtab === "tags") return searchParams.get("tagId")?.split(",") ?? [];
+ if (subtab === "short_links")
+ return searchParams.get("linkId")?.split(",") ?? [];
+ if (subtab === "destination_urls")
+ return searchParams.get("url")?.split(",") ?? [];
+ return [];
+ }, [subtab, searchParams]);
+
+ const filterParamKey = useMemo(() => {
+ if (subtab === "groups") return "groupId";
+ if (subtab === "tags") return "tagId";
+ if (subtab === "short_links") return "linkId";
+ if (subtab === "destination_urls") return "url";
+ return null;
+ }, [subtab]);
+
+ const onToggleFilter = useCallback((val: string) => {
+ setSelectedItems((prev) =>
+ prev.includes(val) ? prev.filter((v) => v !== val) : [...prev, val],
+ );
+ }, []);
+
+ const onApplyFilterValues = useCallback(
+ (values: string[]) => {
+ if (!filterParamKey) return;
+ if (values.length === 0) {
+ queryParams({ del: filterParamKey });
+ } else {
+ queryParams({ set: { [filterParamKey]: values.join(",") } });
+ }
+ setSelectedItems([]);
+ },
+ [filterParamKey, queryParams],
+ );
+
+ const onClearFilter = useCallback(() => {
+ setSelectedItems([]);
+ if (isFilterActive && filterParamKey) queryParams({ del: filterParamKey });
+ }, [filterParamKey, queryParams, isFilterActive]);
+
const groupByParams = useMemo(
() => TAB_CONFIG[tab].getGroupBy(subtab),
[tab, subtab],
);
const { data } = useAnalyticsFilterOption(groupByParams);
+ const { data: allData } = useAnalyticsFilterOption(groupByParams, {
+ omitGroupByFilterKey: true,
+ });
const [persisted] = useWorkspacePreferences("linksDisplay");
@@ -106,6 +165,49 @@ export function PartnerSection() {
[persisted, tab, subtab],
);
+ const mapItem = useCallback(
+ (d: Record<string, any>) => {
+ const isSegmentsTab = tab === "segments";
+ const isLinksTab = tab === "links";
+ const isGroupsSubtab = isSegmentsTab && subtab === "groups";
+ const isTagsSubtab = isSegmentsTab && subtab === "tags";
+ const isShortLinksSubtab = isLinksTab && subtab === "short_links";
+ const isDestinationUrlsSubtab =
+ isLinksTab && subtab === "destination_urls";
+
+ let icon;
+ if (isGroupsSubtab) {
+ icon = d.group ? <GroupColorCircle group={d.group} /> : null;
+ } else if (isTagsSubtab) {
+ icon = d.tag ? (
+ <TagBadge color={d.tag.color} withIcon className="sm:p-1" />
+ ) : null;
+ } else {
+ icon = (
+ <LinkLogo
+ apexDomain={getApexDomain(d.url || "")}
+ className="size-5 sm:size-5"
+ />
+ );
+ }
+
+ let filterValue: string | undefined;
+ if (isGroupsSubtab) filterValue = d.groupId;
+ else if (isTagsSubtab) filterValue = d.tagId;
+ else if (isShortLinksSubtab) filterValue = d.id;
+ else if (isDestinationUrlsSubtab) filterValue = d.url;
+
+ return {
+ icon,
+ title: getItemTitle(d),
+ filterValue,
+ value: d[dataKey] || 0,
+ ...(isShortLinksSubtab && { linkData: d }),
+ };
+ },
+ [tab, subtab, dataKey, getItemTitle],
+ );
+
const subTabProps = useMemo(() => {
if (adminPage || partnerPage) return {};
const config = TAB_CONFIG[tab];
@@ -127,6 +229,8 @@ export function PartnerSection() {
]}
expandLimit={8}
dataLength={data?.length}
+ isFilterActive={isFilterActive}
+ onClearFilter={onClearFilter}
selectedTabId={tab}
onSelectTab={handleTabChange}
{...subTabProps}
@@ -136,110 +240,24 @@ export function PartnerSection() {
data.length > 0 ? (
<BarList
tab={tab}
- data={
- data
- ?.map((d) => {
- const isSegmentsTab = tab === "segments";
- const isLinksTab = tab === "links";
- const isGroupsSubtab = isSegmentsTab && subtab === "groups";
- const isTagsSubtab = isSegmentsTab && subtab === "tags";
- const isShortLinksSubtab =
- isLinksTab && subtab === "short_links";
- const isDestinationUrlsSubtab =
- isLinksTab && subtab === "destination_urls";
-
- // Determine icon
- let icon;
- if (isGroupsSubtab) {
- icon = d.group ? (
- <GroupColorCircle group={d.group} />
- ) : null;
- } else if (isTagsSubtab) {
- icon = d.tag ? (
- <TagBadge
- color={d.tag.color}
- withIcon
- className="sm:p-1"
- />
- ) : null;
- } else {
- icon = (
- <LinkLogo
- apexDomain={getApexDomain(d.url || "")}
- className="size-5 sm:size-5"
- />
- );
- }
-
- // Determine href
- let href: string | undefined;
- if (isShortLinksSubtab) {
- const hasLinkFilter =
- searchParams.has("domain") && searchParams.has("key");
- href = queryParams({
- ...(hasLinkFilter
- ? { del: ["domain", "key"] }
- : {
- set: {
- domain: d.domain,
- key: d.key || "_root",
- },
- }),
- getNewPath: true,
- }) as string;
- } else if (isDestinationUrlsSubtab) {
- const hasUrlFilter = searchParams.has("url");
- href = queryParams({
- ...(hasUrlFilter
- ? { del: "url" }
- : {
- set: {
- url: d.url,
- },
- }),
- getNewPath: true,
- }) as string;
- } else if (isGroupsSubtab) {
- const hasGroupFilter = searchParams.has("groupId");
- href = queryParams({
- ...(hasGroupFilter
- ? { del: "groupId" }
- : {
- set: {
- groupId: d.groupId,
- },
- }),
- getNewPath: true,
- }) as string;
- } else if (isTagsSubtab) {
- const hasTagFilter = searchParams.has("tagId");
- href = queryParams({
- ...(hasTagFilter
- ? { del: "tagId" }
- : {
- set: {
- tagId: d.tagId,
- },
- }),
- getNewPath: true,
- }) as string;
- }
-
- return {
- icon,
- title: getItemTitle(d),
- href,
- value: d[dataKey] || 0,
- ...(isShortLinksSubtab && { linkData: d }),
- };
- })
- ?.sort((a, b) => b.value - a.value) || []
- }
+ data={data.map(mapItem).sort((a, b) => b.value - a.value)}
+ allData={allData?.map(mapItem).sort((a, b) => b.value - a.value)}
unit={selectedTab}
- maxValue={Math.max(...data?.map((d) => d[dataKey] ?? 0)) ?? 0}
+ maxValue={Math.max(...data.map((d) => d[dataKey] ?? 0))}
barBackground="bg-orange-100"
hoverBackground="hover:bg-gradient-to-r hover:from-orange-50 hover:to-transparent hover:border-orange-500"
+ filterSelectedBackground="bg-orange-500"
+ filterSelectedHoverBackground="hover:bg-orange-600"
+ filterHoverClass="bg-white border border-orange-200"
setShowModal={setShowModal}
+ selectedFilterValues={selectedItems}
+ activeFilterValues={activeFilterValues}
+ onToggleFilter={onToggleFilter}
+ onClearFilter={onClearFilter}
+ onClearSelection={() => setSelectedItems([])}
+ onApplyFilterValues={
+ filterParamKey ? onApplyFilterValues : undefined
+ }
{...(limit && { limit })}
/>
) : (
diff --git a/apps/web/ui/analytics/referrers-utms.tsx b/apps/web/ui/analytics/referrers-utms.tsx
index f1f5eb5eb3..6677c8bcb1 100644
--- a/apps/web/ui/analytics/referrers-utms.tsx
+++ b/apps/web/ui/analytics/referrers-utms.tsx
@@ -4,7 +4,7 @@ import { BlurImage, useRouterStuff, UTM_PARAMETERS } from "@dub/ui";
import { Note, ReferredVia } from "@dub/ui/icons";
import { getApexDomain, GOOGLE_FAVICON_URL } from "@dub/utils";
import { Link2 } from "lucide-react";
-import { useContext, useMemo, useState } from "react";
+import { useCallback, useContext, useEffect, useMemo, useState } from "react";
import { AnalyticsCard } from "./analytics-card";
import { AnalyticsLoadingSpinner } from "./analytics-loading-spinner";
import { AnalyticsContext } from "./analytics-provider";
@@ -47,6 +47,7 @@ export function ReferrersUTMs() {
const [tab, setTab] = useState<TabId>("referers");
const [subtab, setSubtab] = useState<Subtab>(TAB_CONFIG[tab].defaultSubtab);
+ const [selectedItems, setSelectedItems] = useState<string[]>([]);
// Reset subtab when tab changes to ensure it's valid for the new tab
const handleTabChange = (newTab: TabId) => {
@@ -57,9 +58,46 @@ export function ReferrersUTMs() {
const { data } = useAnalyticsFilterOption({
groupBy: subtab,
});
+ const { data: allData } = useAnalyticsFilterOption(
+ { groupBy: subtab },
+ { omitGroupByFilterKey: true },
+ );
const singularTabName = SINGULAR_ANALYTICS_ENDPOINTS[subtab];
+ useEffect(() => {
+ setSelectedItems([]);
+ }, [tab, subtab]);
+
+ const onToggleFilter = useCallback((val: string) => {
+ setSelectedItems((prev) =>
+ prev.includes(val) ? prev.filter((v) => v !== val) : [...prev, val],
+ );
+ }, []);
+
+ const onApplyFilterValues = useCallback(
+ (values: string[]) => {
+ if (values.length === 0) {
+ queryParams({ del: singularTabName });
+ } else {
+ queryParams({ set: { [singularTabName]: values.join(",") } });
+ }
+ setSelectedItems([]);
+ },
+ [singularTabName, queryParams],
+ );
+
+ const isFilterActive = searchParams.has(singularTabName);
+ const activeFilterValues = useMemo(
+ () => searchParams.get(singularTabName)?.split(",") ?? [],
+ [singularTabName, searchParams],
+ );
+
+ const onClearFilter = useCallback(() => {
+ setSelectedItems([]);
+ if (isFilterActive) queryParams({ del: singularTabName });
+ }, [singularTabName, queryParams, isFilterActive]);
+
const UTMTagIcon = useMemo(() => {
if (tab === "utms") {
return UTM_PARAMETERS.find(
@@ -92,6 +130,8 @@ export function ReferrersUTMs() {
{...subTabProps}
expandLimit={8}
dataLength={data?.length}
+ isFilterActive={isFilterActive}
+ onClearFilter={onClearFilter}
>
{({ limit, setShowModal }) => (
<>
@@ -126,26 +166,56 @@ export function ReferrersUTMs() {
/>
),
title: d[singularTabName],
- href: queryParams({
- ...(searchParams.has(singularTabName)
- ? { del: singularTabName }
- : {
- set: {
- [singularTabName]: d[singularTabName],
- },
- }),
- getNewPath: true,
- }) as string,
+ filterValue: d[singularTabName],
value: d[dataKey] || 0,
};
})
?.sort((a, b) => b.value - a.value) || []
}
+ allData={allData
+ ?.map((d) => {
+ const isUtmTab = tab === "utms";
+ const isDirect = d[singularTabName] === "(direct)";
+ const isRefererUrl = subtab === "referer_urls";
+ return {
+ icon:
+ isUtmTab && UTMTagIcon ? (
+ <UTMTagIcon />
+ ) : isDirect ? (
+ <Link2 className="h-4 w-4" />
+ ) : (
+ <BlurImage
+ src={`${GOOGLE_FAVICON_URL}${
+ isRefererUrl
+ ? getApexDomain(d[singularTabName])
+ : d[singularTabName]
+ }`}
+ alt={d[singularTabName]}
+ width={20}
+ height={20}
+ className="h-4 w-4 rounded-full"
+ />
+ ),
+ title: d[singularTabName],
+ filterValue: d[singularTabName],
+ value: d[dataKey] || 0,
+ };
+ })
+ ?.sort((a, b) => b.value - a.value)}
unit={selectedTab}
- maxValue={Math.max(...data?.map((d) => d[dataKey] ?? 0)) ?? 0}
+ maxValue={Math.max(...data.map((d) => d[dataKey] ?? 0)) ?? 0}
barBackground="bg-red-100"
hoverBackground="hover:bg-gradient-to-r hover:from-red-50 hover:to-transparent hover:border-red-500"
+ filterSelectedBackground="bg-red-600"
+ filterSelectedHoverBackground="hover:bg-red-700"
+ filterHoverClass="bg-white border border-red-200"
setShowModal={setShowModal}
+ selectedFilterValues={selectedItems}
+ activeFilterValues={activeFilterValues}
+ onToggleFilter={onToggleFilter}
+ onClearFilter={onClearFilter}
+ onClearSelection={() => setSelectedItems([])}
+ onApplyFilterValues={onApplyFilterValues}
{...(limit && { limit })}
/>
) : (
diff --git a/apps/web/ui/analytics/top-links.tsx b/apps/web/ui/analytics/top-links.tsx
index 94dcba0105..34525ec0d2 100644
--- a/apps/web/ui/analytics/top-links.tsx
+++ b/apps/web/ui/analytics/top-links.tsx
@@ -3,7 +3,7 @@ import { useWorkspacePreferences } from "@/lib/swr/use-workspace-preferences";
import { LinkLogo, useRouterStuff } from "@dub/ui";
import { Globe, Hyperlink } from "@dub/ui/icons";
import { getApexDomain } from "@dub/utils";
-import { useCallback, useContext, useMemo, useState } from "react";
+import { useCallback, useContext, useEffect, useMemo, useState } from "react";
import { FolderIcon } from "../folders/folder-icon";
import TagBadge from "../links/tag-badge";
import { AnalyticsCard } from "./analytics-card";
@@ -63,18 +63,72 @@ export function TopLinks() {
const [tab, setTab] = useState<TabId>("links");
const [subtab, setSubtab] = useState<Subtab>(TAB_CONFIG[tab].defaultSubtab);
+ const [selectedItems, setSelectedItems] = useState<string[]>([]);
+
// Reset subtab when tab changes to ensure it's valid for the new tab
const handleTabChange = (newTab: TabId) => {
setTab(newTab);
setSubtab(TAB_CONFIG[newTab].defaultSubtab);
};
+ useEffect(() => {
+ setSelectedItems([]);
+ }, [tab, subtab]);
+
+ const filterParamKey = useMemo(() => {
+ if (subtab === "links") return "linkId";
+ if (subtab === "base_urls") return "url";
+ if (subtab === "folders") return "folderId";
+ if (subtab === "tags") return "tagId";
+ return null;
+ }, [subtab]);
+
+ const onToggleFilter = useCallback((val: string) => {
+ setSelectedItems((prev) =>
+ prev.includes(val) ? prev.filter((v) => v !== val) : [...prev, val],
+ );
+ }, []);
+
+ const onApplyFilterValues = useCallback(
+ (values: string[]) => {
+ if (!filterParamKey) return;
+
+ if (values.length === 0) {
+ queryParams({ del: filterParamKey });
+ } else {
+ queryParams({ set: { [filterParamKey]: values.join(",") } });
+ }
+
+ setSelectedItems([]);
+ },
+ [filterParamKey, queryParams],
+ );
+
+ const isFilterActive = useMemo(
+ () => (filterParamKey ? searchParams.has(filterParamKey) : false),
+ [filterParamKey, searchParams],
+ );
+
+ const activeFilterValues = useMemo(
+ () =>
+ filterParamKey ? searchParams.get(filterParamKey)?.split(",") ?? [] : [],
+ [filterParamKey, searchParams],
+ );
+
+ const onClearFilter = useCallback(() => {
+ setSelectedItems([]);
+ if (isFilterActive && filterParamKey) queryParams({ del: filterParamKey });
+ }, [filterParamKey, queryParams, isFilterActive]);
+
const groupByParams = useMemo(
() => TAB_CONFIG[tab].getGroupBy(subtab),
[tab, subtab],
);
const { data } = useAnalyticsFilterOption(groupByParams);
+ const { data: allData } = useAnalyticsFilterOption(groupByParams, {
+ omitGroupByFilterKey: true,
+ });
const [persisted] = useWorkspacePreferences("linksDisplay");
@@ -104,6 +158,49 @@ export function TopLinks() {
[persisted, tab, subtab],
);
+ const mapItem = useCallback(
+ (d: Record<string, any>) => {
+ const isLinksTab = tab === "links";
+ const isUrlsTab = tab === "urls";
+ const isFoldersSubtab = isLinksTab && subtab === "folders";
+ const isTagsSubtab = isLinksTab && subtab === "tags";
+ const isLinksSubtab = isLinksTab && subtab === "links";
+
+ let icon;
+ if (isFoldersSubtab) {
+ icon = d.folder ? (
+ <FolderIcon folder={d.folder} shape="square" iconClassName="size-3" />
+ ) : null;
+ } else if (isTagsSubtab) {
+ icon = d.tag ? (
+ <TagBadge color={d.tag.color} withIcon className="sm:p-1" />
+ ) : null;
+ } else {
+ icon = (
+ <LinkLogo
+ apexDomain={getApexDomain(d.url || "")}
+ className="size-5 sm:size-5"
+ />
+ );
+ }
+
+ let filterValue: string | undefined;
+ if (isLinksSubtab) filterValue = d.id;
+ else if (isUrlsTab && subtab === "base_urls") filterValue = d.url;
+ else if (isFoldersSubtab) filterValue = d.folderId;
+ else if (isTagsSubtab) filterValue = d.tagId;
+
+ return {
+ icon,
+ title: getItemTitle(d),
+ filterValue,
+ value: d[dataKey] || 0,
+ ...(isLinksSubtab && { linkData: d }),
+ };
+ },
+ [tab, subtab, dataKey, getItemTitle],
+ );
+
const subTabProps = useMemo(() => {
if (adminPage || partnerPage || dashboardProps) return {};
const config = TAB_CONFIG[tab];
@@ -125,6 +222,8 @@ export function TopLinks() {
]}
expandLimit={8}
dataLength={data?.length}
+ isFilterActive={isFilterActive}
+ onClearFilter={onClearFilter}
selectedTabId={tab}
onSelectTab={handleTabChange}
{...subTabProps}
@@ -134,109 +233,24 @@ export function TopLinks() {
data.length > 0 ? (
<BarList
tab={tab}
- data={
- data
- ?.map((d) => {
- const isLinksTab = tab === "links";
- const isUrlsTab = tab === "urls";
- const isFoldersSubtab = isLinksTab && subtab === "folders";
- const isTagsSubtab = isLinksTab && subtab === "tags";
- const isLinksSubtab = isLinksTab && subtab === "links";
-
- // Determine icon
- let icon;
- if (isFoldersSubtab) {
- icon = d.folder ? (
- <FolderIcon
- folder={d.folder}
- shape="square"
- iconClassName="size-3"
- />
- ) : null;
- } else if (isTagsSubtab) {
- icon = d.tag ? (
- <TagBadge
- color={d.tag.color}
- withIcon
- className="sm:p-1"
- />
- ) : null;
- } else {
- icon = (
- <LinkLogo
- apexDomain={getApexDomain(d.url || "")}
- className="size-5 sm:size-5"
- />
- );
- }
-
- // Determine href
- let href: string | undefined;
- if (isLinksSubtab) {
- href = queryParams({
- ...(searchParams.has("linkId")
- ? { del: ["linkId"] }
- : {
- set: {
- linkId: d.id,
- },
- del: ["domain", "key"],
- }),
- getNewPath: true,
- }) as string;
- } else if (isUrlsTab && subtab === "base_urls") {
- const hasUrlFilter = searchParams.has("url");
- href = queryParams({
- ...(hasUrlFilter
- ? { del: "url" }
- : {
- set: {
- url: d.url,
- },
- }),
- getNewPath: true,
- }) as string;
- } else if (isFoldersSubtab) {
- const hasFolderFilter = searchParams.has("folderId");
- href = queryParams({
- ...(hasFolderFilter
- ? { del: "folderId" }
- : {
- set: {
- folderId: d.folderId,
- },
- }),
- getNewPath: true,
- }) as string;
- } else if (isTagsSubtab) {
- const hasTagFilter = searchParams.has("tagId");
- href = queryParams({
- ...(hasTagFilter
- ? { del: "tagId" }
- : {
- set: {
- tagId: d.tagId,
- },
- }),
- getNewPath: true,
- }) as string;
- }
-
- return {
- icon,
- title: getItemTitle(d),
- href,
- value: d[dataKey] || 0,
- ...(isLinksSubtab && { linkData: d }),
- };
- })
- ?.sort((a, b) => b.value - a.value) || []
- }
+ data={data?.map(mapItem).sort((a, b) => b.value - a.value) || []}
+ allData={allData?.map(mapItem).sort((a, b) => b.value - a.value)}
unit={selectedTab}
- maxValue={Math.max(...data?.map((d) => d[dataKey] ?? 0)) ?? 0}
+ maxValue={Math.max(...data.map((d) => d[dataKey] ?? 0))}
barBackground="bg-orange-100"
hoverBackground="hover:bg-gradient-to-r hover:from-orange-50 hover:to-transparent hover:border-orange-500"
+ filterSelectedBackground="bg-orange-500"
+ filterSelectedHoverBackground="hover:bg-orange-600"
+ filterHoverClass="bg-white border border-orange-200"
setShowModal={setShowModal}
+ selectedFilterValues={selectedItems}
+ activeFilterValues={activeFilterValues}
+ onToggleFilter={onToggleFilter}
+ onClearFilter={filterParamKey ? onClearFilter : undefined}
+ onClearSelection={() => setSelectedItems([])}
+ onApplyFilterValues={
+ filterParamKey ? onApplyFilterValues : undefined
+ }
{...(limit && { limit })}
/>
) : (
diff --git a/apps/web/ui/customers/customer-row-item.tsx b/apps/web/ui/customers/customer-row-item.tsx
index 576a70366c..ad5d03abba 100644
--- a/apps/web/ui/customers/customer-row-item.tsx
+++ b/apps/web/ui/customers/customer-row-item.tsx
@@ -1,4 +1,5 @@
import { generateRandomName } from "@/lib/names";
+import { FilterIconCell } from "@/ui/shared/filter-icon-cell";
import { ChartActivity2 } from "@dub/ui";
import { cn } from "@dub/utils";
import Link from "next/link";
@@ -11,6 +12,7 @@ export function CustomerRowItem({
className,
avatarClassName,
chartActivityIconMode = "hiddenOnHover",
+ filterSet,
}: {
customer: {
id: string;
@@ -22,9 +24,17 @@ export function CustomerRowItem({
className?: string;
avatarClassName?: string;
chartActivityIconMode?: "visible" | "hidden" | "hiddenOnHover";
+ 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"}
@@ -36,10 +46,11 @@ export function CustomerRowItem({
)}
>
<div className="flex items-center gap-2 truncate" title={display}>
- <CustomerAvatar
- customer={customer}
- className={cn("size-5 border border-neutral-200", avatarClassName)}
- />
+ {filterSet ? (
+ <FilterIconCell set={filterSet} icon={avatar} />
+ ) : (
+ <div className="shrink-0">{avatar}</div>
+ )}
<span className="truncate">{display}</span>
</div>
{href && chartActivityIconMode !== "hidden" && (
diff --git a/apps/web/ui/customers/customers-table/customers-table.tsx b/apps/web/ui/customers/customers-table/customers-table.tsx
index a1ef84a8d9..d91a0a0522 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 { FilterButtonTableRow } from "@/ui/shared/filter-button-table-row";
+import { FilterIconCell } from "@/ui/shared/filter-icon-cell";
import { SearchBoxPersisted } from "@/ui/shared/search-box";
import {
AnimatedSizeContainer,
@@ -38,7 +38,7 @@ import {
getApexDomain,
getPrettyUrl,
} from "@dub/utils";
-import { Cell, Row } from "@tanstack/react-table";
+import { Row } from "@tanstack/react-table";
import { Command } from "cmdk";
import Image from "next/image";
import Link from "next/link";
@@ -50,12 +50,6 @@ 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,
@@ -163,26 +157,23 @@ export function CustomersTable({
id: "country",
header: "Country",
accessorKey: "country",
- meta: {
- filterParams: ({ getValue }) =>
- getValue()
- ? {
- country: getValue(),
- }
- : undefined,
- },
minSize: 150,
cell: ({ row }) => {
const country = row.original.country;
return (
<div className="flex items-center gap-2">
- {country && (
- <img
- alt={`${country} flag`}
- src={`https://hatscripts.github.io/circle-flags/flags/${country.toLowerCase()}.svg`}
- className="size-4 shrink-0"
+ {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"
+ />
+ }
/>
- )}
+ ) : null}
<span className="min-w-0 truncate">
{(country ? COUNTRIES[country] : null) ?? "-"}
</span>
@@ -193,17 +184,12 @@ export function CustomersTable({
{
id: "partner",
header: "Partner",
- meta: {
- filterParams: ({ row }) =>
- row.original.partner?.id
- ? {
- partnerId: row.original.partner.id,
- }
- : undefined,
- },
cell: ({ row }) =>
row.original.partner ? (
- <PartnerRowItem partner={row.original.partner} />
+ <PartnerRowItem
+ filterSet={{ partnerId: row.original.partner.id }}
+ partner={row.original.partner}
+ />
) : (
"-"
),
@@ -213,25 +199,31 @@ export function CustomersTable({
id: "link",
header: "Link",
accessorKey: "link",
- meta: {
- filterParams: ({ getValue }) =>
- getValue() ? { linkId: getValue().id } : undefined,
- },
cell: ({ row }) =>
row.original.link ? (
- <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"
+ <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"
+ />
+ }
/>
- <span className="truncate" title={row.original.link.shortLink}>
- {getPrettyUrl(row.original.link.shortLink)}
- </span>
- </Link>
+ <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>
) : (
"-"
),
@@ -392,14 +384,6 @@ export function CustomersTable({
del: "page",
scroll: false,
}),
- cellRight: (cell) => {
- const meta = cell.column.columnDef.meta as ColumnMeta | undefined;
- return (
- meta?.filterParams && (
- <FilterButtonTableRow set={meta.filterParams(cell)} />
- )
- );
- },
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 b8b7b637a4..df5e5f7a67 100644
--- a/apps/web/ui/partners/partner-row-item.tsx
+++ b/apps/web/ui/partners/partner-row-item.tsx
@@ -1,4 +1,5 @@
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";
@@ -15,6 +16,7 @@ import {
interface PartnerRowItemProps {
showPermalink?: boolean;
showFraudIndicator?: boolean;
+ filterSet?: Record<string, any>;
partner: {
id: string;
name: string;
@@ -168,46 +170,56 @@ export function PartnerRowItem({
partner,
showPermalink = true,
showFraudIndicator = true,
+ filterSet,
}: PartnerRowItemProps) {
const { slug } = useParams();
const { statusKey, showPayoutsEnabled } = usePartnerPayoutStatus(partner);
const As = showPermalink ? Link : "div";
- return (
- <div className="flex min-w-0 items-center gap-2">
- <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,
- )}
- />
+ 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>
+ />
+ )}
</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>
+ )}
<As
href={`/${slug}/program/partners/${partner.id}`}
{...(showPermalink && { target: "_blank" })}
+ {...(filterSet && {
+ onClick: (e: React.MouseEvent) => e.stopPropagation(),
+ })}
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
new file mode 100644
index 0000000000..de60b3d953
--- /dev/null
+++ b/apps/web/ui/shared/filter-icon-cell.tsx
@@ -0,0 +1,106 @@
+"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>
+ );
+}
diff --git a/packages/ui/src/table/table.tsx b/packages/ui/src/table/table.tsx
index 9e586a25d8..af229431a6 100644
--- a/packages/ui/src/table/table.tsx
+++ b/packages/ui/src/table/table.tsx
@@ -803,7 +803,7 @@ export function Table<T>({
</div>
)}
{pagination && !error && !!data?.length && !!rowCount && (
- <div className="border-border-subtle bg-bg-default text-content-default sticky bottom-0 mx-auto -mt-px flex w-full max-w-full items-center justify-between rounded-b-[inherit] border-t px-4 py-3.5 text-sm leading-6">
+ <div className="border-border-subtle bg-bg-default text-content-default sticky bottom-0 z-10 mx-auto -mt-px flex w-full max-w-full items-center justify-between rounded-b-[inherit] border-t px-4 py-3.5 text-sm leading-6">
<div>
<span className="hidden sm:inline-block">Viewing</span>{" "}
<span className="font-medium">