11import { DialogClose } from "@radix-ui/react-dialog" ;
22import { Form , useNavigation } from "@remix-run/react" ;
33import { motion } from "framer-motion" ;
4+ import { ArrowUpCircleIcon } from "@heroicons/react/24/outline" ;
45import { PlusIcon } from "@heroicons/react/20/solid" ;
56import { useEffect , useState } from "react" ;
67import { type MatchedOrganization , useDashboardLimits } from "~/hooks/useOrganizations" ;
@@ -80,6 +81,7 @@ export function CreateDashboardButton({
8081 < CreateDashboardUpgradeDialog
8182 limits = { limits }
8283 canUpgrade = { ! ! canUpgrade }
84+ isFreePlan = { plan ?. v3Subscription ?. isPaying === false }
8385 organization = { organization }
8486 />
8587 ) : (
@@ -97,12 +99,38 @@ const PROGRESS_COLOR_ERROR = "#E11D48"; // rose-600 / error
9799function CreateDashboardUpgradeDialog ( {
98100 limits,
99101 canUpgrade,
102+ isFreePlan,
100103 organization,
101104} : {
102105 limits : { used : number ; limit : number } ;
103106 canUpgrade : boolean ;
107+ isFreePlan : boolean ;
104108 organization : MatchedOrganization ;
105109} ) {
110+
111+ if ( isFreePlan ) {
112+ return (
113+ < DialogContent >
114+ < DialogHeader > Upgrade to unlock dashboards</ DialogHeader >
115+ < div className = "flex items-center gap-4 pt-3" >
116+ < ArrowUpCircleIcon className = "ml-1 size-14 shrink-0 text-indigo-500" />
117+ < DialogDescription className = "pt-0" >
118+ Custom metric dashboards are available on paid plans. Upgrade to create dashboards and
119+ track your task metrics.
120+ </ DialogDescription >
121+ </ div >
122+ < DialogFooter className = "flex justify-between" >
123+ < DialogClose asChild >
124+ < Button variant = "secondary/medium" > Cancel</ Button >
125+ </ DialogClose >
126+ < LinkButton variant = "primary/medium" to = { v3BillingPath ( organization ) } >
127+ Upgrade plan
128+ </ LinkButton >
129+ </ DialogFooter >
130+ </ DialogContent >
131+ ) ;
132+ }
133+
106134 const percentage = Math . min ( limits . used / limits . limit , 1 ) ;
107135 const filled = percentage * PROGRESS_RING_CIRCUMFERENCE ;
108136
@@ -144,13 +172,17 @@ function CreateDashboardUpgradeDialog({
144172 < DialogDescription className = "pt-0" >
145173 { canUpgrade ? (
146174 < >
147- You've used all { limits . limit } of your custom dashboards. Upgrade your plan to create
148- more.
175+ { limits . limit === 1
176+ ? "Your plan includes 1 custom dashboard and it's already in use."
177+ : `You've used all ${ limits . limit } of your custom dashboards.` } { " " }
178+ Upgrade your plan to create more.
149179 </ >
150180 ) : (
151181 < >
152- You've used all { limits . limit } of your custom dashboards. To create more, request a
153- limit increase or visit the{ " " }
182+ { limits . limit === 1
183+ ? "Your plan includes 1 custom dashboard and it's already in use."
184+ : `You've used all ${ limits . limit } of your custom dashboards.` } { " " }
185+ To create more, request a limit increase or visit the{ " " }
154186 < TextLink to = { v3BillingPath ( organization ) } > billing page</ TextLink > for pricing
155187 details.
156188 </ >
0 commit comments