The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
include SidebarUsage on free plans + improve PAYOUT_STATUS_DESCRIPTIONS
Steven Teya377ca707ea8
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-stats.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-stats.tsxindex ca0a5c79aa..6b70d9c771 100644--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-stats.tsx+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-stats.tsx@@ -4,6 +4,7 @@ import usePartnerPayoutsCount from "@/lib/swr/use-partner-payouts-count";import usePartnerProfile from "@/lib/swr/use-partner-profile";import { PayoutsCount } from "@/lib/types";import { PayoutStatusBadges } from "@/ui/partners/payout-status-badges";+import { PAYOUT_STATUS_DESCRIPTIONS } from "@/ui/partners/payout-status-descriptions";import { AlertCircleFill } from "@/ui/shared/icons";import { PayoutStatus } from "@dub/prisma/client";import { Tooltip } from "@dub/ui";@@ -15,30 +16,6 @@ import {} from "@dub/utils";import { HelpCircle } from "lucide-react";-const tooltips = {- stripe: {- pending:- "Payouts that have passed the program's holding period and are waiting to be processed.",- processing:- " Payouts that are being processed by the program – this can take up to 5 business days.",- processed:- "Payouts that have been processed by the program and will be paid out to your connected bank account once they reach your minimum withdrawal balance.",- sent: "Payouts that are on their way to your connected bank account – this can take anywhere from 1 to 14 business days depending on your bank location.",- completed:- "Payouts that have been paid out to your connected bank account.",- },-- paypal: {- pending:- "Payouts that have passed the program's holding period and are waiting to be processed.",- processing:- "Payouts that have been processed by the program and are on their way to your PayPal account - this can take up to 5 business days.",- processed: "",- sent: "",- completed: "Payouts that have been paid out to your PayPal account",- },-} as const;-function PayoutStatsCard({label,amount,@@ -143,7 +120,9 @@ export function PayoutStats() {}}- const tooltip = payoutMethod ? tooltips[payoutMethod] : undefined;+ const tooltip = payoutMethod+ ? PAYOUT_STATUS_DESCRIPTIONS[payoutMethod]+ : undefined;const payoutStats = [{diff --git a/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx b/apps/web/ui/layout/sidebar/app-sidebar-nav.tsxindex 43a33607dc..0f59df0cf5 100644--- a/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx+++ b/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx@@ -43,6 +43,7 @@ import { Hyperlink } from "./icons/hyperlink";import { LinesY } from "./icons/lines-y";import { User } from "./icons/user";import { SidebarNav, SidebarNavAreas, SidebarNavGroups } from "./sidebar-nav";+import { SidebarUsage } from "./usage";import { useProgramApplicationsCount } from "./use-program-applications-count";import { WorkspaceDropdown } from "./workspace-dropdown";@@ -439,7 +440,7 @@ export function AppSidebarNav({showConversionGuides: canTrackConversions && customersCount === 0,}}toolContent={toolContent}- newsContent={newsContent}+ newsContent={plan && (plan === "free" ? <SidebarUsage /> : newsContent)}switcher={<WorkspaceDropdown />}/>);diff --git a/apps/web/ui/layout/sidebar/news.tsx b/apps/web/ui/layout/sidebar/news.tsxindex 7ad843762e..62b0095825 100644--- a/apps/web/ui/layout/sidebar/news.tsx+++ b/apps/web/ui/layout/sidebar/news.tsx@@ -38,7 +38,7 @@ export function News({ articles }: { articles: NewsArticle[] }) {return cards.length || showCompleted ? (<div- className="group overflow-hidden border-t border-neutral-200 px-3 pt-6 transition-all duration-200 hover:pt-10"+ className="group overflow-hidden border-t border-neutral-200 p-3 pt-6 transition-all duration-200 hover:pt-10"data-active={cardCount !== 0}><div className="relative size-full">diff --git a/apps/web/ui/layout/sidebar/sidebar-nav-old.tsx b/apps/web/ui/layout/sidebar/sidebar-nav-old.tsxdeleted file mode 100644index 00ad34d8f0..0000000000--- a/apps/web/ui/layout/sidebar/sidebar-nav-old.tsx+++ /dev/null@@ -1,258 +0,0 @@-import { AnimatedSizeContainer, ClientOnly, Icon, NavWordmark } from "@dub/ui";-import { cn } from "@dub/utils";-import { AnimatePresence, motion } from "framer-motion";-import { ChevronDown, ChevronLeft } from "lucide-react";-import Link from "next/link";-import { usePathname } from "next/navigation";-import {- PropsWithChildren,- ReactNode,- Suspense,- useMemo,- useState,-} from "react";-import UserDropdownOld from "./user-dropdown-old";--export type NavItemCommon = {- name: string;- href: string;- exact?: boolean;-};--export type NavSubItemType = NavItemCommon;--export type NavItemType = NavItemCommon & {- icon: Icon;- items?: NavSubItemType[];-};--export type SidebarNavAreas<T extends Record<any, any>> = Record<- string,- (args: T) => {- title?: string;- backHref?: string;- showSwitcher?: boolean;- showNews?: boolean;- direction?: "left" | "right";- content: {- name?: string;- items: NavItemType[];- }[];- }->;--/**- * @deprecated use SidebarNav instead- */-export function SidebarNavOld<T extends Record<any, any>>({- areas,- currentArea,- data,- toolContent,- newsContent,- switcher,- bottom,-}: {- areas: SidebarNavAreas<T>;- currentArea: string;- data: T;- toolContent?: ReactNode;- newsContent?: ReactNode;- switcher?: ReactNode;- bottom?: ReactNode;-}) {- return (- <ClientOnly className="scrollbar-hide relative flex h-full w-full flex-col overflow-y-auto overflow-x-hidden">- <nav className="relative flex grow flex-col p-3 text-neutral-500">- <div className="relative flex items-start justify-between gap-1 pb-3">- {Object.entries(areas).map(([area, areaConfig]) => {- const { title, backHref } = areaConfig(data);-- return (- <Link- key={area}- href={backHref ?? "/"}- className={cn(- "rounded-md px-1 outline-none transition-opacity focus-visible:ring-2 focus-visible:ring-black/50",- area === currentArea- ? "relative opacity-100"- : "pointer-events-none absolute opacity-0",- (!title || !backHref) && "mb-1",- )}- aria-hidden={area !== currentArea ? true : undefined}- {...{ inert: area !== currentArea ? "" : undefined }}- >- {title && backHref ? (- <div className="py group -my-1 -ml-1 flex items-center gap-2 py-2 pr-1 text-sm font-medium text-neutral-900">- <ChevronLeft className="size-4 text-neutral-500 transition-transform duration-100 group-hover:-translate-x-0.5" />- {title}- </div>- ) : (- <NavWordmark className="h-6" isInApp />- )}- </Link>- );- })}- <div className="hidden items-center gap-3 md:flex">- <Suspense fallback={null}>{toolContent}</Suspense>- <UserDropdownOld />- </div>- </div>- <div className="relative w-full grow">- {Object.entries(areas).map(([area, areaConfig]) => {- const { content, showSwitcher, showNews, direction } =- areaConfig(data);- return (- <Area- key={area}- visible={area === currentArea}- direction={direction ?? "right"}- >- {showSwitcher && switcher && (- <div className="pt-2">{switcher}</div>- )}-- <div className="flex flex-col gap-4 pt-4">- {content.map(({ name, items }, idx) => (- <div key={idx} className="flex flex-col gap-0.5">- {name && (- <div className="mb-2 pl-1 text-sm text-neutral-500">- {name}- </div>- )}- {items.map((item) => (- <NavItem key={item.name} item={item} />- ))}- </div>- ))}- </div>-- <AnimatePresence>- {showNews && (- <motion.div- className="-mx-3 flex grow flex-col justify-end"- initial={{ opacity: 0, y: 10 }}- animate={{ opacity: 1, y: 0 }}- exit={{ opacity: 0, y: 10 }}- transition={{- duration: 0.1,- ease: "easeInOut",- }}- >- {newsContent}- </motion.div>- )}- </AnimatePresence>- </Area>- );- })}- </div>- </nav>- {bottom && (- <div className="relative flex flex-col justify-end">{bottom}</div>- )}- </ClientOnly>- );-}--function NavItem({ item }: { item: NavItemType | NavSubItemType }) {- const { name, href, exact } = item;-- const Icon = "icon" in item ? item.icon : undefined;- const items = "items" in item ? item.items : undefined;-- const [hovered, setHovered] = useState(false);-- const pathname = usePathname();-- const isActive = useMemo(() => {- const hrefWithoutQuery = href.split("?")[0];- return exact- ? pathname === hrefWithoutQuery- : pathname.startsWith(hrefWithoutQuery);- }, [pathname, href, exact]);-- return (- <div>- <Link- href={href}- data-active={isActive}- onPointerEnter={() => setHovered(true)}- onPointerLeave={() => setHovered(false)}- className={cn(- "group flex items-center gap-2.5 rounded-md p-2 text-sm leading-none text-neutral-600 transition-[background-color,color,font-weight] duration-75 hover:bg-neutral-200/50 active:bg-neutral-200/80",- "outline-none focus-visible:ring-2 focus-visible:ring-black/50",- isActive &&- !items &&- "bg-blue-100/50 font-medium text-blue-600 hover:bg-blue-100/80 active:bg-blue-100",- )}- >- {Icon && (- <Icon- className={cn(- "size-4 text-neutral-500 transition-colors duration-75",- !items && "group-data-[active=true]:text-blue-600",- )}- data-hovered={hovered}- />- )}- {name}- {items && (- <div className="flex grow justify-end">- {items ? (- <ChevronDown className="size-3.5 text-neutral-500 transition-transform duration-75 group-data-[active=true]:rotate-180" />- ) : null}- </div>- )}- </Link>- {items && (- <AnimatedSizeContainer- height- transition={{ duration: 0.2, ease: "easeInOut" }}- >- <div- className={cn(- "transition-opacity duration-200",- isActive ? "h-auto" : "h-0 opacity-0",- )}- aria-hidden={!isActive}- >- <div className="pl-px pt-1">- <div className="pl-3.5">- <div className="flex flex-col gap-0.5 border-l border-neutral-200 pl-2">- {items.map((item) => (- <NavItem key={item.name} item={item} />- ))}- </div>- </div>- </div>- </div>- </AnimatedSizeContainer>- )}- </div>- );-}--export function Area({- visible,- direction,- children,-}: PropsWithChildren<{ visible: boolean; direction: "left" | "right" }>) {- return (- <div- className={cn(- "left-0 top-0 flex size-full flex-col md:transition-[opacity,transform] md:duration-300",- visible- ? "opacity-1 relative"- : cn(- "pointer-events-none absolute opacity-0",- direction === "left" ? "-translate-x-full" : "translate-x-full",- ),- )}- aria-hidden={!visible ? "true" : undefined}- {...{ inert: !visible ? "" : undefined }}- >- {children}- </div>- );-}diff --git a/apps/web/ui/layout/sidebar/sidebar-nav.tsx b/apps/web/ui/layout/sidebar/sidebar-nav.tsxindex 5b05dde6fc..7357940287 100644--- a/apps/web/ui/layout/sidebar/sidebar-nav.tsx+++ b/apps/web/ui/layout/sidebar/sidebar-nav.tsx@@ -203,15 +203,17 @@ export function SidebarNav<T extends Record<any, any>>({</div>{/* Fixed bottom sections */}- <div className="flex flex-col gap-2 p-3 pt-0">+ <div className="flex flex-col gap-2">{data.showConversionGuides && (- <Link- href={`/${data.slug}/guides`}- className="flex items-center gap-2 rounded-lg bg-neutral-200/75 px-2.5 py-2 text-xs text-neutral-700 transition-colors hover:bg-neutral-200"- >- <BookOpen className="size-4" />- Set up conversion tracking- </Link>+ <div className="px-3 pb-2">+ <Link+ href={`/${data.slug}/guides`}+ className="flex items-center gap-2 rounded-lg bg-neutral-200/75 px-2.5 py-2 text-xs text-neutral-700 transition-colors hover:bg-neutral-200"+ >+ <BookOpen className="size-4" />+ Set up conversion tracking+ </Link>+ </div>)}<AnimatePresence>diff --git a/apps/web/ui/layout/sidebar/usage.tsx b/apps/web/ui/layout/sidebar/usage.tsxindex d11c461e5d..ca3a2d72f6 100644--- a/apps/web/ui/layout/sidebar/usage.tsx+++ b/apps/web/ui/layout/sidebar/usage.tsx@@ -18,7 +18,7 @@ import Link from "next/link";import { useParams } from "next/navigation";import { CSSProperties, forwardRef, useMemo, useState } from "react";-export function Usage() {+export function SidebarUsage() {const { slug } = useParams() as { slug?: string };return slug ? <UsageInner /> : null;diff --git a/apps/web/ui/partners/payout-status-badge-partner.tsx b/apps/web/ui/partners/payout-status-badge-partner.tsxindex 72b76151ad..263738c237 100644--- a/apps/web/ui/partners/payout-status-badge-partner.tsx+++ b/apps/web/ui/partners/payout-status-badge-partner.tsx@@ -1,7 +1,10 @@+import usePartnerProfile from "@/lib/swr/use-partner-profile";import { Payout, Program } from "@dub/prisma/client";-import { DynamicTooltipWrapper, StatusBadge } from "@dub/ui";+import { StatusBadge, Tooltip } from "@dub/ui";import { currencyFormatter } from "@dub/utils";+import { useMemo } from "react";import { PayoutStatusBadges } from "./payout-status-badges";+import { PAYOUT_STATUS_DESCRIPTIONS } from "./payout-status-descriptions";export const PayoutStatusBadgePartner = ({payout,@@ -12,28 +15,37 @@ export const PayoutStatusBadgePartner = ({};program: Pick<Program, "minPayoutAmount">;}) => {+ const { partner } = usePartnerProfile();+const badge = PayoutStatusBadges[payout.status];- const tooltip = (() => {++ const tooltipContent: string | undefined = useMemo(() => {+ if (!partner) {+ return undefined;+ }if (payout.status === "failed" && payout.failureReason) {return payout.failureReason;}- if (payout.status === "pending") {- return payout.amount >= program.minPayoutAmount- ? "This payout will be processed depends on your program's payment schedule, which is usually at the beginning or the end of the month."- : `This program's minimum payout amount is ${currencyFormatter(- program.minPayoutAmount / 100,- )}. This payout will be accrued and processed during the next payout period.`;+ if (+ payout.status === "pending" &&+ payout.amount < program.minPayoutAmount+ ) {+ return `This program's minimum payout amount is ${currencyFormatter(+ program.minPayoutAmount / 100,+ )}. This payout will be accrued and processed during the next payout period.`;}- return undefined;- })();+ return (+ PAYOUT_STATUS_DESCRIPTIONS?.[+ partner?.paypalEmail ? "paypal" : "stripe"+ ]?.[payout.status] || PAYOUT_STATUS_DESCRIPTIONS?.paypal?.[payout.status]+ );+ }, [payout, program, partner]);return badge ? (<StatusBadge icon={badge.icon} variant={badge.variant}>- <DynamicTooltipWrapper- tooltipProps={tooltip ? { content: tooltip } : undefined}- >- {badge.label}- </DynamicTooltipWrapper>+ <Tooltip content={tooltipContent}>+ <div>{badge.label}</div>+ </Tooltip></StatusBadge>) : ("-"diff --git a/apps/web/ui/partners/payout-status-descriptions.ts b/apps/web/ui/partners/payout-status-descriptions.tsnew file mode 100644index 0000000000..1e564d8691--- /dev/null+++ b/apps/web/ui/partners/payout-status-descriptions.ts@@ -0,0 +1,23 @@+export const PAYOUT_STATUS_DESCRIPTIONS = {+ stripe: {+ pending:+ "Payouts that have passed the program's holding period and are waiting to be processed.",+ processing:+ "Payouts that are being processed by the program – this can take up to 5 business days.",+ processed:+ "Payouts that have been processed by the program and will be paid out to your connected bank account once they reach your minimum withdrawal balance.",+ sent: "Payouts that are on their way to your connected bank account – this can take anywhere from 1 to 14 business days depending on your bank location.",+ completed:+ "Payouts that have been paid out to your connected bank account.",+ },++ paypal: {+ pending:+ "Payouts that have passed the program's holding period and are waiting to be processed.",+ processing:+ "Payouts that have been processed by the program and are on their way to your PayPal account - this can take up to 5 business days.",+ processed: "",+ sent: "",+ completed: "Payouts that have been paid out to your PayPal account",+ },+};