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.

don't show CopyDefaultDiscountButton for edit card

Steven Tey4cb6ccc5f5cf
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/discount/group-discount.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/discount/group-discount.tsx
index 43ad1087ad..168463f42a 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/discount/group-discount.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/groups/[groupSlug]/discount/group-discount.tsx
@@ -75,7 +75,7 @@ const DiscountItem = ({
</div>
<div className="flex flex-col-reverse items-center gap-2 md:flex-row">
- {group.slug !== DEFAULT_PARTNER_GROUP.slug && (
+ {!discount && group.slug !== DEFAULT_PARTNER_GROUP.slug && (
<CopyDefaultDiscountButton />
)}
<Button
diff --git a/apps/web/scripts/migrations/backfill-partner-groups-verify.ts b/apps/web/scripts/migrations/backfill-partner-groups-verify.ts
new file mode 100644
index 0000000000..6eaddc1ae5
--- /dev/null
+++ b/apps/web/scripts/migrations/backfill-partner-groups-verify.ts
@@ -0,0 +1,64 @@
+import { prisma } from "@dub/prisma";
+import { deepEqual } from "@dub/utils";
+import "dotenv-flow/config";
+
+// verify that the rewards and discount are the same for all enrollments in a group
+async function main() {
+ const groups = await prisma.programEnrollment.groupBy({
+ by: [
+ "programId",
+ "groupId",
+ "saleRewardId",
+ "leadRewardId",
+ "clickRewardId",
+ "discountId",
+ ],
+ where: {
+ status: {
+ notIn: ["pending", "rejected", "banned"],
+ },
+ },
+ });
+
+ for (const group of groups) {
+ if (!group.groupId) {
+ console.log(`Some enrollments in ${group.programId} have no group id`);
+ continue;
+ }
+
+ const groupData = await prisma.partnerGroup.findUnique({
+ where: {
+ id: group.groupId,
+ },
+ });
+
+ if (!groupData) {
+ console.log(`Group ${group.groupId} not found`);
+ continue;
+ }
+
+ if (
+ !deepEqual(
+ {
+ saleRewardId: groupData.saleRewardId,
+ leadRewardId: groupData.leadRewardId,
+ clickRewardId: groupData.clickRewardId,
+ discountId: groupData.discountId,
+ },
+ {
+ saleRewardId: group.saleRewardId,
+ leadRewardId: group.leadRewardId,
+ clickRewardId: group.clickRewardId,
+ discountId: group.discountId,
+ },
+ )
+ ) {
+ console.log(`Group ${group.groupId} has different rewards`);
+ continue;
+ }
+
+ console.log(`Group ${group.groupId} is valid`);
+ }
+}
+
+main();