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.

simplify ReviewFraudAlertSheet

Steven Teyabd50af34d40
diff --git a/apps/web/app/(ee)/admin.dub.co/(dashboard)/fraud-alerts/review-fraud-alert-sheet.tsx b/apps/web/app/(ee)/admin.dub.co/(dashboard)/fraud-alerts/review-fraud-alert-sheet.tsx
index bdcc4ffa85..6103865854 100644
--- a/apps/web/app/(ee)/admin.dub.co/(dashboard)/fraud-alerts/review-fraud-alert-sheet.tsx
+++ b/apps/web/app/(ee)/admin.dub.co/(dashboard)/fraud-alerts/review-fraud-alert-sheet.tsx
@@ -2,7 +2,6 @@
import { PARTNER_PLATFORM_FIELDS } from "@/lib/partners/partner-platforms";
import { PartnerPlatformProps } from "@/lib/types";
-import { CommissionSchema } from "@/lib/zod/schemas/commissions";
import { fraudAlertSchema } from "@/lib/zod/schemas/fraud";
import {
MAX_FRAUD_REASON_LENGTH,
@@ -13,7 +12,6 @@ import {
ProgramEnrollmentSchema,
ProgramSchema,
} from "@/lib/zod/schemas/programs";
-import { CommissionStatusBadges } from "@/ui/partners/commission-status-badges";
import { PartnerAvatar } from "@/ui/partners/partner-avatar";
import { PayoutStatusBadges } from "@/ui/partners/payout-status-badges";
import { FraudAlertStatus } from "@dub/prisma/client";
@@ -56,12 +54,6 @@ type PartnerDetail = z.infer<typeof PartnerSchema> & {
payouts: (z.infer<typeof PayoutSchema> & {
program: ProgramInfo;
})[];
- commissions: (Pick<
- z.infer<typeof CommissionSchema>,
- "id" | "earnings" | "currency" | "status" | "createdAt"
- > & {
- program: ProgramInfo;
- })[];
};
const FRAUD_ALERT_STATUS_BADGES: Record<
@@ -289,24 +281,6 @@ function SheetContent({
) : null}
</Section>
- {/* Payouts table */}
- <Section title="Payouts">
- {isLoading ? (
- <LoadingState />
- ) : partner ? (
- <PayoutsTable payouts={partner.payouts} />
- ) : null}
- </Section>
-
- {/* Commissions table */}
- <Section title="Commissions">
- {isLoading ? (
- <LoadingState />
- ) : partner ? (
- <CommissionsTable commissions={partner.commissions} />
- ) : null}
- </Section>
-
{/* Ban history table */}
<Section title="Ban History">
{isLoading ? (
@@ -327,6 +301,15 @@ function SheetContent({
/>
) : null}
</Section>
+
+ {/* Payouts table */}
+ <Section title="Payouts">
+ {isLoading ? (
+ <LoadingState />
+ ) : partner ? (
+ <PayoutsTable payouts={partner.payouts} />
+ ) : null}
+ </Section>
</div>
</div>
@@ -372,122 +355,6 @@ function SheetContent({
);
}
-function PayoutsTable({ payouts }: { payouts: PartnerDetail["payouts"] }) {
- const table = useTable({
- data: payouts,
- columns: [
- {
- id: "program",
- header: "Program",
- cell: ({ row }) => <ProgramCell program={row.original.program} />,
- },
- {
- id: "amount",
- header: "Amount",
- cell: ({ row }) => currencyFormatter(row.original.amount),
- },
- {
- id: "status",
- header: "Status",
- cell: ({ row }) => {
- const badge =
- PayoutStatusBadges[
- row.original.status as keyof typeof PayoutStatusBadges
- ];
- return (
- <StatusBadge
- variant={
- (badge?.variant as
- | "pending"
- | "success"
- | "error"
- | "neutral") ?? "neutral"
- }
- >
- {badge?.label ?? row.original.status}
- </StatusBadge>
- );
- },
- },
- {
- id: "createdAt",
- header: "Date",
- cell: ({ row }) => formatDateTime(row.original.createdAt),
- },
- ],
- thClassName: "border-l-0",
- tdClassName: "border-l-0",
- className: "[&_tr:last-child>td]:border-b-transparent",
- scrollWrapperClassName: "min-h-0",
- });
-
- if (!payouts.length) {
- return <EmptyState message="No payouts" />;
- }
-
- return <Table {...table} />;
-}
-
-function CommissionsTable({
- commissions,
-}: {
- commissions: PartnerDetail["commissions"];
-}) {
- const table = useTable({
- data: commissions,
- columns: [
- {
- id: "program",
- header: "Program",
- cell: ({ row }) => <ProgramCell program={row.original.program} />,
- },
- {
- id: "earnings",
- header: "Earning",
- cell: ({ row }) => currencyFormatter(row.original.earnings),
- },
- {
- id: "status",
- header: "Status",
- cell: ({ row }) => {
- const badge =
- CommissionStatusBadges[
- row.original.status as keyof typeof CommissionStatusBadges
- ];
- return (
- <StatusBadge
- variant={
- (badge?.variant as
- | "pending"
- | "success"
- | "error"
- | "neutral") ?? "neutral"
- }
- >
- {badge?.label ?? row.original.status}
- </StatusBadge>
- );
- },
- },
- {
- id: "createdAt",
- header: "Date",
- cell: ({ row }) => formatDateTime(row.original.createdAt),
- },
- ],
- thClassName: "border-l-0",
- tdClassName: "border-l-0",
- className: "[&_tr:last-child>td]:border-b-transparent",
- scrollWrapperClassName: "min-h-0",
- });
-
- if (!commissions.length) {
- return <EmptyState message="No commissions" />;
- }
-
- return <Table {...table} />;
-}
-
function BanHistoryTable({
enrollments,
}: {
@@ -611,6 +478,62 @@ function FraudAlertsTable({
return <Table {...table} />;
}
+function PayoutsTable({ payouts }: { payouts: PartnerDetail["payouts"] }) {
+ const table = useTable({
+ data: payouts,
+ columns: [
+ {
+ id: "program",
+ header: "Program",
+ cell: ({ row }) => <ProgramCell program={row.original.program} />,
+ },
+ {
+ id: "amount",
+ header: "Amount",
+ cell: ({ row }) => currencyFormatter(row.original.amount),
+ },
+ {
+ id: "status",
+ header: "Status",
+ cell: ({ row }) => {
+ const badge =
+ PayoutStatusBadges[
+ row.original.status as keyof typeof PayoutStatusBadges
+ ];
+ return (
+ <StatusBadge
+ variant={
+ (badge?.variant as
+ | "pending"
+ | "success"
+ | "error"
+ | "neutral") ?? "neutral"
+ }
+ >
+ {badge?.label ?? row.original.status}
+ </StatusBadge>
+ );
+ },
+ },
+ {
+ id: "createdAt",
+ header: "Date",
+ cell: ({ row }) => formatDateTime(row.original.createdAt),
+ },
+ ],
+ thClassName: "border-l-0",
+ tdClassName: "border-l-0",
+ className: "[&_tr:last-child>td]:border-b-transparent",
+ scrollWrapperClassName: "min-h-0",
+ });
+
+ if (!payouts.length) {
+ return <EmptyState message="No payouts" />;
+ }
+
+ return <Table {...table} />;
+}
+
function ProgramCell({ program }: { program: ProgramInfo }) {
return (
<div className="flex items-center gap-2">
diff --git a/apps/web/app/(ee)/api/admin/partners/[id]/route.ts b/apps/web/app/(ee)/api/admin/partners/[id]/route.ts
index 9675bbd7ac..388347b3e6 100644
--- a/apps/web/app/(ee)/api/admin/partners/[id]/route.ts
+++ b/apps/web/app/(ee)/api/admin/partners/[id]/route.ts
@@ -26,81 +26,63 @@ export const GET = withAdmin(async ({ params }) => {
return new Response("Partner not found.", { status: 404 });
}
- const [programEnrollments, fraudAlerts, payouts, commissions] =
- await Promise.all([
- prisma.programEnrollment.findMany({
- where: {
- partnerId: id,
- status: "banned",
- },
- include: {
- program: {
- select: {
- id: true,
- name: true,
- logo: true,
- },
+ const [programEnrollments, fraudAlerts, payouts] = await Promise.all([
+ prisma.programEnrollment.findMany({
+ where: {
+ partnerId: id,
+ status: "banned",
+ },
+ include: {
+ program: {
+ select: {
+ id: true,
+ name: true,
+ logo: true,
},
},
- orderBy: {
- bannedAt: "desc",
- },
- }),
+ },
+ orderBy: {
+ bannedAt: "desc",
+ },
+ }),
- prisma.fraudAlert.findMany({
- where: {
- partnerId: id,
- },
- include: {
- program: {
- select: {
- id: true,
- name: true,
- logo: true,
- },
+ prisma.fraudAlert.findMany({
+ where: {
+ partnerId: id,
+ },
+ include: {
+ program: {
+ select: {
+ id: true,
+ name: true,
+ logo: true,
},
},
- orderBy: {
- createdAt: "desc",
- },
- }),
+ },
+ orderBy: {
+ createdAt: "desc",
+ },
+ }),
- prisma.payout.findMany({
- where: {
- partnerId: id,
- },
- include: {
- program: {
- select: {
- id: true,
- name: true,
- logo: true,
- },
+ prisma.payout.findMany({
+ where: {
+ partnerId: id,
+ },
+ include: {
+ program: {
+ select: {
+ id: true,
+ name: true,
+ logo: true,
},
},
- orderBy: {
- createdAt: "desc",
- },
- }),
-
- prisma.commission.findMany({
- where: {
- partnerId: id,
- },
- include: {
- program: {
- select: {
- id: true,
- name: true,
- logo: true,
- },
- },
- },
- orderBy: {
- createdAt: "desc",
- },
- }),
- ]);
+ },
+ orderBy: {
+ createdAt: "desc",
+ },
+ take: 10,
+ }),
+ ]);
return NextResponse.json({
...partner,
@@ -111,6 +93,5 @@ export const GET = withAdmin(async ({ params }) => {
programEnrollments,
fraudAlerts,
payouts,
- commissions,
});
});