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 PayoutPaidCell

Steven Tey64ab90e22787
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/[partnerId]/payouts/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/[partnerId]/payouts/page-client.tsx
index 14abbd1834..4c5bb81c94 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/[partnerId]/payouts/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/[partnerId]/payouts/page-client.tsx
@@ -14,6 +14,7 @@ import {
useTable,
} from "@dub/ui";
import { cn, currencyFormatter, formatPeriod } from "@dub/utils";
+import { PayoutPaidCell } from "app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-paid-cell";
import Link from "next/link";
import { useParams } from "next/navigation";
@@ -44,7 +45,12 @@ function PartnerPayouts({ partner }: { partner: EnrolledPartnerProps }) {
error: payoutsError,
loading,
} = usePayouts({
- query: { partnerId: partner.id, pageSize: 10 },
+ query: {
+ partnerId: partner.id,
+ pageSize: 10,
+ sortBy: "initiatedAt",
+ sortOrder: "desc",
+ },
});
const table = useTable({
@@ -69,6 +75,17 @@ function PartnerPayouts({ partner }: { partner: EnrolledPartnerProps }) {
);
},
},
+
+ {
+ header: "Paid",
+ cell: ({ row }) => (
+ <PayoutPaidCell
+ initiatedAt={row.original.initiatedAt}
+ paidAt={row.original.paidAt}
+ user={row.original.user}
+ />
+ ),
+ },
{
id: "amount",
header: "Amount",
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-paid-cell.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-paid-cell.tsx
new file mode 100644
index 0000000000..938932f9ca
--- /dev/null
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-paid-cell.tsx
@@ -0,0 +1,93 @@
+import { PayoutStatusBadges } from "@/ui/partners/payout-status-badges";
+import { Tooltip } from "@dub/ui";
+import { formatDate, formatDateTime, OG_AVATAR_URL } from "@dub/utils";
+
+type PayoutPaidCellUser = {
+ id?: string;
+ name?: string | null;
+ image?: string | null;
+} | null;
+
+type PayoutPaidCellProps = {
+ initiatedAt?: string | Date | null;
+ paidAt?: string | Date | null;
+ user?: PayoutPaidCellUser;
+};
+
+export function PayoutPaidCell({
+ initiatedAt,
+ paidAt,
+ user,
+}: PayoutPaidCellProps) {
+ const ProcessingIcon = PayoutStatusBadges.processing.icon;
+ const CompletedIcon = PayoutStatusBadges.completed.icon;
+
+ if (!initiatedAt) {
+ return "-";
+ }
+
+ return (
+ <Tooltip
+ content={
+ <div className="flex flex-col gap-1 p-2.5">
+ {user && (
+ <div className="flex flex-col gap-2">
+ <img
+ src={user.image || `${OG_AVATAR_URL}${user.name}`}
+ alt={user.name ?? user.id}
+ className="size-6 shrink-0 rounded-full"
+ />
+ <p className="text-sm font-medium">{user.name}</p>
+ </div>
+ )}
+ <div className="flex items-center gap-1.5 text-xs text-neutral-500">
+ <ProcessingIcon className="size-3 shrink-0 text-blue-600" />
+ <span>
+ Payment initiated at{" "}
+ <span className="font-medium text-neutral-700">
+ {formatDateTime(initiatedAt, {
+ month: "short",
+ day: "numeric",
+ year: "numeric",
+ hour: "numeric",
+ minute: "numeric",
+ })}
+ </span>
+ </span>
+ </div>
+ {paidAt && (
+ <div className="flex items-center gap-1.5 text-xs text-neutral-500">
+ <CompletedIcon className="size-3 shrink-0 text-green-600" />
+ <span>
+ Payment completed at{" "}
+ <span className="font-medium text-neutral-700">
+ {formatDateTime(paidAt, {
+ month: "short",
+ day: "numeric",
+ year: "numeric",
+ hour: "numeric",
+ minute: "numeric",
+ })}
+ </span>
+ </span>
+ </div>
+ )}
+ </div>
+ }
+ >
+ <div className="flex items-center gap-2">
+ {user && (
+ <img
+ src={user.image || `${OG_AVATAR_URL}${user.name}`}
+ alt={user.name ?? user.id}
+ className="size-5 shrink-0 rounded-full"
+ />
+ )}
+ {formatDate(initiatedAt, {
+ month: "short",
+ year: undefined,
+ })}
+ </div>
+ </Tooltip>
+ );
+}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-table.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-table.tsx
index e311b4c21a..c499111012 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-table.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-table.tsx
@@ -23,16 +23,11 @@ import {
useTable,
} from "@dub/ui";
import { MoneyBill2 } from "@dub/ui/icons";
-import {
- cn,
- currencyFormatter,
- formatDate,
- formatDateTime,
- OG_AVATAR_URL,
-} from "@dub/utils";
+import { cn, currencyFormatter } from "@dub/utils";
import { formatPeriod } from "@dub/utils/src/functions/datetime";
import { fetcher } from "@dub/utils/src/functions/fetcher";
import { PayoutDetailsSheet } from "app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-details-sheet";
+import { PayoutPaidCell } from "app/app.dub.co/(dashboard)/[slug]/(ee)/program/payouts/payout-paid-cell";
import { useParams } from "next/navigation";
import { memo, useEffect, useMemo, useState } from "react";
import useSWR from "swr";
@@ -170,85 +165,13 @@ const PayoutTableInner = memo(
},
{
header: "Paid",
- cell: ({ row }) => {
- const ProcessingIcon = PayoutStatusBadges.processing.icon;
- const CompletedIcon = PayoutStatusBadges.completed.icon;
-
- return row.original.initiatedAt ? (
- <Tooltip
- content={
- <div className="flex flex-col gap-1 p-2.5">
- {row.original.user && (
- <div className="flex flex-col gap-2">
- <img
- src={
- row.original.user.image ||
- `${OG_AVATAR_URL}${row.original.user.name}`
- }
- alt={row.original.user.name ?? row.original.user.id}
- className="size-6 shrink-0 rounded-full"
- />
- <p className="text-sm font-medium">
- {row.original.user.name}
- </p>
- </div>
- )}
- <div className="flex items-center gap-1.5 text-xs text-neutral-500">
- <ProcessingIcon className="size-3 shrink-0 text-blue-600" />
- <span>
- Payment initiated at{" "}
- <span className="font-medium text-neutral-700">
- {formatDateTime(row.original.initiatedAt, {
- month: "short",
- day: "numeric",
- year: "numeric",
- hour: "numeric",
- minute: "numeric",
- })}
- </span>
- </span>
- </div>
- {row.original.paidAt && (
- <div className="flex items-center gap-1.5 text-xs text-neutral-500">
- <CompletedIcon className="size-3 shrink-0 text-green-600" />
- <span>
- Payment completed at{" "}
- <span className="font-medium text-neutral-700">
- {formatDateTime(row.original.paidAt, {
- month: "short",
- day: "numeric",
- year: "numeric",
- hour: "numeric",
- minute: "numeric",
- })}
- </span>
- </span>
- </div>
- )}
- </div>
- }
- >
- <div className="flex items-center gap-2">
- {row.original.user && (
- <img
- src={
- row.original.user.image ||
- `${OG_AVATAR_URL}${row.original.user.name}`
- }
- alt={row.original.user.name ?? row.original.user.id}
- className="size-5 shrink-0 rounded-full"
- />
- )}
- {formatDate(row.original.initiatedAt, {
- month: "short",
- year: undefined,
- })}
- </div>
- </Tooltip>
- ) : (
- "-"
- );
- },
+ cell: ({ row }) => (
+ <PayoutPaidCell
+ initiatedAt={row.original.initiatedAt}
+ paidAt={row.original.paidAt}
+ user={row.original.user}
+ />
+ ),
},
{
id: "amount",