Skip to content

Commit 6a887c2

Browse files
committed
move code
1 parent c384b0d commit 6a887c2

File tree

51 files changed

+120
-67
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+120
-67
lines changed

packages/global/support/user/inform/type.d.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { InformTypeEnum } from './constants';
22

33
export type SendInformProps = {
4-
tmbId?: string;
5-
type: `${InformTypeEnum}`;
64
title: string;
75
content: string;
86
};
7+
export type SendInform2User = SendInformProps & {
8+
type: `${InformTypeEnum}`;
9+
tmbId: string;
10+
};
911

1012
export type UserInformSchema = {
1113
_id: string;

packages/web/components/common/Icon/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const iconPaths = {
1616
'common/confirm/rightTip': () => import('./icons/common/confirm/rightTip.svg'),
1717
'common/courseLight': () => import('./icons/common/courseLight.svg'),
1818
'common/customTitleLight': () => import('./icons/common/customTitleLight.svg'),
19+
'common/data': () => import('./icons/common/data.svg'),
1920
'common/editor/resizer': () => import('./icons/common/editor/resizer.svg'),
2021
'common/errorFill': () => import('./icons/common/errorFill.svg'),
2122
'common/file/move': () => import('./icons/common/file/move.svg'),
Lines changed: 9 additions & 0 deletions
Loading

projects/app/src/web/common/hooks/useConfirm.tsx renamed to packages/web/hooks/useConfirm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
22
import { useDisclosure, Button, ModalBody, ModalFooter } from '@chakra-ui/react';
33
import { useTranslation } from 'next-i18next';
4-
import MyModal from '@fastgpt/web/components/common/MyModal';
4+
import MyModal from '../components/common/MyModal';
55

66
export const useConfirm = (props?: {
77
title?: string;

packages/web/hooks/useRequest.tsx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { useToast } from './useToast';
2+
import { useMutation } from '@tanstack/react-query';
3+
import type { UseMutationOptions } from '@tanstack/react-query';
4+
import { getErrText } from '@fastgpt/global/common/error/utils';
5+
import { useTranslation } from 'next-i18next';
6+
7+
interface Props extends UseMutationOptions<any, any, any, any> {
8+
successToast?: string | null;
9+
errorToast?: string | null;
10+
}
11+
12+
export const useRequest = ({ successToast, errorToast, onSuccess, onError, ...props }: Props) => {
13+
const { toast } = useToast();
14+
const { t } = useTranslation();
15+
const mutation = useMutation<unknown, unknown, any, unknown>({
16+
...props,
17+
onSuccess(res, variables: void, context: unknown) {
18+
onSuccess?.(res, variables, context);
19+
successToast &&
20+
toast({
21+
title: successToast,
22+
status: 'success'
23+
});
24+
},
25+
onError(err: any, variables: void, context: unknown) {
26+
onError?.(err, variables, context);
27+
28+
if (errorToast !== undefined) {
29+
const errText = t(getErrText(err, errorToast || ''));
30+
if (errText) {
31+
toast({
32+
title: errText,
33+
status: 'error'
34+
});
35+
}
36+
}
37+
}
38+
});
39+
40+
return mutation;
41+
};

pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

projects/app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"react": "18.2.0",
4949
"react-day-picker": "^8.7.1",
5050
"react-dom": "18.2.0",
51-
"react-hook-form": "^7.43.1",
51+
"react-hook-form": "7.43.1",
5252
"react-i18next": "13.5.0",
5353
"react-markdown": "^8.0.7",
5454
"react-syntax-highlighter": "^15.5.0",

projects/app/src/components/ChatBox/FeedbackModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useRef } from 'react';
22
import { ModalBody, Textarea, ModalFooter, Button } from '@chakra-ui/react';
33
import MyModal from '@fastgpt/web/components/common/MyModal';
4-
import { useRequest } from '@/web/common/hooks/useRequest';
4+
import { useRequest } from '@fastgpt/web/hooks/useRequest';
55
import { useTranslation } from 'next-i18next';
66
import { updateChatUserFeedback } from '@/web/core/chat/api';
77

projects/app/src/components/ChatBox/MessageInput.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { compressImgFileAndUpload } from '@/web/common/file/controller';
1010
import { customAlphabet } from 'nanoid';
1111
import { ChatFileTypeEnum } from '@fastgpt/global/core/chat/constants';
1212
import { addDays } from 'date-fns';
13-
import { useRequest } from '@/web/common/hooks/useRequest';
13+
import { useRequest } from '@fastgpt/web/hooks/useRequest';
1414
import { MongoImageTypeEnum } from '@fastgpt/global/common/file/image/constants';
1515
import { OutLinkChatAuthProps } from '@fastgpt/global/support/permission/chat';
1616
import { ChatBoxInputFormType, ChatBoxInputType, UserInputFileItemType } from './type';

projects/app/src/components/core/module/Flow/ModuleTemplateList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { getErrText } from '@fastgpt/global/common/error/utils';
2020
import { moduleTemplatesList } from '@fastgpt/global/core/module/template/constants';
2121
import RowTabs from '@fastgpt/web/components/common/Tabs/RowTabs';
2222
import { useWorkflowStore } from '@/web/core/workflow/store/workflow';
23-
import { useRequest } from '@/web/common/hooks/useRequest';
23+
import { useRequest } from '@fastgpt/web/hooks/useRequest';
2424
import ParentPaths from '@/components/common/ParentPaths';
2525
import MyIcon from '@fastgpt/web/components/common/Icon';
2626
import { useRouter } from 'next/router';

0 commit comments

Comments
 (0)