The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
prevent deleting partnerGroupDefaultLinkId
Steven Tey504bef8c57e9
diff --git a/apps/web/app/(ee)/api/partner-profile/programs/[programId]/links/[linkId]/route.ts b/apps/web/app/(ee)/api/partner-profile/programs/[programId]/links/[linkId]/route.tsindex 410b8b0832..7d9b243600 100644--- a/apps/web/app/(ee)/api/partner-profile/programs/[programId]/links/[linkId]/route.ts+++ b/apps/web/app/(ee)/api/partner-profile/programs/[programId]/links/[linkId]/route.ts@@ -183,6 +183,14 @@ export const DELETE = withPartnerProfile(async ({ partner, params }) => {});}+ // Check if this is a default link+ if (link.partnerGroupDefaultLinkId) {+ throw new DubApiError({+ code: "forbidden",+ message: "You cannot delete your default link.",+ });+ }+// Check if link has any clicks, leads, or salesif (link.clicks > 0 || link.leads > 0 || link.saleAmount > 0) {throw new DubApiError({diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-controls.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-controls.tsxindex f501136c44..aa892b7e59 100644--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-controls.tsx+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/links/partner-link-controls.tsx@@ -41,7 +41,10 @@ export function PartnerLinkControls({});const canDelete =- link.clicks === 0 && link.leads === 0 && link.saleAmount === 0;+ !link.partnerGroupDefaultLinkId &&+ link.clicks === 0 &&+ link.leads === 0 &&+ link.saleAmount === 0;const { setShowDeletePartnerLinkModal, DeletePartnerLinkModal } =useDeletePartnerLinkModal({@@ -133,9 +136,11 @@ export function PartnerLinkControls({className="h-9 px-2 font-medium"disabled={!canDelete}disabledTooltip={- !canDelete- ? "You can only delete links with 0 clicks, 0 leads, and $0 in sales."- : undefined+ link.partnerGroupDefaultLinkId+ ? "You cannot delete your default link."+ : !canDelete+ ? "You can only delete links with 0 clicks, 0 leads, and $0 in sales."+ : undefined}/></div>