Skip to content

Commit bd77628

Browse files
authored
Merge branch 'main' into link-page
2 parents 150035f + b3b758f commit bd77628

File tree

9 files changed

+82
-16
lines changed

9 files changed

+82
-16
lines changed

apps/web/app/api/programs/[programId]/payouts/route.ts

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export const GET = withWorkspace(
6969
},
7070
include: {
7171
partner: true,
72+
user: true,
7273
_count: {
7374
select: {
7475
commissions: true,

apps/web/app/app.dub.co/(dashboard)/[slug]/programs/[programId]/payouts/payout-table.tsx

+62-10
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,19 @@ import {
2020
Popover,
2121
StatusBadge,
2222
Table,
23+
Tooltip,
2324
usePagination,
2425
useRouterStuff,
2526
useTable,
2627
} from "@dub/ui";
2728
import { CircleCheck, Dots, MoneyBill2, MoneyBills2 } from "@dub/ui/icons";
28-
import { cn } from "@dub/utils";
29-
import { formatDate, formatPeriod } from "@dub/utils/src/functions/datetime";
29+
import {
30+
cn,
31+
DICEBEAR_AVATAR_URL,
32+
formatDate,
33+
formatDateTime,
34+
} from "@dub/utils";
35+
import { formatPeriod } from "@dub/utils/src/functions/datetime";
3036
import { fetcher } from "@dub/utils/src/functions/fetcher";
3137
import { Row } from "@tanstack/react-table";
3238
import { Command } from "cmdk";
@@ -137,16 +143,62 @@ const PayoutTableInner = memo(
137143
},
138144
},
139145
{
140-
id: "paidAt",
141146
header: "Paid",
142147
cell: ({ row }) =>
143-
row.original.paidAt
144-
? formatDate(row.original.paidAt, {
145-
month: "short",
146-
day: "numeric",
147-
year: undefined,
148-
})
149-
: "-",
148+
row.original.paidAt ? (
149+
<Tooltip
150+
content={
151+
<div className="flex flex-col gap-1 p-2.5">
152+
{row.original.user && (
153+
<div className="flex flex-col gap-2">
154+
<img
155+
src={
156+
row.original.user.image ||
157+
`${DICEBEAR_AVATAR_URL}${row.original.user.name}`
158+
}
159+
alt={row.original.user.name}
160+
className="size-6 shrink-0 rounded-full"
161+
/>
162+
<p className="text-sm font-medium">
163+
{row.original.user.name}
164+
</p>
165+
</div>
166+
)}
167+
<div className="text-xs text-neutral-500">
168+
Paid at{" "}
169+
<span className="font-medium text-neutral-700">
170+
{formatDateTime(row.original.paidAt, {
171+
month: "short",
172+
day: "numeric",
173+
year: "numeric",
174+
hour: "numeric",
175+
minute: "numeric",
176+
})}
177+
</span>
178+
</div>
179+
</div>
180+
}
181+
>
182+
<div className="flex items-center gap-2">
183+
{row.original.user && (
184+
<img
185+
src={
186+
row.original.user.image ||
187+
`${DICEBEAR_AVATAR_URL}${row.original.user.name}`
188+
}
189+
alt={row.original.user.name}
190+
className="size-5 shrink-0 rounded-full"
191+
/>
192+
)}
193+
{formatDate(row.original.paidAt, {
194+
month: "short",
195+
year: undefined,
196+
})}
197+
</div>
198+
</Tooltip>
199+
) : (
200+
"-"
201+
),
150202
},
151203
{
152204
id: "amount",

apps/web/app/partners.dub.co/(dashboard)/programs/[programSlug]/earnings/earnings-table.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import { CircleDollar } from "@dub/ui/icons";
2020
import {
2121
currencyFormatter,
2222
fetcher,
23-
formatDate,
2423
formatDateTime,
2524
getApexDomain,
2625
getPrettyUrl,
@@ -70,9 +69,13 @@ export function EarningsTablePartner({ limit }: { limit?: number }) {
7069
id: "createdAt",
7170
header: "Date",
7271
accessorKey: "timestamp",
72+
minSize: 140,
7373
cell: ({ row }) => (
7474
<p title={formatDateTime(row.original.createdAt)}>
75-
{formatDate(row.original.createdAt, { month: "short" })}
75+
{formatDateTime(row.original.createdAt, {
76+
month: "short",
77+
year: undefined,
78+
})}
7679
</p>
7780
),
7881
},

apps/web/app/partners.dub.co/(dashboard)/settings/payouts/payout-table.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ import {
1616
useTable,
1717
} from "@dub/ui";
1818
import { MoneyBill2 } from "@dub/ui/icons";
19-
import { DICEBEAR_AVATAR_URL } from "@dub/utils";
20-
import { formatPeriod } from "@dub/utils/src/functions/datetime";
19+
import { DICEBEAR_AVATAR_URL, formatPeriod } from "@dub/utils";
2120
import { useEffect, useState } from "react";
2221
import { PayoutDetailsSheet } from "./payout-details-sheet";
2322

apps/web/lib/actions/partners/confirm-payouts.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const allowedPaymentMethods = ["us_bank_account", "card", "link"];
2323
export const confirmPayoutsAction = authActionClient
2424
.schema(confirmPayoutsSchema)
2525
.action(async ({ parsedInput, ctx }) => {
26-
const { workspace } = ctx;
26+
const { workspace, user } = ctx;
2727
const { programId, paymentMethodId } = parsedInput;
2828

2929
const { minPayoutAmount } = await getProgramOrThrow({
@@ -148,6 +148,7 @@ export const confirmPayoutsAction = authActionClient
148148
data: {
149149
invoiceId: invoice.id,
150150
status: "processing",
151+
userId: user.id,
151152
},
152153
});
153154

apps/web/lib/middleware/utils/bots-list.ts

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export const UA_BOTS = [
88
"meta-externalagent", // Meta external agent
99
"WhatsApp", // WhatsApp crawler
1010
"google", // Google crawler
11-
"linkedin", // LinkedIn crawler
1211
"baidu", // Baidu crawler
1312
"bing", // Bing crawler
1413
"msn", // MSN crawler

apps/web/lib/zod/schemas/payouts.ts

+7
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ export const PayoutSchema = z.object({
7474
export const PayoutResponseSchema = PayoutSchema.merge(
7575
z.object({
7676
partner: PartnerSchema,
77+
user: z
78+
.object({
79+
id: z.string(),
80+
name: z.string(),
81+
image: z.string(),
82+
})
83+
.nullish(),
7784
_count: z.object({ commissions: z.number() }),
7885
}),
7986
);

packages/prisma/schema/payout.prisma

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ model Payout {
1818
programId String
1919
partnerId String
2020
invoiceId String?
21+
userId String?
2122
amount Int @default(0)
2223
currency String @default("USD")
2324
status PayoutStatus @default(pending)
@@ -34,10 +35,12 @@ model Payout {
3435
program Program @relation(fields: [programId], references: [id])
3536
partner Partner @relation(fields: [partnerId], references: [id])
3637
invoice Invoice? @relation(fields: [invoiceId], references: [id])
38+
user User? @relation(fields: [userId], references: [id])
3739
commissions Commission[]
3840
3941
@@index(programId)
4042
@@index(partnerId)
4143
@@index(invoiceId)
4244
@@index(status)
45+
@@index(userId)
4346
}

packages/prisma/schema/schema.prisma

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ model User {
4242
folders FolderUser[]
4343
folderAccessRequests FolderAccessRequest[]
4444
utmTemplates UtmTemplate[]
45+
payouts Payout[]
4546
4647
@@index(source)
4748
@@index(defaultWorkspace)

0 commit comments

Comments
 (0)