The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
add embed loading state
Steven Tey7e51e3fa64c8
diff --git a/apps/web/app/app.dub.co/(dashboard)/account/settings/referrals/page.tsx b/apps/web/app/app.dub.co/(dashboard)/account/settings/referrals/page.tsxindex 718c48508c..31fcdf52ce 100644--- a/apps/web/app/app.dub.co/(dashboard)/account/settings/referrals/page.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/account/settings/referrals/page.tsx@@ -1,6 +1,13 @@import { getSession } from "@/lib/auth/utils";import { dub } from "@/lib/dub";+import { AnimatedEmptyState } from "@/ui/shared/animated-empty-state";import { DubWidget } from "@dub/embed-react";+import {+ CursorRays,+ Hyperlink,+ InvoiceDollar,+ UserCheck,+} from "@dub/ui/src/icons";export const dynamic = "auto";@@ -8,13 +15,29 @@ export default async function ReferralsPage() {const session = await getSession();const referralLinkId = session?.user["referralLinkId"];- if (!referralLinkId) return <div>No referral link ID</div>;+ if (!referralLinkId)+ return (+ <AnimatedEmptyState+ title="Refer a friend"+ description="Activate your referral link to share the word about Dub and earn cash rewards"+ cardContent={+ <>+ <Hyperlink className="size-4 text-neutral-700" />+ <div className="h-2.5 w-24 min-w-0 rounded-sm bg-neutral-200" />+ <div className="xs:flex hidden grow items-center justify-end gap-1.5 text-gray-500">+ <CursorRays className="size-3.5" />+ <UserCheck className="size-3.5" />+ <InvoiceDollar className="size-3.5" />+ </div>+ </>+ }+ pillContent="Coming soon"+ />+ );const { publicToken } = await dub.embedTokens.create({linkId: referralLinkId,});- if (!publicToken) return <div>No public token</div>;-return <DubWidget token={publicToken} variant="inline" />;}diff --git a/apps/web/app/app.dub.co/embed/loading.tsx b/apps/web/app/app.dub.co/embed/loading.tsxnew file mode 100644index 0000000000..479406107d--- /dev/null+++ b/apps/web/app/app.dub.co/embed/loading.tsx@@ -0,0 +1,9 @@+import { LoadingSpinner } from "@dub/ui/src/icons";++export default function EmbedLoading() {+ return (+ <div className="flex min-h-screen flex-col items-center justify-center">+ <LoadingSpinner />+ </div>+ );+}diff --git a/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx b/apps/web/ui/layout/sidebar/app-sidebar-nav.tsxindex 482a89a4a6..ec13a0330c 100644--- a/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx+++ b/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx@@ -230,11 +230,15 @@ const NAV_AREAS: SidebarNavAreas<{icon: ShieldCheck,href: "/account/settings/security",},- {- name: "Referrals",- icon: Gift,- href: "/account/settings/referrals",- },+ ...(session?.user?.["referralLinkId"]+ ? [+ {+ name: "Referrals",+ icon: Gift,+ href: "/account/settings/referrals",+ },+ ]+ : []),],},],