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 route.ts

Kiran K03c90f918c31
diff --git a/apps/web/app/api/workspaces/[idOrSlug]/billing/invoices/route.ts b/apps/web/app/api/workspaces/[idOrSlug]/billing/invoices/route.ts
index 55e20b909a..ebbbac8612 100644
--- a/apps/web/app/api/workspaces/[idOrSlug]/billing/invoices/route.ts
+++ b/apps/web/app/api/workspaces/[idOrSlug]/billing/invoices/route.ts
@@ -7,7 +7,10 @@ import { NextResponse } from "next/server";
import { z } from "zod";
const querySchema = z.object({
- type: z.enum(["subscription", "payout"]).optional().default("subscription"),
+ type: z
+ .enum(["subscription", "partnerPayout", "domainRenewal"])
+ .optional()
+ .default("subscription"),
});
// TODO: move to GET /invoices
@@ -21,7 +24,10 @@ export const GET = withWorkspace(async ({ workspace, searchParams }) => {
const invoices =
type === "subscription"
? await subscriptionInvoices(workspace.stripeId)
- : await payoutInvoices(workspace.id);
+ : await otherInvoices({
+ workspaceId: workspace.id,
+ type,
+ });
return NextResponse.json(z.array(InvoiceSchema).parse(invoices));
});
@@ -47,10 +53,17 @@ const subscriptionInvoices = async (stripeId: string) => {
}
};
-const payoutInvoices = async (workspaceId: string) => {
+const otherInvoices = async ({
+ workspaceId,
+ type,
+}: {
+ workspaceId: string;
+ type: "partnerPayout" | "domainRenewal";
+}) => {
const invoices = await prisma.invoice.findMany({
where: {
workspaceId,
+ type,
},
select: {
id: true,
@@ -67,7 +80,8 @@ const payoutInvoices = async (workspaceId: string) => {
return invoices.map((invoice) => {
return {
...invoice,
- description: "Dub Partner payout",
+ description:
+ type === "partnerPayout" ? "Dub Partner payout" : "Dub Domain renewal",
pdfUrl: `${APP_DOMAIN}/invoices/${invoice.id}`,
};
});