aproli90 commited on
Commit
18aed00
·
verified ·
1 Parent(s): e8aec35

Upload 26 files

Browse files
Files changed (1) hide show
  1. app/components/chat/ApiKeyWarning.tsx +20 -25
app/components/chat/ApiKeyWarning.tsx CHANGED
@@ -1,28 +1,23 @@
1
- import React from 'react';
2
- import type { ProviderInfo } from '~/types/model';
3
-
4
- interface ApiKeyWarningProps {
5
- provider: ProviderInfo;
6
- apiKeys: Record<string, string>;
7
- }
8
-
9
  export const ApiKeyWarning: React.FC<ApiKeyWarningProps> = ({ provider, apiKeys }) => {
10
- const isApiKeyMissing = !apiKeys[provider?.name];
11
-
12
- if (!isApiKeyMissing) return null;
13
-
14
- return (
15
- <div className="bg-yellow-50 border-l-4 border-yellow-400 p-4 mb-4">
16
- <div className="flex">
17
- <div className="flex-shrink-0">
18
- <div className="i-ph:warning-circle text-yellow-400 text-2xl" />
19
- </div>
20
- <div className="ml-3">
21
- <p className="text-sm text-yellow-700">
22
- API key is missing for {provider.name}. Please add an API key in the settings to send messages.
23
- </p>
 
 
 
 
24
  </div>
25
  </div>
26
- </div>
27
- );
28
- };
 
 
 
 
 
 
 
 
 
1
  export const ApiKeyWarning: React.FC<ApiKeyWarningProps> = ({ provider, apiKeys }) => {
2
+ // Add a null check for provider before accessing its name
3
+ const isApiKeyMissing = !provider || !apiKeys[provider.name];
4
+
5
+ if (!isApiKeyMissing) return null;
6
+
7
+ return (
8
+ <div className="bg-yellow-50 border-l-4 border-yellow-400 p-4 mb-4">
9
+ <div className="flex">
10
+ <div className="flex-shrink-0">
11
+ <div className="i-ph:warning-circle text-yellow-400 text-2xl" />
12
+ </div>
13
+ <div className="ml-3">
14
+ <p className="text-sm text-yellow-700">
15
+ {provider
16
+ ? `API key is missing for ${provider.name}. Please add an API key in the settings to send messages.`
17
+ : 'No provider selected. Please select a provider and add an API key.'}
18
+ </p>
19
+ </div>
20
  </div>
21
  </div>
22
+ );
23
+ };