import type { FC } from 'react' import { useContext } from 'use-context-selector' import type { FormValue, Provider, ProviderConfigItem, ProviderWithModels, ProviderWithQuota, } from '../declarations' import Setting from './Setting' import Card from './Card' import QuotaCard from './QuotaCard' import I18n from '@/context/i18n' import { IS_CE_EDITION } from '@/config' type ModelItemProps = { currentProvider?: Provider modelItem: ProviderConfigItem onOpenModal: (v?: FormValue) => void onOperate: (v: Record) => void onUpdate: () => void } const ModelItem: FC = ({ currentProvider, modelItem, onOpenModal, onOperate, onUpdate, }) => { const { locale } = useContext(I18n) const custom = currentProvider?.providers.find(p => p.provider_type === 'custom') as ProviderWithModels const systemFree = currentProvider?.providers.find(p => p.provider_type === 'system' && (p as ProviderWithQuota).quota_type === 'free') as ProviderWithQuota return (
{modelItem.titleIcon[locale]} { modelItem.hit && (
{modelItem.hit[locale]}
) }
{ !!custom?.models?.length && ( ) } { systemFree?.is_valid && !IS_CE_EDITION && ( ) }
) } export default ModelItem