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.

small improvements

Steven Teycebd5a9d4dd6
diff --git a/apps/web/app/(ee)/app.dub.co/invoices/[invoiceId]/route.tsx b/apps/web/app/(ee)/app.dub.co/invoices/[invoiceId]/route.tsx
index ac91e89161..3165db8298 100644
--- a/apps/web/app/(ee)/app.dub.co/invoices/[invoiceId]/route.tsx
+++ b/apps/web/app/(ee)/app.dub.co/invoices/[invoiceId]/route.tsx
@@ -60,7 +60,7 @@ export const GET = withSession(async ({ session, params }) => {
},
},
orderBy: {
- periodStart: "desc",
+ amount: "desc",
},
},
workspace: {
@@ -100,6 +100,23 @@ export const GET = withSession(async ({ session, params }) => {
console.error(error);
}
}
+ const earliestPeriodStart = invoice.payouts.reduce(
+ (acc, payout) => {
+ if (!acc) return payout.periodStart;
+ if (!payout.periodStart) return acc;
+ return payout.periodStart < (acc as Date) ? payout.periodStart : acc;
+ },
+ null as Date | null,
+ );
+
+ const latestPeriodEnd = invoice.payouts.reduce(
+ (acc, payout) => {
+ if (!acc) return payout.periodEnd;
+ if (!payout.periodEnd) return acc;
+ return payout.periodEnd > (acc as Date) ? payout.periodEnd : acc;
+ },
+ null as Date | null,
+ );
const invoiceMetadata = [
{
@@ -117,10 +134,13 @@ export const GET = withSession(async ({ session, params }) => {
},
{
label: "Payout period",
- value: `${formatDate(startOfMonth(invoice.createdAt), {
- month: "short",
- year: "numeric",
- })} - ${formatDate(endOfMonth(invoice.createdAt), {
+ value: `${formatDate(
+ startOfMonth(earliestPeriodStart || invoice.createdAt),
+ {
+ month: "short",
+ year: "numeric",
+ },
+ )} - ${formatDate(endOfMonth(latestPeriodEnd || invoice.createdAt), {
month: "short",
year: "numeric",
})}`,
diff --git a/apps/web/app/api/callback/plain/partner/route.ts b/apps/web/app/api/callback/plain/partner/route.ts
index e9ced5ca6f..f34b182257 100644
--- a/apps/web/app/api/callback/plain/partner/route.ts
+++ b/apps/web/app/api/callback/plain/partner/route.ts
@@ -191,10 +191,13 @@ export async function POST(req: NextRequest) {
]
: []),
...(paypalEmail
- ? plainCopySection({
- label: "Paypal Email",
- value: paypalEmail,
- })
+ ? [
+ plainSpacer,
+ ...plainCopySection({
+ label: "Paypal Email",
+ value: paypalEmail,
+ }),
+ ]
: []),
plainSpacer,
uiComponent.row({
diff --git a/apps/web/scripts/partners/check-pending-paypal-payouts.ts b/apps/web/scripts/partners/check-pending-paypal-payouts.ts
index 514188f3ef..b22f846d57 100644
--- a/apps/web/scripts/partners/check-pending-paypal-payouts.ts
+++ b/apps/web/scripts/partners/check-pending-paypal-payouts.ts
@@ -5,7 +5,9 @@ import "dotenv-flow/config";
async function main() {
const payouts = await prisma.payout.findMany({
where: {
- status: "pending",
+ status: {
+ in: ["pending", "processing"],
+ },
amount: {
gte: 10000,
},