import { useState, useEffect, forwardRef, useImperativeHandle } from 'react'; import clsx from 'clsx' import { Button } from 'antd' import { useTranslation } from 'react-i18next'; import type { ProviderModelItem, ModelListItem, DescriptionItem, BaseRef } from './types' import RbCard from '@/components/RbCard/Card' import { getModelNewList } from '@/api/models' import PageEmpty from '@/components/Empty/PageEmpty'; import { formatDateTime } from '@/utils/format'; const Group = forwardRef void; }>(({ query, handleEdit }, ref) => { const { t } = useTranslation(); const [list, setList] = useState([]) useEffect(() => { getList() }, [query]) const getList = () => { getModelNewList({ ...query, is_composite: true, is_active: true, }) .then(res => { const response = res as ProviderModelItem[] setList(response[0]?.models || []) }) } const formatData = (data: ModelListItem) => { return [ { key: 'type', label: t(`modelNew.type`), children: data.type ? t(`modelNew.${data.type}`) : '-', }, { key: 'is_active', label: t(`modelNew.status`), children: data.is_active ? t(`common.statusEnabled`) : t(`common.statusDisabled`), }, { key: 'created_at', label: t(`modelNew.created_at`), children: data.created_at ? formatDateTime(data.created_at, 'YYYY-MM-DD HH:mm:ss') : '-', }, ] } useImperativeHandle(ref, () => ({ getList, })); return ( <> {list.length === 0 ? :(
{list.map(item => ( {item.name[0]}
} > {formatData(item)?.map((description: DescriptionItem) => (
{(description.label as string)} {(description.children as string)}
))} ))} ) } ) }) export default Group