MCPcopy Index your code
hub / github.com/triggerdotdev/trigger.dev / UsageBar

Function UsageBar

apps/webapp/app/components/billing/UsageBar.tsx:15–125  ·  view source on GitHub ↗
({
  numberOfCurrentRuns,
  billingLimit,
  tierRunLimit,
  projectedRuns,
  subscribedToPaidTier = false,
}: UsageBarProps)

Source from the content-addressed store, hash-verified

13};
14
15export function UsageBar({
16 numberOfCurrentRuns,
17 billingLimit,
18 tierRunLimit,
19 projectedRuns,
20 subscribedToPaidTier = false,
21}: UsageBarProps) {
22 const getLargestNumber = Math.max(
23 numberOfCurrentRuns,
24 tierRunLimit ?? -Infinity,
25 projectedRuns,
26 billingLimit ?? -Infinity
27 );
28 //creates a maximum range for the progress bar, add 10% to the largest number so the bar doesn't reach the end
29 const maxRange = Math.round(getLargestNumber * 1.1);
30 const tierRunLimitPercentage = tierRunLimit ? Math.round((tierRunLimit / maxRange) * 100) : 0;
31 const projectedRunsPercentage = Math.round((projectedRuns / maxRange) * 100);
32 const billingLimitPercentage =
33 billingLimit !== undefined ? Math.round((billingLimit / maxRange) * 100) : 0;
34 const usagePercentage = Math.round((numberOfCurrentRuns / maxRange) * 100);
35
36 //cap the usagePercentage to the freeRunLimitPercentage
37 const usageCappedToLimitPercentage = Math.min(usagePercentage, tierRunLimitPercentage);
38
39 return (
40 <div className="h-fit w-full py-16">
41 <div className="relative h-3 w-full rounded-sm bg-charcoal-800">
42 {billingLimit && (
43 <motion.div
44 initial={{ width: 0 }}
45 animate={{ width: billingLimitPercentage + "%" }}
46 transition={{ duration: 1.5, type: "spring" }}
47 style={{ width: `${billingLimitPercentage}%` }}
48 className="absolute h-3 rounded-l-sm"
49 >
50 <Legend
51 text="Billing limit:"
52 value={formatNumberCompact(billingLimit)}
53 position="bottomRow2"
54 percentage={billingLimitPercentage}
55 tooltipContent={`Billing limit: ${formatNumberCompact(billingLimit)}`}
56 />
57 </motion.div>
58 )}
59 {tierRunLimit && (
60 <motion.div
61 initial={{ width: 0 }}
62 animate={{ width: tierRunLimitPercentage + "%" }}
63 transition={{ duration: 1.5, type: "spring" }}
64 style={{ width: `${tierRunLimitPercentage}%` }}
65 className="absolute h-3 rounded-l-sm bg-green-900/50"
66 >
67 <Legend
68 text={`${subscribedToPaidTier ? "Included free:" : "Free tier limit:"}`}
69 value={formatNumberCompact(tierRunLimit)}
70 position="bottomRow1"
71 percentage={tierRunLimitPercentage}
72 tooltipContent={`${

Callers

nothing calls this directly

Calls 4

formatNumberCompactFunction · 0.90
cnFunction · 0.90
maxMethod · 0.80
minMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…