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.

fix invoices page design

Steven Teyb9045727040e
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/invoices/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/invoices/page.tsx
index 211698d941..abbbc676ad 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/invoices/page.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/invoices/page.tsx
@@ -1,10 +1,365 @@
-import { Suspense } from "react";
-import WorkspaceInvoicesClient from "./page-client";
+"use client";
+
+import { INVOICE_PAYMENT_METHODS } from "@/lib/constants/payouts";
+import useWorkspace from "@/lib/swr/use-workspace";
+import { InvoiceProps } from "@/lib/types";
+import { PageContent } from "@/ui/layout/page-content";
+import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper";
+import { PayoutStatusBadges } from "@/ui/partners/payout-status-badges";
+import { AnimatedEmptyState } from "@/ui/shared/animated-empty-state";
+import {
+ buttonVariants,
+ ChevronRight,
+ DynamicTooltipWrapper,
+ Receipt2,
+ StatusBadge,
+ TabSelect,
+ useRouterStuff,
+} from "@dub/ui";
+import { cn, currencyFormatter, fetcher } from "@dub/utils";
+import { AlertCircle } from "lucide-react";
+import Link from "next/link";
+import { useMemo } from "react";
+import useSWR from "swr";
+
+const INVOICE_TYPES = [
+ { id: "subscription", label: "Subscription" },
+ { id: "partnerPayout", label: "Partner payouts" },
+ { id: "domainRenewal", label: "Domain renewals" },
+];
export default function WorkspaceInvoices() {
+ const { slug } = useWorkspace();
+ const { searchParams, queryParams } = useRouterStuff();
+
+ const selectedInvoiceType = useMemo(() => {
+ let type = searchParams.get("type");
+
+ if (type === "payout") {
+ type = "partnerPayout";
+ }
+
+ return INVOICE_TYPES.find((t) => t.id === type) || INVOICE_TYPES[0];
+ }, [searchParams]);
+
+ const { data: invoices } = useSWR<InvoiceProps[]>(
+ `/api/workspaces/${slug}/billing/invoices?type=${selectedInvoiceType.id}`,
+ fetcher,
+ );
+
+ const displayPaymentMethod = selectedInvoiceType.id === "partnerPayout";
+
return (
- <Suspense>
- <WorkspaceInvoicesClient />
- </Suspense>
+ <PageContent
+ title={
+ <div className="flex items-center gap-1.5">
+ <Link
+ href={`/${slug}/settings/billing`}
+ className="transition-all duration-150 hover:text-neutral-600 active:scale-95"
+ >
+ Billing
+ </Link>
+ <ChevronRight className="text-content-muted size-4" />
+ <h1>Invoices</h1>
+ </div>
+ }
+ >
+ <PageWidthWrapper>
+ <div className="rounded-xl border border-neutral-200 bg-white">
+ <TabSelect
+ className="px-4 md:px-5"
+ options={INVOICE_TYPES}
+ selected={selectedInvoiceType.id}
+ onSelect={(id) => {
+ queryParams({
+ set: {
+ type: id,
+ },
+ });
+ }}
+ />
+ <div className="grid divide-y divide-neutral-200 border-t border-neutral-200">
+ {invoices ? (
+ invoices.length > 0 ? (
+ invoices.map((invoice) => (
+ <InvoiceCard
+ key={invoice.id}
+ invoice={invoice}
+ displayPaymentMethod={displayPaymentMethod}
+ />
+ ))
+ ) : (
+ <AnimatedEmptyState
+ title={`No ${selectedInvoiceType.label.toLowerCase()} invoices found`}
+ description={`You don't have any ${selectedInvoiceType.label.toLowerCase()} invoices yet`}
+ cardContent={() => (
+ <>
+ <Receipt2 className="size-4 text-neutral-700" />
+ <div className="h-2.5 w-24 min-w-0 rounded-sm bg-neutral-200" />
+ </>
+ )}
+ className="border-none"
+ />
+ )
+ ) : (
+ <>
+ <InvoiceCardSkeleton
+ displayPaymentMethod={displayPaymentMethod}
+ />
+ <InvoiceCardSkeleton
+ displayPaymentMethod={displayPaymentMethod}
+ />
+ <InvoiceCardSkeleton
+ displayPaymentMethod={displayPaymentMethod}
+ />
+ </>
+ )}
+ </div>
+ </div>
+ </PageWidthWrapper>
+ </PageContent>
);
}
+
+const InvoiceCard = ({
+ invoice,
+ displayPaymentMethod = false,
+}: {
+ invoice: InvoiceProps;
+ displayPaymentMethod: boolean;
+}) => {
+ const invoicePaymentMethod =
+ INVOICE_PAYMENT_METHODS[invoice.paymentMethod ?? "ach"];
+
+ return (
+ <div className="px-3 py-4 xl:px-12">
+ {/* Mobile layout */}
+ <div className="block xl:hidden">
+ <div className="mb-4 flex items-start justify-between">
+ <div className="text-sm">
+ <div className="font-medium">{invoice.description}</div>
+ <div className="text-neutral-500">
+ {new Date(invoice.createdAt).toLocaleDateString("en-US", {
+ month: "short",
+ year: "numeric",
+ day: "numeric",
+ })}
+ </div>
+ </div>
+ <div className="flex items-center">
+ {invoice.pdfUrl && invoice.status !== "failed" ? (
+ <a
+ href={invoice.pdfUrl}
+ target="_blank"
+ className={cn(
+ buttonVariants({ variant: "secondary" }),
+ "flex h-9 items-center justify-center rounded-md border px-3 text-sm",
+ )}
+ >
+ <span>View invoice</span>
+ </a>
+ ) : (
+ <div />
+ )}
+ </div>
+ </div>
+
+ <div className="space-y-4">
+ <div className="text-left text-sm">
+ <div className="font-medium">Total</div>
+ <div className="flex items-center gap-1.5 text-neutral-500">
+ <span className="text-sm font-medium">
+ {currencyFormatter(invoice.total)}
+ </span>
+ {invoice.status &&
+ (() => {
+ const badge = PayoutStatusBadges[invoice.status];
+ return (
+ <DynamicTooltipWrapper
+ tooltipProps={
+ invoice.failedReason
+ ? { content: invoice.failedReason }
+ : undefined
+ }
+ >
+ <StatusBadge
+ icon={invoice.status === "failed" ? AlertCircle : null}
+ variant={badge.variant}
+ className="rounded-md py-0.5"
+ >
+ {badge.label}
+ </StatusBadge>
+ </DynamicTooltipWrapper>
+ );
+ })()}
+ </div>
+ </div>
+
+ {displayPaymentMethod && (
+ <div className="text-left text-sm">
+ <div className="font-medium">Method</div>
+ {invoicePaymentMethod ? (
+ <div className="flex items-center gap-1.5 text-neutral-500">
+ <div className="text-content-subtle text-sm font-medium">
+ {invoicePaymentMethod.label}
+ </div>
+ <StatusBadge
+ icon={null}
+ variant="neutral"
+ className="rounded-md py-0.5 text-xs font-semibold text-neutral-700"
+ >
+ {invoicePaymentMethod.duration}
+ </StatusBadge>
+ </div>
+ ) : (
+ <span className="text-neutral-500">-</span>
+ )}
+ </div>
+ )}
+ </div>
+ </div>
+
+ {/* Desktop layout */}
+ <div className="hidden xl:grid xl:grid-cols-4 xl:gap-4">
+ <div className="text-sm xl:col-span-1">
+ <div className="font-medium">{invoice.description}</div>
+ <div className="text-neutral-500">
+ {new Date(invoice.createdAt).toLocaleDateString("en-US", {
+ month: "short",
+ year: "numeric",
+ day: "numeric",
+ })}
+ </div>
+ </div>
+
+ <div className="text-left text-sm sm:col-span-1">
+ <div className="font-medium">Total</div>
+ <div className="flex items-center gap-1.5 text-neutral-500">
+ <span className="text-sm font-medium">
+ {currencyFormatter(invoice.total)}
+ </span>
+ {invoice.status &&
+ (() => {
+ const badge = PayoutStatusBadges[invoice.status];
+ return (
+ <DynamicTooltipWrapper
+ tooltipProps={
+ invoice.failedReason
+ ? { content: invoice.failedReason }
+ : undefined
+ }
+ >
+ <StatusBadge
+ icon={invoice.status === "failed" ? AlertCircle : null}
+ variant={badge.variant}
+ className="rounded-md py-0.5"
+ >
+ {badge.label}
+ </StatusBadge>
+ </DynamicTooltipWrapper>
+ );
+ })()}
+ </div>
+ </div>
+
+ {displayPaymentMethod && (
+ <div className="text-left text-sm sm:col-span-1 lg:block">
+ <div className="font-medium">Method</div>
+ {invoicePaymentMethod ? (
+ <div className="flex items-center gap-1.5 text-neutral-500">
+ <div className="text-content-subtle text-sm font-medium">
+ {invoicePaymentMethod.label}
+ </div>
+ <StatusBadge
+ icon={null}
+ variant="neutral"
+ className="rounded-md py-0.5 text-xs font-semibold text-neutral-700"
+ >
+ {invoicePaymentMethod.duration}
+ </StatusBadge>
+ </div>
+ ) : (
+ <span className="text-neutral-500">-</span>
+ )}
+ </div>
+ )}
+
+ <div className="flex items-center justify-end sm:col-span-1 sm:justify-end">
+ {invoice.pdfUrl && invoice.status !== "failed" ? (
+ <a
+ href={invoice.pdfUrl}
+ target="_blank"
+ className={cn(
+ buttonVariants({ variant: "secondary" }),
+ "flex h-9 items-center justify-center rounded-md border px-3 text-sm",
+ )}
+ >
+ <span>View invoice</span>
+ </a>
+ ) : (
+ <div />
+ )}
+ </div>
+ </div>
+ </div>
+ );
+};
+
+const InvoiceCardSkeleton = ({
+ displayPaymentMethod = false,
+}: {
+ displayPaymentMethod?: boolean;
+}) => {
+ return (
+ <div className="px-4 py-6 sm:px-12">
+ {/* Mobile skeleton */}
+ <div className="block sm:hidden">
+ <div className="mb-4 flex items-start justify-between">
+ <div className="flex flex-col gap-1 text-sm">
+ <div className="h-4 w-32 animate-pulse rounded-md bg-neutral-200" />
+ <div className="h-4 w-24 animate-pulse rounded-md bg-neutral-200" />
+ </div>
+ <div className="h-9 w-24 animate-pulse rounded-md bg-neutral-200" />
+ </div>
+
+ <div className="space-y-4">
+ <div className="flex flex-col gap-1">
+ <div className="h-4 w-16 animate-pulse rounded-md bg-neutral-200" />
+ <div className="h-4 w-20 animate-pulse rounded-md bg-neutral-200" />
+ </div>
+
+ {displayPaymentMethod && (
+ <div className="flex flex-col gap-1">
+ <div className="h-4 w-12 animate-pulse rounded-md bg-neutral-200" />
+ <div className="h-4 w-20 animate-pulse rounded-md bg-neutral-200" />
+ </div>
+ )}
+ </div>
+ </div>
+
+ {/* Desktop skeleton */}
+ <div className="hidden sm:grid sm:grid-cols-3 sm:gap-4 lg:grid-cols-4">
+ <div className="flex flex-col gap-1 text-sm sm:col-span-1">
+ <div className="h-4 w-32 animate-pulse rounded-md bg-neutral-200" />
+ <div className="h-4 w-24 animate-pulse rounded-md bg-neutral-200" />
+ </div>
+
+ <div className="flex flex-col gap-1 sm:col-span-1">
+ <div className="h-4 w-16 animate-pulse rounded-md bg-neutral-200" />
+ <div className="h-4 w-20 animate-pulse rounded-md bg-neutral-200" />
+ </div>
+
+ {displayPaymentMethod && (
+ <div className="flex flex-col gap-1 sm:col-span-1">
+ <div className="h-4 w-12 animate-pulse rounded-md bg-neutral-200" />
+ <div className="h-4 w-20 animate-pulse rounded-md bg-neutral-200" />
+ </div>
+ )}
+
+ <div className="flex items-center justify-end sm:col-span-1 sm:justify-end">
+ <div className="h-9 w-24 animate-pulse rounded-md bg-neutral-200" />
+ </div>
+ </div>
+ </div>
+ );
+};
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/plan-usage.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/plan-usage.tsx
index e456f5b0e7..7a01af1035 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/plan-usage.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/plan-usage.tsx
@@ -7,8 +7,8 @@ import usePartnersCount from "@/lib/swr/use-partners-count";
import useTagsCount from "@/lib/swr/use-tags-count";
import { useUsageTimeseries } from "@/lib/swr/use-usage-timeseries";
import useWorkspace from "@/lib/swr/use-workspace";
-import { useConfirmModal } from "@/ui/modals/confirm-modal";
import useWorkspaceUsers from "@/lib/swr/use-workspace-users";
+import { useConfirmModal } from "@/ui/modals/confirm-modal";
import { useManageUsageModal } from "@/ui/modals/manage-usage-modal";
import { useStartPaidPlanModal } from "@/ui/modals/start-paid-plan-modal";
import SubscriptionMenu from "@/ui/workspaces/subscription-menu";
@@ -43,14 +43,11 @@ import {
} from "@dub/utils";
import NumberFlow from "@number-flow/react";
import Link from "next/link";
-import { useRouter } from "next/navigation";
import { CSSProperties, ReactNode, useMemo } from "react";
import { toast } from "sonner";
import { UsageChart } from "./usage-chart";
export default function PlanUsage() {
- const router = useRouter();
-
const {
id: workspaceId,
slug,
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/enabled/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/enabled/page.tsx
index a8c31a3099..87762d15c0 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/enabled/page.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/integrations/enabled/page.tsx
@@ -52,7 +52,14 @@ async function EnabledIntegrationsPageRSC({ slug }: { slug: string }) {
},
},
include: {
- user: true,
+ user: {
+ select: {
+ id: true,
+ name: true,
+ email: true,
+ image: true,
+ },
+ },
},
},
},