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.

add commission.list descriptions

Steven Tey301f967842e2
diff --git a/apps/web/lib/zod/schemas/commissions.ts b/apps/web/lib/zod/schemas/commissions.ts
index d44c7a2654..cad3298979 100644
--- a/apps/web/lib/zod/schemas/commissions.ts
+++ b/apps/web/lib/zod/schemas/commissions.ts
@@ -29,16 +29,50 @@ export const CommissionResponseSchema = CommissionSchema.merge(
export const getCommissionsQuerySchema = z
.object({
type: z.enum(["click", "lead", "sale"]).optional(),
- customerId: z.string().optional(),
- payoutId: z.string().optional(),
- partnerId: z.string().optional(),
- invoiceId: z.string().optional(),
- status: z.nativeEnum(CommissionStatus).optional(),
- sortBy: z.enum(["createdAt", "amount"]).default("createdAt"),
- sortOrder: z.enum(["asc", "desc"]).default("desc"),
- interval: z.enum(DATE_RANGE_INTERVAL_PRESETS).default("all"),
- start: parseDateSchema.optional(),
- end: parseDateSchema.optional(),
+ customerId: z
+ .string()
+ .optional()
+ .describe("Filter the list of commissions by the associated customer."),
+ payoutId: z
+ .string()
+ .optional()
+ .describe("Filter the list of commissions by the associated payout."),
+ partnerId: z
+ .string()
+ .optional()
+ .describe("Filter the list of commissions by the associated partner."),
+ invoiceId: z
+ .string()
+ .optional()
+ .describe(
+ "Filter the list of commissions by the associated invoice. Since invoiceId is unique on a per-program basis, this will only return one commission per invoice.",
+ ),
+ status: z
+ .nativeEnum(CommissionStatus)
+ .optional()
+ .describe(
+ "Filter the list of commissions by their corresponding status.",
+ ),
+ sortBy: z
+ .enum(["createdAt", "amount"])
+ .default("createdAt")
+ .describe("The field to sort the list of commissions by."),
+ sortOrder: z
+ .enum(["asc", "desc"])
+ .default("desc")
+ .describe("The sort order for the list of commissions."),
+ interval: z
+ .enum(DATE_RANGE_INTERVAL_PRESETS)
+ .default("all")
+ .describe("The interval to retrieve commissions for."),
+ start: parseDateSchema
+ .optional()
+ .describe(
+ "The start date of the date range to filter the commissions by.",
+ ),
+ end: parseDateSchema
+ .optional()
+ .describe("The end date of the date range to filter the commissions by."),
})
.merge(getPaginationQuerySchema({ pageSize: 100 }));
diff --git a/apps/web/ui/partners/payout-invoice-sheet.tsx b/apps/web/ui/partners/payout-invoice-sheet.tsx
index 8d3ebb0b25..ebc5533937 100644
--- a/apps/web/ui/partners/payout-invoice-sheet.tsx
+++ b/apps/web/ui/partners/payout-invoice-sheet.tsx
@@ -1,9 +1,9 @@
import { confirmPayoutsAction } from "@/lib/actions/partners/confirm-payouts";
import { PAYOUT_FEES } from "@/lib/partners/constants";
+import { mutatePrefix } from "@/lib/swr/mutate";
import usePaymentMethods from "@/lib/swr/use-payment-methods";
import usePayouts from "@/lib/swr/use-payouts";
import usePayoutsCount from "@/lib/swr/use-payouts-count";
-import useProgram from "@/lib/swr/use-program";
import useWorkspace from "@/lib/swr/use-workspace";
import { PayoutsCount } from "@/lib/types";
import { X } from "@/ui/shared/icons";
@@ -29,6 +29,7 @@ import {
truncate,
} from "@dub/utils";
import { useAction } from "next-safe-action/hooks";
+import { useParams } from "next/navigation";
import {
Dispatch,
Fragment,
@@ -44,7 +45,7 @@ interface PayoutInvoiceSheetProps {
}
function PayoutInvoiceSheetContent({ setIsOpen }: PayoutInvoiceSheetProps) {
- const { program } = useProgram();
+ const { programId } = useParams() as { programId: string };
const { id: workspaceId, slug, plan } = useWorkspace();
const { paymentMethods, loading: paymentMethodsLoading } =
usePaymentMethods();
@@ -103,6 +104,7 @@ function PayoutInvoiceSheetContent({ setIsOpen }: PayoutInvoiceSheetProps) {
const { executeAsync, isPending } = useAction(confirmPayoutsAction, {
onSuccess: async () => {
+ await mutatePrefix(`/api/programs/${programId}/payouts`);
toast.success(
"Payouts confirmed successfully! They will be processed soon.",
);
@@ -352,13 +354,13 @@ function PayoutInvoiceSheetContent({ setIsOpen }: PayoutInvoiceSheetProps) {
variant="primary"
loading={isPending}
onClick={async () => {
- if (!workspaceId || !program?.id || !selectedPaymentMethod) {
+ if (!workspaceId || !selectedPaymentMethod) {
return;
}
await executeAsync({
workspaceId,
- programId: program.id,
+ programId,
paymentMethodId: selectedPaymentMethod.id,
});
}}