Skip to content

Commit d1ca3b6

Browse files
committed
add conditional check
1 parent 5211434 commit d1ca3b6

3 files changed

Lines changed: 38 additions & 25 deletions

File tree

apps/web/app/(ee)/partners.dub.co/(dashboard)/invoices/[payoutId]/route.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ export const GET = withPartnerProfile(async ({ partner, params }) => {
6161
});
6262
}
6363

64+
if (!["completed", "processing"].includes(payout.status)) {
65+
throw new DubApiError({
66+
code: "unauthorized",
67+
message:
68+
"This payout is not completed yet, hence no invoice is generated.",
69+
});
70+
}
71+
6472
const invoiceMetadata = [
6573
{
6674
label: "Program",

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

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,20 @@ function PayoutDetailsSheetContent({ payout }: PayoutDetailsSheetProps) {
8989
})}
9090
</strong>
9191

92-
<Tooltip content="View invoice">
93-
<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">
94-
<Link
95-
href={`/invoices/${payout.id}`}
96-
className="text-neutral-700"
97-
target="_blank"
98-
rel="noopener noreferrer"
99-
>
100-
<InvoiceDollar className="size-4" />
101-
</Link>
102-
</div>
103-
</Tooltip>
92+
{["completed", "processing"].includes(payout.status) && (
93+
<Tooltip content="View invoice">
94+
<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">
95+
<Link
96+
href={`/invoices/${payout.id}`}
97+
className="text-neutral-700"
98+
target="_blank"
99+
rel="noopener noreferrer"
100+
>
101+
<InvoiceDollar className="size-4" />
102+
</Link>
103+
</div>
104+
</Tooltip>
105+
)}
104106
</div>
105107
),
106108

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

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -103,19 +103,22 @@ export function PayoutTable() {
103103
payoutsEnabled={Boolean(partner?.payoutsEnabledAt)}
104104
minPayoutAmount={row.original.program.minPayoutAmount}
105105
/>
106-
<Tooltip content="View invoice">
107-
<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">
108-
<Link
109-
href={`/invoices/${row.original.id}`}
110-
className="text-neutral-700"
111-
target="_blank"
112-
rel="noopener noreferrer"
113-
onClick={(e) => e.stopPropagation()}
114-
>
115-
<InvoiceDollar className="size-4" />
116-
</Link>
117-
</div>
118-
</Tooltip>
106+
107+
{["completed", "processing"].includes(row.original.status) && (
108+
<Tooltip content="View invoice">
109+
<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">
110+
<Link
111+
href={`/invoices/${row.original.id}`}
112+
className="text-neutral-700"
113+
target="_blank"
114+
rel="noopener noreferrer"
115+
onClick={(e) => e.stopPropagation()}
116+
>
117+
<InvoiceDollar className="size-4" />
118+
</Link>
119+
</div>
120+
</Tooltip>
121+
)}
119122
</div>
120123
),
121124
},

0 commit comments

Comments
 (0)