@@ -16,7 +16,7 @@ import { toast } from "sonner"
1616import { useDocumentMutations } from "../../hooks/use-document-mutations"
1717import { useCustomer } from "autumn-js/react"
1818import { useTokenUsage } from "@/hooks/use-token-usage"
19- import { tokensToCredits , formatUsageNumber } from "@/lib/billing-utils"
19+ import { formatUsageNumber } from "@/lib/billing-utils"
2020import { SpaceSelector } from "../space-selector"
2121import { useIsMobile } from "@hooks/use-mobile"
2222import { addDocumentParam } from "@/lib/search-params"
@@ -127,11 +127,8 @@ export function AddDocument({
127127 const autumn = useCustomer ( )
128128 const {
129129 tokensUsed,
130- tokensLimit,
131- tokensPercent,
132130 searchesUsed,
133- searchesLimit,
134- searchesPercent,
131+ planUsagePct,
135132 hasPaidPlan,
136133 isLoading : isLoadingUsage ,
137134 } = useTokenUsage ( autumn )
@@ -298,72 +295,46 @@ export function AddDocument({
298295 dmSansClassName ( ) ,
299296 ) }
300297 >
301- Credits
298+ Plan usage
302299 </ span >
303300 < span
304301 className = { cn (
305- "text-sm font-medium" ,
302+ "text-sm font-medium tabular-nums " ,
306303 hasPaidPlan ? "text-[#4BA0FA]" : "text-[#737373]" ,
307304 dmSansClassName ( ) ,
308305 ) }
309306 >
310307 { isLoadingUsage
311308 ? "…"
312- : `${ tokensToCredits ( tokensUsed ) } / ${ tokensToCredits ( tokensLimit ) } ` }
309+ : `${ planUsagePct < 1 && planUsagePct > 0 ? "< 1" : Math . round ( planUsagePct ) } % used ` }
313310 </ span >
314311 </ div >
315312 < div className = "h-2 w-full rounded-[40px] bg-[#2E353D] p-px overflow-hidden" >
316313 < div
317314 className = "h-full rounded-[40px]"
318315 style = { {
319- width : `${ tokensPercent } %` ,
316+ width : `${ planUsagePct } %` ,
320317 background :
321- tokensPercent > 80
318+ planUsagePct > 80
322319 ? "#ef4444"
323320 : hasPaidPlan
324321 ? "linear-gradient(to right, #4BA0FA 80%, #002757 100%)"
325322 : "#0054AD" ,
326323 } }
324+ title = { `${ formatUsageNumber ( tokensUsed ) } tokens · ${ formatUsageNumber ( searchesUsed ) } queries` }
327325 />
328326 </ div >
329- </ div >
330-
331- < div className = "flex flex-col gap-2" >
332- < div className = "flex justify-between items-center" >
333- < span
327+ { ! isLoadingUsage && (
328+ < p
334329 className = { cn (
335- "text-[#FAFAFA] text-sm font-medium " ,
330+ "text-xs text-[#737373] tabular-nums " ,
336331 dmSansClassName ( ) ,
337332 ) }
338333 >
339- Search Queries
340- </ span >
341- < span
342- className = { cn (
343- "text-sm font-medium" ,
344- hasPaidPlan ? "text-[#4BA0FA]" : "text-[#737373]" ,
345- dmSansClassName ( ) ,
346- ) }
347- >
348- { isLoadingUsage
349- ? "…"
350- : `${ formatUsageNumber ( searchesUsed ) } / ${ formatUsageNumber ( searchesLimit ) } ` }
351- </ span >
352- </ div >
353- < div className = "h-2 w-full rounded-[40px] bg-[#2E353D] p-px overflow-hidden" >
354- < div
355- className = "h-full rounded-[40px]"
356- style = { {
357- width : `${ searchesPercent } %` ,
358- background :
359- searchesPercent > 80
360- ? "#ef4444"
361- : hasPaidPlan
362- ? "linear-gradient(to right, #4BA0FA 80%, #002757 100%)"
363- : "#0054AD" ,
364- } }
365- />
366- </ div >
334+ { formatUsageNumber ( tokensUsed ) } tokens ·{ " " }
335+ { formatUsageNumber ( searchesUsed ) } queries
336+ </ p >
337+ ) }
367338 </ div >
368339
369340 { ! hasPaidPlan && (
@@ -373,7 +344,7 @@ export function AddDocument({
373344 setIsUpgrading ( true )
374345 try {
375346 await autumn . attach ( {
376- productId : "api_pro" ,
347+ planId : "api_pro" ,
377348 successUrl : "https://app.supermemory.ai/settings#account" ,
378349 } )
379350 window . location . reload ( )
0 commit comments