2023-05-25 16:59:47 +08:00
|
|
|
'use client'
|
|
|
|
import cn from 'classnames'
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import { PlusIcon } from '@heroicons/react/20/solid'
|
|
|
|
import Button from '../../base/button'
|
|
|
|
import s from './style.module.css'
|
2023-05-30 15:26:26 +08:00
|
|
|
import type { App } from '@/models/explore'
|
|
|
|
import AppModeLabel from '@/app/(commonLayout)/apps/AppModeLabel'
|
|
|
|
import AppIcon from '@/app/components/base/app-icon'
|
2023-05-25 16:59:47 +08:00
|
|
|
|
|
|
|
export type AppCardProps = {
|
2023-05-30 15:26:26 +08:00
|
|
|
app: App
|
|
|
|
canCreate: boolean
|
|
|
|
onCreate: () => void
|
2023-05-25 16:59:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const AppCard = ({
|
|
|
|
app,
|
|
|
|
canCreate,
|
|
|
|
onCreate,
|
|
|
|
}: AppCardProps) => {
|
|
|
|
const { t } = useTranslation()
|
2024-01-23 19:31:56 +08:00
|
|
|
const { app: appBasicInfo, is_agent } = app
|
2023-05-25 16:59:47 +08:00
|
|
|
return (
|
2023-11-29 14:58:27 +08:00
|
|
|
<div className={cn(s.wrap, 'col-span-1 bg-white border-2 border-solid border-transparent rounded-lg shadow-sm min-h-[160px] flex flex-col transition-all duration-200 ease-in-out cursor-pointer hover:shadow-lg')}>
|
2023-11-28 20:05:19 +08:00
|
|
|
<div className='flex pt-[14px] px-[14px] pb-3 h-[66px] items-center gap-3 grow-0 shrink-0'>
|
|
|
|
<AppIcon size='small' icon={app.app.icon} background={app.app.icon_background} />
|
|
|
|
<div className='relative h-8 text-sm font-medium leading-8 grow'>
|
|
|
|
<div className='absolute top-0 left-0 w-full h-full overflow-hidden text-ellipsis whitespace-nowrap'>{appBasicInfo.name}</div>
|
2023-05-25 16:59:47 +08:00
|
|
|
</div>
|
2023-11-28 20:05:19 +08:00
|
|
|
</div>
|
|
|
|
<div className='mb-3 px-[14px] h-9 text-xs leading-normal text-gray-500 line-clamp-2'>{app.description}</div>
|
|
|
|
<div className='flex items-center flex-wrap min-h-[42px] px-[14px] pt-2 pb-[10px]'>
|
|
|
|
<div className={s.mode}>
|
2024-01-23 19:31:56 +08:00
|
|
|
<AppModeLabel mode={appBasicInfo.mode} isAgent={is_agent} />
|
2023-11-28 20:05:19 +08:00
|
|
|
</div>
|
2024-01-24 12:37:42 +08:00
|
|
|
{
|
|
|
|
canCreate && (
|
|
|
|
<div className={cn(s.opWrap, 'flex items-center w-full space-x-2')}>
|
|
|
|
<Button type='primary' className='grow flex items-center !h-7' onClick={() => onCreate()}>
|
|
|
|
<PlusIcon className='w-4 h-4 mr-1' />
|
|
|
|
<span className='text-xs'>{t('explore.appCard.addToWorkspace')}</span>
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
2023-05-25 16:59:47 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default AppCard
|