mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
Merge pull request #772 from Hexastack/feat/replace-mutateasync-with-mutate
feat: replace mutateasync with mutate
This commit is contained in:
commit
4bc79332e7
@ -84,7 +84,7 @@ const AttachmentUploader: FC<FileUploadProps> = ({
|
|||||||
const dialogs = useDialogs();
|
const dialogs = useDialogs();
|
||||||
const [isDragOver, setIsDragOver] = useState<boolean>(false);
|
const [isDragOver, setIsDragOver] = useState<boolean>(false);
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
const { mutateAsync: uploadAttachment } = useUpload(EntityType.ATTACHMENT, {
|
const { mutate: uploadAttachment } = useUpload(EntityType.ATTACHMENT, {
|
||||||
onError: () => {
|
onError: () => {
|
||||||
toast.error(t("message.upload_failed"));
|
toast.error(t("message.upload_failed"));
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024 Hexastack. All rights reserved.
|
* Copyright © 2025 Hexastack. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
||||||
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
||||||
@ -38,7 +38,7 @@ export const Login = () => {
|
|||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { authenticate } = useAuth();
|
const { authenticate } = useAuth();
|
||||||
const { mutateAsync: login, isLoading } = useLogin({
|
const { mutate: login, isLoading } = useLogin({
|
||||||
onSuccess: (data) => {
|
onSuccess: (data) => {
|
||||||
if (data.state) authenticate(data);
|
if (data.state) authenticate(data);
|
||||||
else {
|
else {
|
||||||
@ -49,7 +49,7 @@ export const Login = () => {
|
|||||||
toast.error(t("message.login_failure"));
|
toast.error(t("message.login_failure"));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const { mutateAsync: confirmAccount } = useConfirmAccount({
|
const { mutate: confirmAccount } = useConfirmAccount({
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
toast.success(t("message.reset_confirm_success"));
|
toast.success(t("message.reset_confirm_success"));
|
||||||
},
|
},
|
||||||
@ -76,8 +76,8 @@ export const Login = () => {
|
|||||||
required: t("message.password_is_required"),
|
required: t("message.password_is_required"),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const onSubmitForm = async (data: ILoginAttributes) => {
|
const onSubmitForm = (data: ILoginAttributes) => {
|
||||||
await login(data);
|
login(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024 Hexastack. All rights reserved.
|
* Copyright © 2025 Hexastack. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
||||||
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
||||||
@ -53,7 +53,7 @@ export const Register = () => {
|
|||||||
const { t } = useTranslate();
|
const { t } = useTranslate();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
const { mutateAsync: acceptInvite, isLoading } = useAcceptInvite({
|
const { mutate: acceptInvite, isLoading } = useAcceptInvite({
|
||||||
onError: () => {
|
onError: () => {
|
||||||
toast.error(t("message.internal_server_error"));
|
toast.error(t("message.internal_server_error"));
|
||||||
},
|
},
|
||||||
@ -108,11 +108,11 @@ export const Register = () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const onSubmitForm = async ({
|
const onSubmitForm = ({
|
||||||
password2: _password2,
|
password2: _password2,
|
||||||
...rest
|
...rest
|
||||||
}: TRegisterExtendedPayload) => {
|
}: TRegisterExtendedPayload) => {
|
||||||
await acceptInvite(rest);
|
acceptInvite(rest);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -39,11 +39,11 @@ export const ContextVarForm: FC<ComponentFormProps<IContextVar>> = ({
|
|||||||
toast.success(t("message.success_save"));
|
toast.success(t("message.success_save"));
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const { mutateAsync: createContextVar } = useCreate(
|
const { mutate: createContextVar } = useCreate(
|
||||||
EntityType.CONTEXT_VAR,
|
EntityType.CONTEXT_VAR,
|
||||||
options,
|
options,
|
||||||
);
|
);
|
||||||
const { mutateAsync: updateContextVar } = useUpdate(
|
const { mutate: updateContextVar } = useUpdate(
|
||||||
EntityType.CONTEXT_VAR,
|
EntityType.CONTEXT_VAR,
|
||||||
options,
|
options,
|
||||||
);
|
);
|
||||||
@ -72,7 +72,7 @@ export const ContextVarForm: FC<ComponentFormProps<IContextVar>> = ({
|
|||||||
required: t("message.label_is_required"),
|
required: t("message.label_is_required"),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const onSubmitForm = async (params: IContextVarAttributes) => {
|
const onSubmitForm = (params: IContextVarAttributes) => {
|
||||||
if (data) {
|
if (data) {
|
||||||
updateContextVar({ id: data.id, params });
|
updateContextVar({ id: data.id, params });
|
||||||
} else {
|
} else {
|
||||||
|
@ -39,7 +39,7 @@ export function Chat() {
|
|||||||
const { t, i18n } = useTranslate();
|
const { t, i18n } = useTranslate();
|
||||||
const { subscriber } = useChat();
|
const { subscriber } = useChat();
|
||||||
const { user } = useAuth();
|
const { user } = useAuth();
|
||||||
const { mutateAsync: createMessage } = useCreate(EntityType.MESSAGE);
|
const { mutate: createMessage } = useCreate(EntityType.MESSAGE);
|
||||||
const { replyTo, messages, fetchNextPage, hasNextPage, isFetching } =
|
const { replyTo, messages, fetchNextPage, hasNextPage, isFetching } =
|
||||||
useInfinitedLiveMessages();
|
useInfinitedLiveMessages();
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024 Hexastack. All rights reserved.
|
* Copyright © 2025 Hexastack. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
||||||
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
||||||
@ -52,7 +52,7 @@ export const Languages = () => {
|
|||||||
params: searchPayload,
|
params: searchPayload,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
const { mutateAsync: updateLanguage } = useUpdate(EntityType.LANGUAGE, {
|
const { mutate: updateLanguage } = useUpdate(EntityType.LANGUAGE, {
|
||||||
onError: () => {
|
onError: () => {
|
||||||
toast.error(t("message.internal_server_error"));
|
toast.error(t("message.internal_server_error"));
|
||||||
},
|
},
|
||||||
@ -61,7 +61,7 @@ export const Languages = () => {
|
|||||||
toast.success(t("message.success_save"));
|
toast.success(t("message.success_save"));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const { mutateAsync: deleteLanguage } = useDelete(EntityType.LANGUAGE, {
|
const { mutate: deleteLanguage } = useDelete(EntityType.LANGUAGE, {
|
||||||
onError: () => {
|
onError: () => {
|
||||||
toast.error(t("message.internal_server_error"));
|
toast.error(t("message.internal_server_error"));
|
||||||
},
|
},
|
||||||
|
@ -110,7 +110,7 @@ export default function NlpSample() {
|
|||||||
toast.success(t("message.item_delete_success"));
|
toast.success(t("message.item_delete_success"));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const { mutateAsync: importDataset, isLoading } = useImport(
|
const { mutate: importDataset, isLoading } = useImport(
|
||||||
EntityType.NLP_SAMPLE,
|
EntityType.NLP_SAMPLE,
|
||||||
{
|
{
|
||||||
onError: () => {
|
onError: () => {
|
||||||
@ -297,8 +297,8 @@ export default function NlpSample() {
|
|||||||
const handleSelectionChange = (selection: GridRowSelectionModel) => {
|
const handleSelectionChange = (selection: GridRowSelectionModel) => {
|
||||||
setSelectedNlpSamples(selection as string[]);
|
setSelectedNlpSamples(selection as string[]);
|
||||||
};
|
};
|
||||||
const handleImportChange = async (file: File) => {
|
const handleImportChange = (file: File) => {
|
||||||
await importDataset(file);
|
importDataset(file);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -62,7 +62,7 @@ export const Nlp = ({
|
|||||||
};
|
};
|
||||||
const { t } = useTranslate();
|
const { t } = useTranslate();
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
const { mutateAsync: createSample } = useCreate<
|
const { mutate: createSample } = useCreate<
|
||||||
EntityType.NLP_SAMPLE,
|
EntityType.NLP_SAMPLE,
|
||||||
INlpDatasetSampleAttributes,
|
INlpDatasetSampleAttributes,
|
||||||
INlpSample,
|
INlpSample,
|
||||||
|
@ -34,7 +34,7 @@ export const ProfileForm: FC<ProfileFormProps> = ({ user }) => {
|
|||||||
const { t } = useTranslate();
|
const { t } = useTranslate();
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
const { mutateAsync: updateProfile, isLoading } = useUpdateProfile({
|
const { mutate: updateProfile, isLoading } = useUpdateProfile({
|
||||||
onError: () => {
|
onError: () => {
|
||||||
toast.error(t("message.internal_server_error"));
|
toast.error(t("message.internal_server_error"));
|
||||||
},
|
},
|
||||||
@ -79,12 +79,12 @@ export const ProfileForm: FC<ProfileFormProps> = ({ user }) => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const onSubmitForm = async ({
|
const onSubmitForm = ({
|
||||||
password,
|
password,
|
||||||
password2: _password2,
|
password2: _password2,
|
||||||
...rest
|
...rest
|
||||||
}: IProfileAttributes) => {
|
}: IProfileAttributes) => {
|
||||||
await updateProfile({
|
updateProfile({
|
||||||
...rest,
|
...rest,
|
||||||
password: password || undefined,
|
password: password || undefined,
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024 Hexastack. All rights reserved.
|
* Copyright © 2025 Hexastack. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
||||||
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
||||||
@ -85,7 +85,7 @@ export const Settings = () => {
|
|||||||
initialSortState: [{ field: "weight", sort: "asc" }],
|
initialSortState: [{ field: "weight", sort: "asc" }],
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
const { mutateAsync: updateSetting } = useUpdate(EntityType.SETTING, {
|
const { mutate: updateSetting } = useUpdate(EntityType.SETTING, {
|
||||||
onError: () => {
|
onError: () => {
|
||||||
toast.error(t("message.internal_server_error"));
|
toast.error(t("message.internal_server_error"));
|
||||||
},
|
},
|
||||||
|
@ -46,7 +46,7 @@ export const BlockEditForm: FC<ComponentFormProps<IBlock>> = ({
|
|||||||
setSelectedTab(newValue);
|
setSelectedTab(newValue);
|
||||||
};
|
};
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
const { mutateAsync: updateBlock } = useUpdate(EntityType.BLOCK, {
|
const { mutate: updateBlock } = useUpdate(EntityType.BLOCK, {
|
||||||
onError: () => {
|
onError: () => {
|
||||||
rest.onError?.();
|
rest.onError?.();
|
||||||
toast.error(t("message.internal_server_error"));
|
toast.error(t("message.internal_server_error"));
|
||||||
@ -94,7 +94,7 @@ export const BlockEditForm: FC<ComponentFormProps<IBlock>> = ({
|
|||||||
required: t("message.name_is_required"),
|
required: t("message.name_is_required"),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const onSubmitForm = async (params: IBlockAttributes) => {
|
const onSubmitForm = (params: IBlockAttributes) => {
|
||||||
if (block) {
|
if (block) {
|
||||||
updateBlock({ id: block.id, params });
|
updateBlock({ id: block.id, params });
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024 Hexastack. All rights reserved.
|
* Copyright © 2025 Hexastack. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
||||||
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
||||||
@ -252,12 +252,12 @@ const VisualEditorProvider: React.FC<VisualEditorContextProps> = ({
|
|||||||
children,
|
children,
|
||||||
}) => {
|
}) => {
|
||||||
const [selectedCategoryId, setSelectedCategoryId] = React.useState("");
|
const [selectedCategoryId, setSelectedCategoryId] = React.useState("");
|
||||||
const { mutateAsync: createBlock } = useCreate(EntityType.BLOCK);
|
const { mutate: createBlock } = useCreate(EntityType.BLOCK);
|
||||||
const createNode = async (payload: any) => {
|
const createNode = (payload: any) => {
|
||||||
payload.position = payload.position || getCentroid();
|
payload.position = payload.position || getCentroid();
|
||||||
payload.category = payload.category || selectedCategoryId;
|
payload.category = payload.category || selectedCategoryId;
|
||||||
|
|
||||||
return await createBlock(payload, {
|
return createBlock(payload, {
|
||||||
onSuccess({ id }) {
|
onSuccess({ id }) {
|
||||||
addNode({
|
addNode({
|
||||||
...payload,
|
...payload,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright © 2024 Hexastack. All rights reserved.
|
* Copyright © 2025 Hexastack. All rights reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
|
||||||
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
|
||||||
@ -7,10 +7,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
NodeModel,
|
|
||||||
DiagramModel,
|
|
||||||
DiagramEngine,
|
DiagramEngine,
|
||||||
|
DiagramModel,
|
||||||
DiagramModelGenerics,
|
DiagramModelGenerics,
|
||||||
|
NodeModel,
|
||||||
} from "@projectstorm/react-diagrams";
|
} from "@projectstorm/react-diagrams";
|
||||||
import { ReactNode } from "react";
|
import { ReactNode } from "react";
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ export interface IVisualEditor {
|
|||||||
}
|
}
|
||||||
export interface IVisualEditorContext {
|
export interface IVisualEditorContext {
|
||||||
addNode: (payload: any) => NodeModel;
|
addNode: (payload: any) => NodeModel;
|
||||||
createNode: (payload: any) => Promise<IBlock>;
|
createNode: (payload: any) => void;
|
||||||
buildDiagram: (props: IVisualEditor) => {
|
buildDiagram: (props: IVisualEditor) => {
|
||||||
model: DiagramModel<DiagramModelGenerics>;
|
model: DiagramModel<DiagramModelGenerics>;
|
||||||
engine: DiagramEngine;
|
engine: DiagramEngine;
|
||||||
|
Loading…
Reference in New Issue
Block a user