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.

feat: enable social media cards as demo for free plan

flooorianflo8a438b71946f
diff --git a/apps/web/lib/api/links/process-link.ts b/apps/web/lib/api/links/process-link.ts
index 65faa1e058..dcda254910 100644
--- a/apps/web/lib/api/links/process-link.ts
+++ b/apps/web/lib/api/links/process-link.ts
@@ -64,7 +64,14 @@ export async function processLink({
(!workspace || workspace.plan === "free") &&
(!createdAt || new Date(createdAt) > new Date("2024-01-19"))
) {
- if (proxy || password || rewrite || expiresAt || ios || android || geo) {
+ // separate check for social media card activation with free plan
+ if (proxy) {
+ return {
+ link: payload,
+ error: "Social media cards need a Pro plan.",
+ code: "forbidden",
+ };
+ } else if (password || rewrite || expiresAt || ios || android || geo) {
return {
link: payload,
error:
diff --git a/apps/web/ui/modals/add-edit-link-modal/index.tsx b/apps/web/ui/modals/add-edit-link-modal/index.tsx
index f167dd8171..26d164d00f 100644
--- a/apps/web/ui/modals/add-edit-link-modal/index.tsx
+++ b/apps/web/ui/modals/add-edit-link-modal/index.tsx
@@ -412,8 +412,40 @@ function AddEditLinkModal({
} else {
const { error } = await res.json();
if (error) {
- toast.error(error.message);
const message = error.message.toLowerCase();
+
+ if (message === "social media cards need a pro plan.") {
+ toast.custom(
+ () => (
+ <div className="relative z-50 grid grid-cols-2 items-center gap-4 rounded-2xl border border-gray-200 bg-white p-4 shadow-md">
+ <div>
+ <p className="mb-1.5 text-sm text-gray-700">
+ Social media cards need a Pro plan.
+ </p>
+ <p className="text-xs text-gray-500">
+ Upgrade to Pro to get this feature.
+ </p>
+ </div>
+ <Button
+ text={`Upgrade to ${nextPlan.name}`}
+ onClick={() => {
+ queryParams({
+ set: {
+ upgrade: nextPlan.name.toLowerCase(),
+ },
+ });
+ }}
+ />
+ </div>
+ ),
+ {
+ duration: 10000,
+ },
+ );
+ } else {
+ toast.error(error.message);
+ }
+
if (message.includes("key") || message.includes("domain")) {
setKeyError(error.message);
} else if (message.includes("url")) {
diff --git a/apps/web/ui/modals/add-edit-link-modal/og-section.tsx b/apps/web/ui/modals/add-edit-link-modal/og-section.tsx
index 88c6243ee1..0346763e1a 100644
--- a/apps/web/ui/modals/add-edit-link-modal/og-section.tsx
+++ b/apps/web/ui/modals/add-edit-link-modal/og-section.tsx
@@ -147,29 +147,6 @@ export default function OGSection({
<Switch
fn={() => setData((prev) => ({ ...prev, proxy: !proxy }))}
checked={proxy}
- // custom social media cards is only available on Dub's Pro plan
- {...((!plan || plan === "free") && !proxy
- ? {
- disabledTooltip: (
- <TooltipContent
- title={`Custom Social Media Cards is only available on ${process.env.NEXT_PUBLIC_APP_NAME}'s Pro plan. Upgrade to Pro to use this feature.`}
- cta="Upgrade to Pro"
- {...(plan === "free"
- ? {
- onClick: () =>
- queryParams({
- set: {
- upgrade: "pro",
- },
- }),
- }
- : {
- href: `${HOME_DOMAIN}/pricing`,
- })}
- />
- ),
- }
- : {})}
/>
</div>