Add billing limit

This commit is contained in:
Dries Augustyns
2025-12-04 19:23:04 +01:00
parent 6cdbc43c8e
commit 5fc5bc68fd
4 changed files with 175 additions and 37 deletions
+5 -2
View File
@@ -16,10 +16,13 @@ export interface BillingLimitsData {
/**
* Hook to fetch billing limits for a project
*
* Free tier projects (no subscription): Shows total usage with 1000/month limit
* Paid tier projects (with subscription): Shows per-category usage with custom limits
*/
export function useBillingLimits(projectId: string | undefined, hasSubscription: boolean) {
export function useBillingLimits(projectId: string | undefined, billingEnabled: boolean) {
const {data, error, mutate, isLoading} = useSWR<BillingLimitsData>(
projectId && hasSubscription ? `/users/@me/projects/${projectId}/billing-limits` : null,
projectId && billingEnabled ? `/users/@me/projects/${projectId}/billing-limits` : null,
{
revalidateOnFocus: false,
refreshInterval: 30000, // Refresh every 30 seconds to keep usage updated