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.

improve loading state

Steven Teyded8046e0438
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 75215d6111..f514648461 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,12 +1,64 @@
import { AnalyticsResponse } from "@/lib/analytics/types";
import { editQueryString } from "@/lib/analytics/utils";
import { PartnerRowItem } from "@/ui/partners/partner-row-item";
-import { LoadingSpinner, Table, usePagination, useTable } from "@dub/ui";
+import { Table, usePagination, useTable } from "@dub/ui";
import { currencyFormatter, fetcher, nFormatter } from "@dub/utils";
import { useContext, useMemo, useState } from "react";
import useSWR from "swr";
import { ProgramAnalyticsContext } from "./page-client";
+function PartnerTableSkeleton() {
+ return (
+ <div className="bg-bg-default relative overflow-x-auto rounded-xl">
+ <table className="group/table w-full border-separate border-spacing-0 text-sm transition-[border-spacing,margin-top] [&_tr:last-child>td]:border-b-transparent [&_tr>*:first-child]:border-l-transparent [&_tr>*:last-child]:border-r-transparent [&_tr]:border-b">
+ <thead>
+ <tr>
+ <th className="border-border-subtle border-b border-l-0 px-4 py-2.5 text-left font-medium text-neutral-900">
+ Partner
+ </th>
+ <th className="border-border-subtle border-b border-l-0 px-4 py-2.5 text-left font-medium text-neutral-900">
+ Clicks
+ </th>
+ <th className="border-border-subtle border-b border-l-0 px-4 py-2.5 text-left font-medium text-neutral-900">
+ Leads
+ </th>
+ <th className="border-border-subtle border-b border-l-0 px-4 py-2.5 text-left font-medium text-neutral-900">
+ Sales
+ </th>
+ <th className="border-border-subtle border-b border-l-0 px-4 py-2.5 text-left font-medium text-neutral-900">
+ Revenue
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ {[...Array(10)].map((_, idx) => (
+ <tr key={idx} className="group/row">
+ <td className="border-border-subtle border-b border-l-0 px-4 py-2.5">
+ <div className="flex items-center gap-2.5">
+ <div className="size-6 animate-pulse rounded-full bg-neutral-200" />
+ <div className="h-4 w-32 animate-pulse rounded bg-neutral-200" />
+ </div>
+ </td>
+ <td className="border-border-subtle border-b border-l-0 px-4 py-2.5">
+ <div className="h-4 w-16 animate-pulse rounded bg-neutral-200" />
+ </td>
+ <td className="border-border-subtle border-b border-l-0 px-4 py-2.5">
+ <div className="h-4 w-16 animate-pulse rounded bg-neutral-200" />
+ </td>
+ <td className="border-border-subtle border-b border-l-0 px-4 py-2.5">
+ <div className="h-4 w-16 animate-pulse rounded bg-neutral-200" />
+ </td>
+ <td className="border-border-subtle border-b border-l-0 px-4 py-2.5">
+ <div className="h-4 w-20 animate-pulse rounded bg-neutral-200" />
+ </td>
+ </tr>
+ ))}
+ </tbody>
+ </table>
+ </div>
+ );
+}
+
export function AnalyticsPartnersTable() {
const { queryString } = useContext(ProgramAnalyticsContext);
@@ -83,19 +135,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,
thClassName: "border-l-0",
@@ -106,7 +145,9 @@ export function AnalyticsPartnersTable() {
error: topPartnersError ? "Failed to load partners" : undefined,
});
- return topPartnersPage && topPartnersPage.length > 0 ? (
+ return topPartnersLoading ? (
+ <PartnerTableSkeleton />
+ ) : topPartnersPage && topPartnersPage.length > 0 ? (
<Table
{...tableProps}
table={table}
@@ -115,17 +156,7 @@ export function AnalyticsPartnersTable() {
/>
) : (
<div className="text-content-muted flex h-36 items-center justify-center text-sm">
- {topPartnersLoading ? (
- <LoadingSpinner />
- ) : topPartnersError ? (
- "Failed to load partners."
- ) : (
- "No partners found."
- )}
+ {topPartnersError ? "Failed to load partners." : "No partners found."}
</div>
);
}
-
-// Don't seem to need this locally but the Vercel build fails without a type predicate
-const isNotNull = <T extends unknown>(item: T | null): item is T =>
- item !== null;
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/page-client.tsx
index b33a7ff449..248adb090e 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/analytics/page-client.tsx
@@ -66,7 +66,7 @@ export function ProgramAnalyticsPageClient() {
});
return (
- <div className="flex flex-col gap-6">
+ <div className="flex flex-col gap-6 pb-12">
<div>
<div className="flex items-center gap-2">
<Filter.Select