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.

Fix discount maxDuration

Kiran Kf63f51d39d96
diff --git a/apps/web/ui/partners/add-edit-discount-sheet.tsx b/apps/web/ui/partners/add-edit-discount-sheet.tsx
index aa4a178343..5eb9103332 100644
--- a/apps/web/ui/partners/add-edit-discount-sheet.tsx
+++ b/apps/web/ui/partners/add-edit-discount-sheet.tsx
@@ -75,27 +75,31 @@ function DiscountSheetContent({
formState: { errors },
} = useForm<FormData>({
defaultValues: {
- ...(discount && {
- amount: discount.amount
- ? discount.type === "flat"
- ? discount.amount / 100
- : discount.amount
- : 0,
- type: discount.type || "flat",
- maxDuration:
- discount?.maxDuration === null
- ? Infinity
- : discount?.maxDuration || 0,
- couponId: discount.couponId || "",
- couponTestId: discount.couponTestId || "",
- }),
+ amount:
+ discount?.type === "flat" ? discount.amount / 100 : discount?.amount,
+ type: discount?.type || "percentage",
+ maxDuration:
+ discount?.maxDuration === null ? Infinity : discount?.maxDuration || 0,
+ couponId: discount?.couponId || "",
+ couponTestId: discount?.couponTestId || "",
includedPartnerIds: null,
excludedPartnerIds: null,
},
});
- const [type, amount, includedPartnerIds = [], excludedPartnerIds = []] =
- watch(["type", "amount", "includedPartnerIds", "excludedPartnerIds"]);
+ const [
+ type,
+ amount,
+ includedPartnerIds = [],
+ excludedPartnerIds = [],
+ maxDuration,
+ ] = watch([
+ "type",
+ "amount",
+ "includedPartnerIds",
+ "excludedPartnerIds",
+ "maxDuration",
+ ]);
const { data: discountPartners, loading: isLoadingDiscountPartners } =
useDiscountPartners({
@@ -288,7 +292,8 @@ function DiscountSheetContent({
setValue(
"maxDuration",
recurring
- ? discount?.maxDuration || 3
+ ? discount?.maxDuration ||
+ Infinity
: 0,
);
}