The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Update import-campaign.ts
Kiran K46258e61db7b
diff --git a/apps/web/lib/rewardful/import-campaign.ts b/apps/web/lib/rewardful/import-campaign.tsindex ae69887b9a..04cceec6f0 100644--- a/apps/web/lib/rewardful/import-campaign.ts+++ b/apps/web/lib/rewardful/import-campaign.ts@@ -38,12 +38,12 @@ export async function importCampaign({ programId }: { programId: string }) {reward_type === "amount" ? commission_amount_cents : commission_percent,};+ let rewardId: string | null = null;+const rewardFound = await prisma.reward.findFirst({where: newReward,});- let rewardId: string | null = null;-if (!rewardFound) {const reward = await prisma.reward.create({data: {@@ -64,13 +64,15 @@ export async function importCampaign({ programId }: { programId: string }) {}rewardId = reward.id;+ } else {+ rewardId = rewardFound.id;}return await rewardfulImporter.queue({programId,// we will only need to assign rewardId to affiliates// if it's not the defaultRewardId of the program (there's already a defaultRewardId)- ...(defaultRewardId && rewardId && { rewardId }),+ ...(defaultRewardId && { rewardId }),action: "import-affiliates",});}