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.

INVOICE_AVAILABLE_PAYOUT_STATUSES

Steven Teyba06df688ef2
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-details-sheet.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-details-sheet.tsx
index e763a52953..5ac2784777 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-details-sheet.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-details-sheet.tsx
@@ -1,4 +1,7 @@
-import { PAYOUTS_SHEET_ITEMS_LIMIT } from "@/lib/partners/constants";
+import {
+ INVOICE_AVAILABLE_PAYOUT_STATUSES,
+ PAYOUTS_SHEET_ITEMS_LIMIT,
+} from "@/lib/partners/constants";
import usePartnerProfile from "@/lib/swr/use-partner-profile";
import { PartnerEarningsResponse, PartnerPayoutResponse } from "@/lib/types";
import { CommissionTypeIcon } from "@/ui/partners/comission-type-icon";
@@ -87,7 +90,7 @@ function PayoutDetailsSheetContent({ payout }: PayoutDetailsSheetProps) {
})}
</strong>
- {["completed", "processing"].includes(payout.status) && (
+ {INVOICE_AVAILABLE_PAYOUT_STATUSES.includes(payout.status) && (
<Tooltip content="View invoice">
<div className="flex h-5 w-5 items-center justify-center rounded-md transition-colors duration-150 hover:border hover:border-neutral-200 hover:bg-neutral-100">
<Link
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-table.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-table.tsx
index b6fd13ac83..dd1c88f11f 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-table.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/payouts/payout-table.tsx
@@ -1,5 +1,6 @@
"use client";
+import { INVOICE_AVAILABLE_PAYOUT_STATUSES } from "@/lib/partners/constants";
import usePartnerPayouts from "@/lib/swr/use-partner-payouts";
import usePartnerPayoutsCount from "@/lib/swr/use-partner-payouts-count";
import { PartnerPayoutResponse } from "@/lib/types";
@@ -113,7 +114,9 @@ export function PayoutTable() {
minPayoutAmount={row.original.program.minPayoutAmount}
/>
- {["completed", "processing"].includes(row.original.status) && (
+ {INVOICE_AVAILABLE_PAYOUT_STATUSES.includes(
+ row.original.status,
+ ) && (
<Tooltip content="View invoice">
<div className="flex h-5 w-5 items-center justify-center rounded-md transition-colors duration-150 hover:border hover:border-neutral-200 hover:bg-neutral-100">
<Link
diff --git a/apps/web/app/(ee)/partners.dub.co/invoices/[payoutId]/route.tsx b/apps/web/app/(ee)/partners.dub.co/invoices/[payoutId]/route.tsx
index a696293ab6..517b732036 100644
--- a/apps/web/app/(ee)/partners.dub.co/invoices/[payoutId]/route.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/invoices/[payoutId]/route.tsx
@@ -1,5 +1,6 @@
import { DubApiError } from "@/lib/api/errors";
import { withPartnerProfile } from "@/lib/auth/partner";
+import { INVOICE_AVAILABLE_PAYOUT_STATUSES } from "@/lib/partners/constants";
import { prisma } from "@dub/prisma";
import {
currencyFormatter,
@@ -60,7 +61,7 @@ export const GET = withPartnerProfile(async ({ partner, params }) => {
});
}
- if (!["completed", "processing"].includes(payout.status)) {
+ if (!INVOICE_AVAILABLE_PAYOUT_STATUSES.includes(payout.status)) {
throw new DubApiError({
code: "unauthorized",
message:
@@ -68,10 +69,6 @@ export const GET = withPartnerProfile(async ({ partner, params }) => {
});
}
- const EU_PARTNER =
- partner.country && EU_COUNTRY_CODES.includes(partner.country);
- const AU_PARTNER = partner.country && partner.country === "AU";
-
const invoiceMetadata = [
{
label: "Program",
diff --git a/apps/web/lib/partners/constants.ts b/apps/web/lib/partners/constants.ts
index 26286e40cc..a6f1844fc6 100644
--- a/apps/web/lib/partners/constants.ts
+++ b/apps/web/lib/partners/constants.ts
@@ -85,3 +85,10 @@ export const PROGRAM_IMPORT_SOURCES = [
helpUrl: "https://dub.co/help/article/migrating-from-partnerstack",
},
] as const;
+
+export const INVOICE_AVAILABLE_PAYOUT_STATUSES = [
+ "processing",
+ "processing",
+ "sent",
+ "completed",
+];