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.

added tooltip for Plan & Usage

Steven Tey5013945a417d
diff --git a/components/app/settings/plan-usage.tsx b/components/app/settings/plan-usage.tsx
index 9b9759fdf9..7074c2df5a 100644
--- a/components/app/settings/plan-usage.tsx
+++ b/components/app/settings/plan-usage.tsx
@@ -153,40 +153,7 @@ export default function PlanUsage() {
<div className="h-3 w-28 bg-gray-200 rounded-full animate-pulse" />
)}
{plan ? (
- plan === "Pro 1M" ? (
- <div className="flex space-x-3">
- <a
- href="mailto:[email protected]?subject=Upgrade%20to%20Enterprise%20Plan"
- className="flex justify-center items-center bg-violet-600 text-white border-violet-600 hover:text-violet-600 hover:bg-white h-9 w-24 text-sm border rounded-md focus:outline-none transition-all ease-in-out duration-150"
- >
- Contact Us
- </a>
- <button
- onClick={() => {
- setClicked(true);
- fetch(`/api/stripe/manage-subscription`, {
- method: "POST",
- })
- .then(async (res) => {
- const url = await res.json();
- router.push(url);
- })
- .catch((err) => {
- alert(err);
- setClicked(false);
- });
- }}
- disabled={clicked}
- className={`${
- clicked
- ? "cursor-not-allowed bg-gray-100 border-gray-200"
- : "bg-black text-white border-black hover:text-black hover:bg-white"
- } h-9 w-40 text-sm border rounded-md focus:outline-none transition-all ease-in-out duration-150`}
- >
- {clicked ? <LoadingDots /> : "Manage Subscription"}
- </button>
- </div>
- ) : (
+ plan === "Free" ? (
<button
onClick={() => {
setClicked(true);
@@ -213,6 +180,41 @@ export default function PlanUsage() {
>
{clicked ? <LoadingDots /> : "Upgrade"}
</button>
+ ) : (
+ <div className="flex space-x-3">
+ {plan === "Pro 1M" && (
+ <a
+ href="mailto:[email protected]?subject=Upgrade%20to%20Enterprise%20Plan"
+ className="flex justify-center items-center bg-violet-600 text-white border-violet-600 hover:text-violet-600 hover:bg-white h-9 w-24 text-sm border rounded-md focus:outline-none transition-all ease-in-out duration-150"
+ >
+ Contact Us
+ </a>
+ )}
+ <button
+ onClick={() => {
+ setClicked(true);
+ fetch(`/api/stripe/manage-subscription`, {
+ method: "POST",
+ })
+ .then(async (res) => {
+ const url = await res.json();
+ router.push(url);
+ })
+ .catch((err) => {
+ alert(err);
+ setClicked(false);
+ });
+ }}
+ disabled={clicked}
+ className={`${
+ clicked
+ ? "cursor-not-allowed bg-gray-100 border-gray-200"
+ : "bg-black text-white border-black hover:text-black hover:bg-white"
+ } h-9 w-40 text-sm border rounded-md focus:outline-none transition-all ease-in-out duration-150`}
+ >
+ {clicked ? <LoadingDots /> : "Manage Subscription"}
+ </button>
+ </div>
)
) : (
<div className="h-9 w-24 bg-gray-200 rounded-md animate-pulse" />
diff --git a/components/shared/tooltip.tsx b/components/shared/tooltip.tsx
index 0701d826e8..c436b6d8b2 100644
--- a/components/shared/tooltip.tsx
+++ b/components/shared/tooltip.tsx
@@ -1,9 +1,8 @@
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
-import { ReactNode, useRef, useState } from "react";
+import { ReactNode, useEffect, useRef, useState } from "react";
import { motion, AnimatePresence, useAnimation } from "framer-motion";
-import { PRO_TIERS } from "@/lib/constants";
+import { PLAN_FROM_USAGE_LIMIT, PRO_TIERS } from "@/lib/constants";
import Slider from "@/components/shared/slider";
-import { nFormatter } from "@/lib/utils";
export default function Tooltip({
children,
@@ -93,13 +92,15 @@ export default function Tooltip({
<TooltipPrimitive.Content
sideOffset={4}
side="top"
- className="hidden sm:block animate-slide-up-fade items-center rounded-md px-4 py-2.5 z-20 bg-white border border-gray-200 drop-shadow-lg"
+ className="hidden sm:block animate-slide-up-fade items-center rounded-md overflow-hidden z-20 bg-white border border-gray-200 drop-shadow-lg"
>
<TooltipPrimitive.Arrow className="fill-current text-white" />
{typeof content === "string" ? (
- <span className="block text-sm text-center text-gray-700 max-w-xs">
- {content}
- </span>
+ <div className="px-4 py-2.5">
+ <span className="block text-sm text-center text-gray-700 max-w-xs">
+ {content}
+ </span>
+ </div>
) : (
content
)}
@@ -116,6 +117,7 @@ export default function Tooltip({
import Link from "next/link";
import BlurImage from "@/components/shared/blur-image";
+import { nFormatter } from "@/lib/utils";
export function TooltipContent({
title,
@@ -127,7 +129,7 @@ export function TooltipContent({
ctaLink: string;
}) {
return (
- <div className="max-w-xs flex flex-col text-center items-center space-y-3 py-2">
+ <div className="max-w-xs flex flex-col text-center items-center space-y-3 p-5">
<p className="text-sm text-gray-700">{title}</p>
<Link href={ctaLink}>
<a className="py-1.5 px-3 bg-black hover:bg-white rounded-full border border-black text-sm text-white hover:text-black transition-all mt-4">
@@ -157,16 +159,34 @@ export function OGImageProxy() {
);
}
-export function ProTiers({ usageLimit }: { usageLimit: number }) {
+export function ProTiers({ usageLimit }: { usageLimit?: number }) {
const [tier, setTier] = useState(
- PRO_TIERS.map((t) => t.quota).indexOf(usageLimit)
+ usageLimit > 1000 ? PRO_TIERS.map((t) => t.quota).indexOf(usageLimit) : 0
);
+
return (
- <div className="max-w-md flex flex-col text-center items-center space-y-2 p-5">
- <Slider value={tier} setValue={setTier} maxValue={PRO_TIERS.length - 1} />
- <p className="text-gray-600 text-sm">
- Up to {nFormatter(PRO_TIERS[tier].quota)} link clicks/mo
- </p>
+ <div className="w-full rounded-md">
+ <div className="max-w-md flex justify-between items-center w-full p-5">
+ <h3 className="text-2xl text-transparent bg-clip-text bg-gradient-to-r from-blue-600 to-cyan-600">
+ {PLAN_FROM_USAGE_LIMIT[PRO_TIERS[tier].quota]}
+ </h3>
+ <div className="flex items-center">
+ <p className="text-2xl font-semibold text-gray-700">
+ ${PRO_TIERS[tier].price}
+ </p>
+ <p className="text-sm text-gray-700">/mo</p>
+ </div>
+ </div>
+ <div className="w-full flex flex-col items-center space-y-1 bg-gray-50 text-center p-5 border-t border-gray-200">
+ <Slider
+ value={tier}
+ setValue={setTier}
+ maxValue={PRO_TIERS.length - 1}
+ />
+ <p className="text-sm text-gray-700">
+ Up to {nFormatter(PRO_TIERS[tier].quota)} link clicks/mo
+ </p>
+ </div>
</div>
);
}