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.

revalidate path intelligently

Steven Teyb5bb7da13e5e
diff --git a/apps/web/lib/actions/partners/update-program.ts b/apps/web/lib/actions/partners/update-program.ts
index 2c8efbd102..5cb010212e 100644
--- a/apps/web/lib/actions/partners/update-program.ts
+++ b/apps/web/lib/actions/partners/update-program.ts
@@ -27,21 +27,21 @@ export const updateProgramAction = authActionClient
.action(async ({ parsedInput, ctx }) => {
const { workspace } = ctx;
const {
- defaultFolderId,
name,
- holdingPeriodDays,
- minPayoutAmount,
- cookieLength,
- domain,
- url,
logo,
wordmark,
brandColor,
landerData,
+ domain,
+ url,
linkStructure,
supportEmail,
helpUrl,
termsUrl,
+ holdingPeriodDays,
+ minPayoutAmount,
+ cookieLength,
+ defaultFolderId,
} = parsedInput;
const programId = getDefaultProgramIdOrThrow(workspace);
@@ -77,20 +77,20 @@ export const updateProgramAction = authActionClient
},
data: {
name,
- cookieLength,
- holdingPeriodDays,
- minPayoutAmount,
- domain,
- url,
- brandColor,
logo: logoUrl ?? undefined,
wordmark: wordmarkUrl ?? undefined,
+ brandColor,
landerData: landerData === null ? Prisma.JsonNull : landerData,
- defaultFolderId,
+ domain,
+ url,
linkStructure,
supportEmail,
helpUrl,
termsUrl,
+ cookieLength,
+ holdingPeriodDays,
+ minPayoutAmount,
+ defaultFolderId,
},
});
@@ -104,10 +104,26 @@ export const updateProgramAction = authActionClient
? [storage.delete(program.wordmark.replace(`${R2_URL}/`, ""))]
: []),
- // Revalidate public pages
- revalidatePath(`/partners.dub.co/${program.slug}`),
- revalidatePath(`/partners.dub.co/${program.slug}/apply`),
- revalidatePath(`/partners.dub.co/${program.slug}/apply/success`),
+ /*
+ Revalidate public pages if the following fields were updated:
+ - name
+ - logo
+ - wordmark
+ - brand color
+ - lander data
+ */
+ ...(name !== program.name ||
+ logoUrl ||
+ wordmarkUrl ||
+ brandColor !== program.brandColor ||
+ landerData
+ ? [
+ revalidatePath(`/partners.dub.co/${program.slug}`),
+ revalidatePath(`/partners.dub.co/${program.slug}/apply`),
+ revalidatePath(`/partners.dub.co/${program.slug}/apply/form`),
+ revalidatePath(`/partners.dub.co/${program.slug}/apply/success`),
+ ]
+ : []),
]),
);
});