import { memo, useCallback, } from 'react' import { useTranslation } from 'react-i18next' import { RiEqualizer2Line, } from '@remixicon/react' import { Button, } from '@/app/components/base/button' import type { CustomConfigurationModelFixedFields, ModelProvider, } from '@/app/components/header/account-setting/model-provider-page/declarations' import { ConfigurationMethodEnum } from '@/app/components/header/account-setting/model-provider-page/declarations' import Authorized from './authorized' import { useCredentialStatus } from './hooks' import Tooltip from '@/app/components/base/tooltip' type ConfigProviderProps = { provider: ModelProvider, currentCustomConfigurationModelFixedFields?: CustomConfigurationModelFixedFields, } const ConfigProvider = ({ provider, currentCustomConfigurationModelFixedFields, }: ConfigProviderProps) => { const { t } = useTranslation() const { hasCredential, authorized, current_credential_id, current_credential_name, available_credentials, } = useCredentialStatus(provider) const notAllowCustomCredential = provider.allow_custom_token === false const renderTrigger = useCallback(() => { const text = hasCredential ? t('common.operation.config') : t('common.operation.setup') const Item = ( ) if (notAllowCustomCredential && !hasCredential) { return ( {Item} ) } return Item }, [authorized, hasCredential, notAllowCustomCredential, t]) return ( ) } export default memo(ConfigProvider)