* perf: insert mongo dataset data session * perf: dataset data index * remove delay * rename bill schema * rename bill record * perf: bill table * perf: prompt * perf: sub plan * change the usage count * feat: usage bill * publish usages * doc * 新增团队聊天功能 (#20) * perf: doc * feat 添加标签部分 feat 信息团队标签配置 feat 新增团队同步管理 feat team分享页面 feat 完成team分享页面 feat 实现模糊搜索 style 格式化 fix 修复迷糊匹配 style 样式修改 fix 团队标签功能修复 * fix 修复鉴权功能 * merge 合并代码 * fix 修复引用错误 * fix 修复pr问题 * fix 修复ts格式问题 --------- Co-authored-by: archer <545436317@qq.com> Co-authored-by: liuxingwan <liuxingwan.lxw@alibaba-inc.com> * update extra plan * fix: ts * format * perf: bill field * feat: standard plan * fix: ts * feat 个人账号页面修改 (#22) * feat 添加标签部分 feat 信息团队标签配置 feat 新增团队同步管理 feat team分享页面 feat 完成team分享页面 feat 实现模糊搜索 style 格式化 fix 修复迷糊匹配 style 样式修改 fix 团队标签功能修复 * fix 修复鉴权功能 * merge 合并代码 * fix 修复引用错误 * fix 修复pr问题 * fix 修复ts格式问题 * feat 修改个人账号页 --------- Co-authored-by: liuxingwan <liuxingwan.lxw@alibaba-inc.com> * fix chunk index; error page text * feat: dataset process Integral prediction * feat: stand plan field * feat: sub plan limit * perf: index * query extension * perf: share link push app name * perf: plan point unit * perf: get sub plan * perf: account page --------- Co-authored-by: yst <77910600+yu-and-liu@users.noreply.github.com> Co-authored-by: liuxingwan <liuxingwan.lxw@alibaba-inc.com>
165 lines
5.4 KiB
TypeScript
165 lines
5.4 KiB
TypeScript
import React, { useState } from 'react';
|
|
import { Box, Flex, Button, IconButton } from '@chakra-ui/react';
|
|
import { DragHandleIcon } from '@chakra-ui/icons';
|
|
import { useRequest } from '@/web/common/hooks/useRequest';
|
|
import { useConfirm } from '@/web/common/hooks/useConfirm';
|
|
import { useRouter } from 'next/router';
|
|
import { useToast } from '@fastgpt/web/hooks/useToast';
|
|
import { AppSchema } from '@fastgpt/global/core/app/type.d';
|
|
import { delModelById } from '@/web/core/app/api';
|
|
import { useTranslation } from 'next-i18next';
|
|
import { useAppStore } from '@/web/core/app/store/useAppStore';
|
|
import PermissionIconText from '@/components/support/permission/IconText';
|
|
import dynamic from 'next/dynamic';
|
|
import Avatar from '@/components/Avatar';
|
|
import MyIcon from '@fastgpt/web/components/common/Icon';
|
|
import TagsEditModal from './tagsEditModal';
|
|
const InfoModal = dynamic(() => import('../InfoModal'));
|
|
|
|
const AppCard = ({ appId }: { appId: string }) => {
|
|
const router = useRouter();
|
|
const { t } = useTranslation();
|
|
const { toast } = useToast();
|
|
const { appDetail } = useAppStore();
|
|
const [settingAppInfo, setSettingAppInfo] = useState<AppSchema>();
|
|
const [TeamTagsSet, setTeamTagsSet] = useState<AppSchema>();
|
|
|
|
const { openConfirm: openConfirmDel, ConfirmModal: ConfirmDelModal } = useConfirm({
|
|
content: t('app.Confirm Del App Tip')
|
|
});
|
|
|
|
/* 点击删除 */
|
|
const { mutate: handleDelModel, isLoading } = useRequest({
|
|
mutationFn: async () => {
|
|
if (!appDetail) return null;
|
|
await delModelById(appDetail._id);
|
|
return 'success';
|
|
},
|
|
onSuccess(res) {
|
|
if (!res) return;
|
|
toast({
|
|
title: t('common.Delete Success'),
|
|
status: 'success'
|
|
});
|
|
router.replace(`/app/list`);
|
|
},
|
|
errorToast: t('common.Delete Failed')
|
|
});
|
|
|
|
return (
|
|
<>
|
|
<Box px={4}>
|
|
<Flex alignItems={'center'} justifyContent={'space-between'}>
|
|
<Box fontSize={['md', 'xl']} fontWeight={'bold'}>
|
|
<PermissionIconText permission={appDetail.permission} />
|
|
</Box>
|
|
<Box color={'myGray.500'} fontSize={'sm'}>
|
|
AppId:{' '}
|
|
<Box as={'span'} userSelect={'all'}>
|
|
{appId}
|
|
</Box>
|
|
</Box>
|
|
</Flex>
|
|
{/* basic info */}
|
|
<Box
|
|
borderWidth={'1px'}
|
|
borderColor={'primary.1'}
|
|
borderRadius={'md'}
|
|
mt={2}
|
|
px={5}
|
|
py={4}
|
|
bg={'primary.50'}
|
|
position={'relative'}
|
|
>
|
|
<Flex alignItems={'center'} py={2}>
|
|
<Avatar src={appDetail.avatar} borderRadius={'md'} w={'28px'} />
|
|
<Box ml={3} fontWeight={'bold'} fontSize={'lg'}>
|
|
{appDetail.name}
|
|
</Box>
|
|
{appDetail.isOwner && (
|
|
<IconButton
|
|
className="delete"
|
|
position={'absolute'}
|
|
top={4}
|
|
right={4}
|
|
size={'smSquare'}
|
|
icon={<MyIcon name={'delete'} w={'14px'} />}
|
|
variant={'whiteDanger'}
|
|
borderRadius={'md'}
|
|
aria-label={'delete'}
|
|
isLoading={isLoading}
|
|
onClick={openConfirmDel(handleDelModel)}
|
|
/>
|
|
)}
|
|
</Flex>
|
|
<Box
|
|
flex={1}
|
|
my={2}
|
|
className={'textEllipsis3'}
|
|
wordBreak={'break-all'}
|
|
color={'myGray.600'}
|
|
>
|
|
{appDetail.intro || t('core.app.tip.Add a intro to app')}
|
|
</Box>
|
|
<Flex>
|
|
<Button
|
|
size={['sm', 'md']}
|
|
variant={'whitePrimary'}
|
|
leftIcon={<MyIcon name={'core/chat/chatLight'} w={'16px'} />}
|
|
onClick={() => router.push(`/chat?appId=${appId}`)}
|
|
>
|
|
{t('core.Chat')}
|
|
</Button>
|
|
<Button
|
|
mx={3}
|
|
size={['sm', 'md']}
|
|
variant={'whitePrimary'}
|
|
leftIcon={<MyIcon name={'support/outlink/shareLight'} w={'16px'} />}
|
|
onClick={() => {
|
|
router.replace({
|
|
query: {
|
|
appId,
|
|
currentTab: 'publish'
|
|
}
|
|
});
|
|
}}
|
|
>
|
|
{t('core.app.navbar.Publish')}
|
|
</Button>
|
|
{appDetail.isOwner && (
|
|
<Button
|
|
mr={3}
|
|
size={['sm', 'md']}
|
|
variant={'whitePrimary'}
|
|
leftIcon={<DragHandleIcon w={'16px'} />}
|
|
onClick={() => setTeamTagsSet(appDetail)}
|
|
>
|
|
{t('common.Team Tags Set')}
|
|
</Button>
|
|
)}
|
|
{appDetail.isOwner && (
|
|
<Button
|
|
size={['sm', 'md']}
|
|
variant={'whitePrimary'}
|
|
leftIcon={<MyIcon name={'common/settingLight'} w={'16px'} />}
|
|
onClick={() => setSettingAppInfo(appDetail)}
|
|
>
|
|
{t('common.Setting')}
|
|
</Button>
|
|
)}
|
|
</Flex>
|
|
</Box>
|
|
</Box>
|
|
<ConfirmDelModal />
|
|
{settingAppInfo && (
|
|
<InfoModal defaultApp={settingAppInfo} onClose={() => setSettingAppInfo(undefined)} />
|
|
)}
|
|
{TeamTagsSet && (
|
|
<TagsEditModal appDetail={appDetail} onClose={() => setTeamTagsSet(undefined)} />
|
|
)}
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default React.memo(AppCard);
|