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.

Add recent activity

Tim Wilson42339b4c2070
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/payouts/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/payouts/page-client.tsx
index 35b7fc4152..a9f7abec1f 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/payouts/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/payouts/page-client.tsx
@@ -8,6 +8,7 @@ import { BadgeCheck, GreekTemple } from "@dub/ui/src/icons";
import { truncate } from "@dub/utils";
import { BankAccount } from "./bank-account";
import { ComplianceButton } from "./compliance-button";
+import { Transactions } from "./transactions";
import { Wallet } from "./wallet";
export function PayoutsPageClient() {
@@ -24,35 +25,40 @@ export function PayoutsPageClient() {
<>
<AddBankAccountModal />
{bankAccountName || isLoadingWorkspace ? (
- <div className="rounded-lg border border-neutral-300 bg-white p-5">
- <div className="flex flex-col justify-between gap-4 sm:flex-row sm:items-center">
- <div className="flex items-center gap-5">
- <div className="hidden size-12 items-center justify-center rounded-full border border-neutral-300 sm:flex">
- <GreekTemple className="size- 5text-neutral-900" />
+ <div>
+ <div className="rounded-lg border border-neutral-300 bg-white p-5">
+ <div className="flex flex-col justify-between gap-4 sm:flex-row sm:items-center">
+ <div className="flex items-center gap-5">
+ <div className="hidden size-12 items-center justify-center rounded-full border border-neutral-300 sm:flex">
+ <GreekTemple className="size- 5text-neutral-900" />
+ </div>
+ <div className="flex flex-col gap-1">
+ {bankAccountName ? (
+ <span className="text-base font-medium leading-none text-neutral-900">
+ {truncate(bankAccountName, 32)}
+ </span>
+ ) : (
+ <div className="h-4 w-32 animate-pulse rounded-md bg-neutral-200" />
+ )}
+ {bankAccountVerified !== undefined ? (
+ <span className="text-sm leading-none text-neutral-500">
+ {bankAccountVerified ? "Connected" : "Verifying"}
+ </span>
+ ) : (
+ <div className="h-3.5 w-16 animate-pulse rounded-md bg-neutral-200" />
+ )}
+ </div>
</div>
- <div className="flex flex-col gap-1">
- {bankAccountName ? (
- <span className="text-base font-medium leading-none text-neutral-900">
- {truncate(bankAccountName, 32)}
- </span>
- ) : (
- <div className="h-4 w-32 animate-pulse rounded-md bg-neutral-200" />
- )}
- {bankAccountVerified !== undefined ? (
- <span className="text-sm leading-none text-neutral-500">
- {bankAccountVerified ? "Connected" : "Verifying"}
- </span>
- ) : (
- <div className="h-3.5 w-16 animate-pulse rounded-md bg-neutral-200" />
- )}
- </div>
- </div>
- <ComplianceButton />
+ <ComplianceButton />
+ </div>
+ <div className="mt-5 grid divide-neutral-200 rounded-lg border border-neutral-200 bg-neutral-50 max-sm:divide-y sm:grid-cols-[repeat(2,minmax(0,1fr))] sm:divide-x">
+ <Wallet />
+ <BankAccount />
+ </div>
</div>
- <div className="mt-5 grid divide-neutral-200 rounded-lg border border-neutral-200 bg-neutral-50 max-sm:divide-y sm:grid-cols-[repeat(2,minmax(0,1fr))] sm:divide-x">
- <Wallet />
- <BankAccount />
+ <div className="mt-8">
+ <Transactions />
</div>
</div>
) : (
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/payouts/transactions.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/payouts/transactions.tsx
index 774e27b74b..8ae5e4e77b 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/payouts/transactions.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/payouts/transactions.tsx
@@ -2,32 +2,57 @@
import { DotsTransactions } from "@/lib/dots/types";
import useWorkspace from "@/lib/swr/use-workspace";
-import { fetcher } from "@dub/utils";
+import { Table, useTable } from "@dub/ui";
+import {
+ capitalize,
+ currencyFormatter,
+ fetcher,
+ formatDateTime,
+} from "@dub/utils";
import useSWR from "swr";
export const Transactions = () => {
const { id: workspaceId } = useWorkspace();
- const { data, isLoading } = useSWR<DotsTransactions>(
+ const { data, error } = useSWR<DotsTransactions>(
`/api/dots/transactions?workspaceId=${workspaceId}`,
fetcher,
);
- const transactions = data?.data || [];
+ const table = useTable({
+ data: data?.data || [],
+ loading: !data && !error,
+ error: error ? "Failed to load recent activity" : undefined,
+ columns: [
+ {
+ header: "Date",
+ accessorFn: (row) => formatDateTime(new Date(row.created), {}),
+ },
+ {
+ header: "Type",
+ accessorFn: (row) => capitalize(row.type),
+ },
+ {
+ header: "Amount",
+ accessorFn: (row) =>
+ currencyFormatter(parseFloat(row.amount) / 100, {
+ minimumFractionDigits: 2,
+ maximumFractionDigits: 2,
+ }),
+ },
+ ],
+ thClassName: "border-l-0",
+ tdClassName: "border-l-0",
+ });
return (
- <ul className="flex w-full flex-col space-y-2">
- {transactions.map((transaction) => (
- <li
- key={transaction.id}
- className="flex items-center justify-between rounded-lg bg-white p-3 shadow transition-colors hover:bg-gray-50"
- >
- <span>{transaction.created}</span>
- <span>{transaction.source_name}</span>
- <span>{transaction.destination_name}</span>
- <span>${Number(transaction.amount).toFixed(2)}</span>
- </li>
- ))}
- </ul>
+ <div>
+ <h2 className="text-base font-semibold text-neutral-900">
+ Recent activity
+ </h2>
+ <div className="mt-3">
+ <Table {...table} />
+ </div>
+ </div>
);
};