move toDisplayName to helper file

This commit is contained in:
SwiftyOS
2025-07-08 10:11:35 +02:00
parent a0da6dd09f
commit df2ef41213
2 changed files with 28 additions and 28 deletions

View File

@@ -11,34 +11,7 @@ import {
} from "@/lib/autogpt-server-api";
import { useBackendAPI } from "@/lib/autogpt-server-api/context";
import { useToastOnFail } from "@/components/ui/use-toast";
// --8<-- [start:CredentialsProviderNames]
// Helper function to convert provider names to display names
function toDisplayName(provider: string): string {
// Special cases that need manual handling
const specialCases: Record<string, string> = {
aiml_api: "AI/ML",
d_id: "D-ID",
e2b: "E2B",
llama_api: "Llama API",
open_router: "Open Router",
smtp: "SMTP",
revid: "Rev.ID",
};
if (specialCases[provider]) {
return specialCases[provider];
}
// General case: convert snake_case to Title Case
return provider
.split(/[_-]/)
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
.join(" ");
}
// Provider display names are now generated dynamically by toDisplayName function
// --8<-- [end:CredentialsProviderNames]
import { toDisplayName } from "@/components/integrations/helper";
type APIKeyCredentialsCreatable = Omit<
APIKeyCredentials,

View File

@@ -0,0 +1,27 @@
// --8<-- [start:CredentialsProviderNames]
// Helper function to convert provider names to display names
export function toDisplayName(provider: string): string {
// Special cases that need manual handling
const specialCases: Record<string, string> = {
aiml_api: "AI/ML",
d_id: "D-ID",
e2b: "E2B",
llama_api: "Llama API",
open_router: "Open Router",
smtp: "SMTP",
revid: "Rev.ID",
};
if (specialCases[provider]) {
return specialCases[provider];
}
// General case: convert snake_case to Title Case
return provider
.split(/[_-]/)
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
.join(" ");
}
// Provider display names are now generated dynamically by toDisplayName function
// --8<-- [end:CredentialsProviderNames]