'use client' import type { FC } from 'react' import type { TryAppInfo } from '@/service/try-app' import Image from 'next/image' import * as React from 'react' import { useTranslation } from 'react-i18next' import { AppTypeIcon } from '@/app/components/app/type-selector' import AppIcon from '@/app/components/base/app-icon' import Button from '@/app/components/base/button' import { cn } from '@/utils/classnames' import useGetRequirements from './use-get-requirements' type Props = { appId: string appDetail: TryAppInfo category?: string className?: string onCreate: () => void } const headerClassName = 'system-sm-semibold-uppercase text-text-secondary mb-3' const requirementIconSize = 20 type RequirementIconProps = { iconUrl: string } const RequirementIcon: FC = ({ iconUrl }) => { const [failedSource, setFailedSource] = React.useState(null) const hasLoadError = !iconUrl || failedSource === iconUrl if (hasLoadError) { return (
) } return ( setFailedSource(iconUrl)} /> ) } const AppInfo: FC = ({ appId, className, category, appDetail, onCreate, }) => { const { t } = useTranslation() const mode = appDetail?.mode const { requirements } = useGetRequirements({ appDetail, appId }) return (
{/* name and icon */}
{appDetail.name}
{mode === 'advanced-chat' &&
{t('types.advanced', { ns: 'app' }).toUpperCase()}
} {mode === 'chat' &&
{t('types.chatbot', { ns: 'app' }).toUpperCase()}
} {mode === 'agent-chat' &&
{t('types.agent', { ns: 'app' }).toUpperCase()}
} {mode === 'workflow' &&
{t('types.workflow', { ns: 'app' }).toUpperCase()}
} {mode === 'completion' &&
{t('types.completion', { ns: 'app' }).toUpperCase()}
}
{appDetail.description && (
{appDetail.description}
)} {category && (
{t('tryApp.category', { ns: 'explore' })}
{category}
)} {requirements.length > 0 && (
{t('tryApp.requirements', { ns: 'explore' })}
{requirements.map(item => (
{item.name}
))}
)}
) } export default React.memo(AppInfo)