From 2c36a54c9482a3c015161a092312aeea0198dacc Mon Sep 17 00:00:00 2001 From: josh <144584931+dancer@users.noreply.github.com> Date: Sun, 21 Sep 2025 13:18:18 +0100 Subject: [PATCH] fix credit card gateway error (#1231) --- components/chat.tsx | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/components/chat.tsx b/components/chat.tsx index b4998ad..3abe0de 100644 --- a/components/chat.tsx +++ b/components/chat.tsx @@ -14,7 +14,6 @@ import type { VisibilityType } from './visibility-selector'; import { useArtifactSelector } from '@/hooks/use-artifact'; import { unstable_serialize } from 'swr/infinite'; import { getChatHistoryPaginationKey } from './sidebar-history'; -import { toast } from './toast'; import type { Session } from 'next-auth'; import { useSearchParams } from 'next/navigation'; import { useChatVisibility } from '@/hooks/use-chat-visibility'; @@ -63,7 +62,8 @@ export function Chat({ const [input, setInput] = useState(''); const [usage, setUsage] = useState(initialLastContext); - const [showCreditCardAlert, setShowCreditCardAlert] = useState(false); + const [showErrorAlert, setShowErrorAlert] = useState(false); + const [errorMessage, setErrorMessage] = useState(''); const [currentModelId, setCurrentModelId] = useState(initialChatModel); const currentModelIdRef = useRef(currentModelId); @@ -108,17 +108,8 @@ export function Chat({ }, onError: (error) => { if (error instanceof ChatSDKError) { - // Check if it's a credit card error - if ( - error.message?.includes('AI Gateway requires a valid credit card') - ) { - setShowCreditCardAlert(true); - } else { - toast({ - type: 'error', - description: error.message, - }); - } + setErrorMessage(error.message); + setShowErrorAlert(true); } }, }); @@ -218,8 +209,8 @@ export function Chat({ />