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.

update payouts admin

Steven Tey35c2ed226b4e
diff --git a/apps/web/app/admin.dub.co/(dashboard)/commissions/client.tsx b/apps/web/app/admin.dub.co/(dashboard)/commissions/client.tsx
index d90842eefd..48ccd48dc8 100644
--- a/apps/web/app/admin.dub.co/(dashboard)/commissions/client.tsx
+++ b/apps/web/app/admin.dub.co/(dashboard)/commissions/client.tsx
@@ -217,7 +217,7 @@ export default function CommissionsPageClient() {
}}
/>
) : (
- <div className="h-9 w-16 animate-pulse rounded-md bg-neutral-200" />
+ <div className="h-10 w-24 animate-pulse rounded-md bg-neutral-200" />
)}
</div>
</button>
diff --git a/apps/web/app/admin.dub.co/(dashboard)/payouts/client.tsx b/apps/web/app/admin.dub.co/(dashboard)/payouts/client.tsx
index 8a5d5943d3..1a92aea412 100644
--- a/apps/web/app/admin.dub.co/(dashboard)/payouts/client.tsx
+++ b/apps/web/app/admin.dub.co/(dashboard)/payouts/client.tsx
@@ -99,10 +99,9 @@ export default function PayoutsPageClient() {
const totals = useMemo(() => {
return {
- payouts:
- timeseriesData?.reduce((acc, { payouts }) => acc + payouts, 0) ?? 0,
- fees: timeseriesData?.reduce((acc, { fees }) => acc + fees, 0) ?? 0,
- total: timeseriesData?.reduce((acc, { total }) => acc + total, 0) ?? 0,
+ payouts: timeseriesData?.reduce((acc, { payouts }) => acc + payouts, 0),
+ fees: timeseriesData?.reduce((acc, { fees }) => acc + fees, 0),
+ total: timeseriesData?.reduce((acc, { total }) => acc + total, 0),
};
}, [timeseriesData]);
@@ -226,16 +225,20 @@ export default function PayoutsPageClient() {
<span>{label}</span>
</div>
<div className="mt-1 flex h-12 items-center">
- <NumberFlow
- value={totals[id] / 100}
- className="text-xl font-medium sm:text-3xl"
- format={{
- style: "currency",
- currency: "USD",
- // @ts-ignore – trailingZeroDisplay is a valid option but TS is outdated
- trailingZeroDisplay: "stripIfInteger",
- }}
- />
+ {totals[id] || totals[id] === 0 ? (
+ <NumberFlow
+ value={totals[id] / 100}
+ className="text-xl font-medium sm:text-3xl"
+ format={{
+ style: "currency",
+ currency: "USD",
+ // @ts-ignore – trailingZeroDisplay is a valid option but TS is outdated
+ trailingZeroDisplay: "stripIfInteger",
+ }}
+ />
+ ) : (
+ <div className="h-10 w-24 animate-pulse rounded-md bg-neutral-200" />
+ )}
</div>
</button>
);
diff --git a/apps/web/app/api/admin/payouts/route.ts b/apps/web/app/api/admin/payouts/route.ts
index b212272296..67dfed688c 100644
--- a/apps/web/app/api/admin/payouts/route.ts
+++ b/apps/web/app/api/admin/payouts/route.ts
@@ -31,9 +31,7 @@ export const GET = withAdmin(async ({ searchParams }) => {
programId: {
not: ACME_PROGRAM_ID,
},
- status: "completed",
- paidAt: {
- not: null,
+ createdAt: {
gte: startDate,
lte: endDate,
},
@@ -47,7 +45,7 @@ export const GET = withAdmin(async ({ searchParams }) => {
},
},
orderBy: {
- paidAt: "desc",
+ createdAt: "desc",
},
});
@@ -59,23 +57,21 @@ export const GET = withAdmin(async ({ searchParams }) => {
{ date: Date; payouts: number; fees: number; total: number }[]
>`
SELECT
- DATE_FORMAT(CONVERT_TZ(paidAt, "UTC", ${timezone}), ${dateFormat}) as date,
+ DATE_FORMAT(CONVERT_TZ(createdAt, "UTC", ${timezone}), ${dateFormat}) as date,
SUM(amount) as payouts,
SUM(fee) as fees,
SUM(total) as total
FROM Invoice
WHERE
programId != ${ACME_PROGRAM_ID}
- AND status = 'completed'
- AND paidAt IS NOT NULL
- AND paidAt >= ${startDate}
- AND paidAt <= ${endDate}
- GROUP BY DATE_FORMAT(CONVERT_TZ(paidAt, "UTC", ${timezone}), ${dateFormat})
+ AND createdAt >= ${startDate}
+ AND createdAt <= ${endDate}
+ GROUP BY DATE_FORMAT(CONVERT_TZ(createdAt, "UTC", ${timezone}), ${dateFormat})
ORDER BY date ASC;
`;
const formattedInvoices = invoices.map((invoice) => ({
- date: invoice.paidAt,
+ date: invoice.createdAt,
programName: invoice.program.name,
programLogo: invoice.program.logo,
status: invoice.status,