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 optional description field to commission creation

Kiran K230c2097eb20
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/create-commission-sheet.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/create-commission-sheet.tsx
index bfc6953e11..5e74bf79ba 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/create-commission-sheet.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/commissions/create-commission-sheet.tsx
@@ -75,6 +75,7 @@ function CreateCommissionSheetContent(props: CreateCommissionSheetProps) {
saleEventDate,
saleAmount,
leadEventDate,
+ description,
] = watch([
"partnerId",
"date",
@@ -84,6 +85,7 @@ function CreateCommissionSheetContent(props: CreateCommissionSheetProps) {
"saleEventDate",
"saleAmount",
"leadEventDate",
+ "description",
]);
useEffect(() => {
@@ -365,6 +367,41 @@ function CreateCommissionSheetContent(props: CreateCommissionSheetProps) {
</span>
</div>
</div>
+
+ <div>
+ <div className="flex items-center justify-between">
+ <label
+ htmlFor="description"
+ className="text-sm font-medium text-neutral-800"
+ >
+ Description
+ <span className="font-normal text-neutral-500">
+ {" "}
+ (optional)
+ </span>
+ </label>
+ <span className="text-xs text-neutral-400">
+ {description?.length || 0}/190
+ </span>
+ </div>
+ <div className="mt-2">
+ <textarea
+ id="description"
+ rows={3}
+ maxLength={190}
+ className={cn(
+ "block w-full rounded-md border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm",
+ errors.description &&
+ "border-red-600 focus:border-red-500 focus:ring-red-600",
+ )}
+ placeholder="Add a description for this commission"
+ {...register("description", {
+ setValueAs: (value) =>
+ value === "" ? null : value,
+ })}
+ />
+ </div>
+ </div>
</div>
</ProgramSheetAccordionContent>
</ProgramSheetAccordionItem>
diff --git a/apps/web/lib/actions/partners/create-commission.ts b/apps/web/lib/actions/partners/create-commission.ts
index 77ed431a9b..a220254df3 100644
--- a/apps/web/lib/actions/partners/create-commission.ts
+++ b/apps/web/lib/actions/partners/create-commission.ts
@@ -34,6 +34,7 @@ export const createCommissionAction = authActionClient
saleEventDate,
leadEventDate,
leadEventName,
+ description,
} = parsedInput;
const programId = getDefaultProgramIdOrThrow(workspace);
@@ -63,6 +64,7 @@ export const createCommissionAction = authActionClient
quantity: 1,
createdAt: date ?? new Date(),
user,
+ description,
});
return;
diff --git a/apps/web/lib/partners/create-partner-commission.ts b/apps/web/lib/partners/create-partner-commission.ts
index 598d78fda2..78280597bc 100644
--- a/apps/web/lib/partners/create-partner-commission.ts
+++ b/apps/web/lib/partners/create-partner-commission.ts
@@ -47,7 +47,7 @@ export const createPartnerCommission = async ({
amount?: number;
quantity: number;
currency?: string;
- description?: string;
+ description?: string | null;
createdAt?: Date;
user?: Session["user"]; // user who created the manual commission
context?: RewardContext;