Check if saas before blocking credit insufficiencies (#5929)

fixes #5926
This commit is contained in:
ConnorYoh
2026-03-13 10:28:39 +00:00
committed by GitHub
parent 9969fe5a6d
commit 44e036da5a
4 changed files with 18 additions and 9 deletions
+4 -1
View File
@@ -1,6 +1,7 @@
import { useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { useSaaSBilling } from '@app/contexts/SaasBillingContext';
import { useSaaSMode } from '@app/hooks/useSaaSMode';
import { getToolCreditCost } from '@app/utils/creditCosts';
import { CREDIT_EVENTS } from '@app/constants/creditEvents';
import type { ToolId } from '@app/types/toolId';
@@ -16,9 +17,11 @@ import type { ToolId } from '@app/types/toolId';
*/
export function useCreditCheck(operationType?: string) {
const billing = useSaaSBilling();
const isSaaSMode = useSaaSMode();
const { t } = useTranslation();
const checkCredits = useCallback(async (): Promise<string | null> => {
if (!isSaaSMode) return null; // Credits only apply in SaaS mode, not self-hosted
if (!billing) return null;
const { creditBalance, loading } = billing;
@@ -41,7 +44,7 @@ export function useCreditCheck(operationType?: string) {
}
return null;
}, [billing, operationType, t]);
}, [billing, isSaaSMode, operationType, t]);
return { checkCredits };
}