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.

fix sidebarUsage valueInCents

Steven Teye57e1b49c2ab
diff --git a/apps/web/ui/layout/sidebar/sidebar-usage.tsx b/apps/web/ui/layout/sidebar/sidebar-usage.tsx
index c39494a322..82cbaa0b67 100644
--- a/apps/web/ui/layout/sidebar/sidebar-usage.tsx
+++ b/apps/web/ui/layout/sidebar/sidebar-usage.tsx
@@ -318,56 +318,66 @@ const UsageRow = forwardRef<HTMLDivElement, UsageRowProps>(
</span>
</div>
{!loading ? (
- valueInCents ? (
+ <div className="flex items-center">
<span className="text-xs font-medium text-neutral-600">
- {formatUsdFromCents(usage!)} of {formatUsdFromCents(limit!)}
- </span>
- ) : (
- <div className="flex items-center">
- <span className="text-xs font-medium text-neutral-600">
- <NumberFlow value={usage} /> of{" "}
- <motion.span
- className={cn(
- "relative transition-colors duration-150",
- showNextPlan && nextPlanLimit
- ? "text-neutral-400"
- : "text-neutral-600",
- )}
- >
- {formatNumber(limit)}
- {showNextPlan && nextPlanLimit && (
- <motion.span
- className="absolute bottom-[45%] left-0 h-[1px] bg-neutral-400"
- initial={{ width: "0%" }}
- animate={{ width: "100%" }}
- transition={{
- duration: 0.25,
- ease: "easeInOut",
- }}
- />
- )}
- </motion.span>
- </span>
- <AnimatePresence>
+ <NumberFlow
+ value={usage}
+ format={
+ valueInCents
+ ? {
+ style: "currency",
+ currency: "USD",
+ trailingZeroDisplay: "stripIfInteger",
+ }
+ : undefined
+ }
+ />{" "}
+ of{" "}
+ <motion.span
+ className={cn(
+ "relative transition-colors duration-150",
+ showNextPlan && nextPlanLimit
+ ? "text-neutral-400"
+ : "text-neutral-600",
+ )}
+ >
+ {valueInCents
+ ? formatUsdFromCents(limit)
+ : formatNumber(limit)}
{showNextPlan && nextPlanLimit && (
- <motion.div
- className="flex items-center"
- initial={{ width: 0, opacity: 0 }}
- animate={{ width: "auto", opacity: 1 }}
- exit={{ width: 0, opacity: 0 }}
+ <motion.span
+ className="absolute bottom-[45%] left-0 h-[1px] bg-neutral-400"
+ initial={{ width: "0%" }}
+ animate={{ width: "100%" }}
transition={{
duration: 0.25,
- ease: [0.4, 0, 0.2, 1], // Custom cubic-bezier for smooth movement
+ ease: "easeInOut",
}}
- >
- <motion.span className="ml-1 whitespace-nowrap text-xs font-medium text-blue-600">
- {formatNumber(nextPlanLimit)}
- </motion.span>
- </motion.div>
+ />
)}
- </AnimatePresence>
- </div>
- )
+ </motion.span>
+ </span>
+ <AnimatePresence>
+ {showNextPlan && nextPlanLimit && (
+ <motion.div
+ className="flex items-center"
+ initial={{ width: 0, opacity: 0 }}
+ animate={{ width: "auto", opacity: 1 }}
+ exit={{ width: 0, opacity: 0 }}
+ transition={{
+ duration: 0.25,
+ ease: [0.4, 0, 0.2, 1], // Custom cubic-bezier for smooth movement
+ }}
+ >
+ <motion.span className="ml-1 whitespace-nowrap text-xs font-medium text-blue-600">
+ {valueInCents
+ ? formatUsdFromCents(nextPlanLimit)
+ : formatNumber(nextPlanLimit)}
+ </motion.span>
+ </motion.div>
+ )}
+ </AnimatePresence>
+ </div>
) : (
<div className="h-4 w-16 animate-pulse rounded-md bg-neutral-500/10" />
)}