'use client' import type { App } from '@/models/explore' import { PlusIcon } from '@heroicons/react/20/solid' import { RiInformation2Line } from '@remixicon/react' import { useCallback } from 'react' import { useTranslation } from 'react-i18next' import { useContextSelector } from 'use-context-selector' import AppIcon from '@/app/components/base/app-icon' import ExploreContext from '@/context/explore-context' import { useGlobalPublicStore } from '@/context/global-public-context' import { AppModeEnum } from '@/types/app' import { cn } from '@/utils/classnames' import { AppTypeIcon } from '../../app/type-selector' import Button from '../../base/button' export type AppCardProps = { app: App canCreate: boolean onCreate: () => void isExplore: boolean } const AppCard = ({ app, canCreate, onCreate, isExplore, }: AppCardProps) => { const { t } = useTranslation() const { app: appBasicInfo } = app const { systemFeatures } = useGlobalPublicStore() const isTrialApp = app.can_trial && systemFeatures.enable_trial_app const setShowTryAppPanel = useContextSelector(ExploreContext, ctx => ctx.setShowTryAppPanel) const showTryAPPPanel = useCallback((appId: string) => { return () => { setShowTryAppPanel?.(true, { appId, app }) } }, [setShowTryAppPanel, app]) return (
{appBasicInfo.name}
{appBasicInfo.mode === AppModeEnum.ADVANCED_CHAT &&
{t('types.advanced', { ns: 'app' }).toUpperCase()}
} {appBasicInfo.mode === AppModeEnum.CHAT &&
{t('types.chatbot', { ns: 'app' }).toUpperCase()}
} {appBasicInfo.mode === AppModeEnum.AGENT_CHAT &&
{t('types.agent', { ns: 'app' }).toUpperCase()}
} {appBasicInfo.mode === AppModeEnum.WORKFLOW &&
{t('types.workflow', { ns: 'app' }).toUpperCase()}
} {appBasicInfo.mode === AppModeEnum.COMPLETION &&
{t('types.completion', { ns: 'app' }).toUpperCase()}
}
{app.description}
{isExplore && (canCreate || isTrialApp) && ( )}
) } export default AppCard