The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
added upgrade plan modal
Steven Teya38e071c02c0
diff --git a/app/api/cron/import/route.ts b/app/api/cron/import/route.tsindex 712ce7e7ea..f7f6f958bd 100644--- a/app/api/cron/import/route.ts+++ b/app/api/cron/import/route.ts@@ -6,7 +6,7 @@ import { Receiver } from "@upstash/qstash";import prisma from "#/lib/prisma";import { randomBadgeColor } from "@/components/app/links/tag-badge";-export const receiver = new Receiver({+const receiver = new Receiver({currentSigningKey: process.env.QSTASH_CURRENT_SIGNING_KEY || "",nextSigningKey: process.env.QSTASH_NEXT_SIGNING_KEY || "",});diff --git a/components/app/modals/upgrade-plan-modal.tsx b/components/app/modals/upgrade-plan-modal.tsxindex b058b61e2e..72244beb7e 100644--- a/components/app/modals/upgrade-plan-modal.tsx+++ b/components/app/modals/upgrade-plan-modal.tsx@@ -11,6 +11,10 @@ import { useRouter } from "next/router";import Link from "next/link";import { motion } from "framer-motion";import { STAGGER_CHILD_VARIANTS } from "#/lib/constants";+import { CheckCircleFill } from "@/components/shared/icons";+import { capitalize } from "#/lib/utils";+import { PLANS } from "#/lib/stripe/utils";+import { getStripe } from "#/lib/stripe/client";function UpgradePlanModal({showUpgradePlanModal,@@ -23,6 +27,16 @@ function UpgradePlanModal({}) {const router = useRouter();const { slug } = router.query;+ const features = [+ "Unlimited custom domains",+ "Unlimited team members",+ "Unlimited link history",+ "Track 50x more link clicks per month",+ "Redirect your root domain",+ "Custom QR Code logo",+ ];+ const [period, setPeriod] = useState<"monthly" | "yearly">("yearly");+ const [clicked, setClicked] = useState(false);return (<ModalshowModal={showUpgradePlanModal}@@ -63,21 +77,94 @@ function UpgradePlanModal({Enjoy higher limits and more powerful features with our Pro plan.</motion.p></motion.div>- <div className="flex flex-col space-y-3 bg-gray-50 px-4 py-8 text-left sm:px-16">- <Button- text="Upgrade to Pro Monthly for $9/mo"- onClick={() => {- setShowUpgradePlanModal(false);- }}- />- {welcomeFlow && (- <Link- href={`/${slug}`}- className="text-center text-xs text-gray-500 underline underline-offset-4 transition-colors hover:text-gray-800"- >- Skip for now- </Link>- )}+ <div className="bg-gray-50 px-4 py-8 text-left sm:px-16">+ <motion.div+ className="flex flex-col space-y-3"+ variants={STAGGER_CHILD_VARIANTS}+ initial="hidden"+ animate="show"+ >+ <div className="mb-4">+ <div className="mb-2 flex items-center justify-between">+ <div className="flex items-center space-x-2">+ <h4 className="font-medium text-gray-900">+ Pro {capitalize(period)}+ </h4>+ <span className="rounded-full border border-gray-400 px-2 py-px text-sm text-gray-500">+ {period === "monthly" ? "$9/month" : "$90/year"}+ </span>+ </div>+ <button+ onClick={() => {+ setPeriod(period === "monthly" ? "yearly" : "monthly");+ }}+ className="text-xs text-gray-500 underline"+ >+ Switch to {period === "monthly" ? "yearly" : "monthly"}+ </button>+ </div>+ <motion.div+ variants={{+ show: {+ transition: {+ staggerChildren: 0.05,+ },+ },+ }}+ initial="hidden"+ animate="show"+ className="flex flex-col space-y-2"+ >+ {features.map((feature, i) => (+ <motion.div+ key={i}+ variants={STAGGER_CHILD_VARIANTS}+ className="flex items-center space-x-2 text-sm text-gray-500"+ >+ <CheckCircleFill className="h-5 w-5 text-green-500" />+ <span>{feature}</span>+ </motion.div>+ ))}+ </motion.div>+ </div>+ <Button+ text={`Upgrade to Pro ${capitalize(period)}`}+ loading={clicked}+ onClick={() => {+ setClicked(true);+ fetch(+ `/api/projects/${slug}/billing/upgrade?priceId=${+ PLANS.find((p) => p.slug === "pro")!.price[period].priceIds[+ process.env.NEXT_PUBLIC_VERCEL_ENV === "production"+ ? "production"+ : "test"+ ]+ }`,+ {+ method: "POST",+ },+ )+ .then(async (res) => {+ const data = await res.json();+ const { id: sessionId } = data;+ const stripe = await getStripe();+ stripe?.redirectToCheckout({ sessionId });+ })+ .catch((err) => {+ alert(err);+ setClicked(false);+ });+ }}+ />+ {welcomeFlow && (+ <Link+ href={`/${slug}`}+ className="text-center text-xs text-gray-500 underline underline-offset-4 transition-colors hover:text-gray-800"+ >+ Skip for now+ </Link>+ )}+ </motion.div></div></div></Modal>diff --git a/components/app/projects/settings/plan-usage.tsx b/components/app/projects/settings/plan-usage.tsxindex 00b283e00d..56bf3dfaa2 100644--- a/components/app/projects/settings/plan-usage.tsx+++ b/components/app/projects/settings/plan-usage.tsx@@ -53,7 +53,7 @@ export default function PlanUsage() {});}, 1000);}- }, [router.query.success, plan]);+ }, [router.query.success]);return (<div className="rounded-lg border border-gray-200 bg-white">diff --git a/lib/api/domains.ts b/lib/api/domains.tsindex 0bc98e8b3d..5692b0565e 100644--- a/lib/api/domains.ts+++ b/lib/api/domains.ts@@ -235,13 +235,13 @@ export async function deleteDomainAndLinks(domain: string) {domain,},});- // const pipeline = redis.pipeline();- // links.forEach(({ key }) => {- // pipeline.del(`${domain}:${key}`);- // });- // pipeline.del(`root:${domain}`);+ const pipeline = redis.pipeline();+ links.forEach(({ key }) => {+ pipeline.del(`${domain}:${key}`);+ });+ pipeline.del(`root:${domain}`);return await Promise.allSettled([- // pipeline.exec(), // delete all links from redis+ pipeline.exec(), // delete all links from redis// remove all images from cloudinarycloudinary.v2.api.delete_resources_by_prefix(domain),// remove the domain from Vercel