feat: replace mutateasync with mutate

This commit is contained in:
hexastack 2025-02-17 19:27:40 +01:00
parent 8ef4307c58
commit 19ae57f019
12 changed files with 35 additions and 30 deletions

View File

@ -84,7 +84,7 @@ const AttachmentUploader: FC<FileUploadProps> = ({
const dialogs = useDialogs();
const [isDragOver, setIsDragOver] = useState<boolean>(false);
const { toast } = useToast();
const { mutateAsync: uploadAttachment } = useUpload(EntityType.ATTACHMENT, {
const { mutate: uploadAttachment } = useUpload(EntityType.ATTACHMENT, {
onError: () => {
toast.error(t("message.upload_failed"));
},

View File

@ -1,11 +1,12 @@
/*
* 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:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/
import EmailIcon from "@mui/icons-material/Email";
import KeyIcon from "@mui/icons-material/Key";
import KeyboardArrowRightIcon from "@mui/icons-material/KeyboardArrowRight";
@ -38,7 +39,7 @@ export const Login = () => {
const { toast } = useToast();
const router = useRouter();
const { authenticate } = useAuth();
const { mutateAsync: login, isLoading } = useLogin({
const { mutate: login, isLoading } = useLogin({
onSuccess: (data) => {
if (data.state) authenticate(data);
else {
@ -49,7 +50,7 @@ export const Login = () => {
toast.error(t("message.login_failure"));
},
});
const { mutateAsync: confirmAccount } = useConfirmAccount({
const { mutate: confirmAccount } = useConfirmAccount({
onSuccess: () => {
toast.success(t("message.reset_confirm_success"));
},
@ -76,8 +77,8 @@ export const Login = () => {
required: t("message.password_is_required"),
},
};
const onSubmitForm = async (data: ILoginAttributes) => {
await login(data);
const onSubmitForm = (data: ILoginAttributes) => {
login(data);
};
useEffect(() => {

View File

@ -39,11 +39,11 @@ export const ContextVarForm: FC<ComponentFormProps<IContextVar>> = ({
toast.success(t("message.success_save"));
},
};
const { mutateAsync: createContextVar } = useCreate(
const { mutate: createContextVar } = useCreate(
EntityType.CONTEXT_VAR,
options,
);
const { mutateAsync: updateContextVar } = useUpdate(
const { mutate: updateContextVar } = useUpdate(
EntityType.CONTEXT_VAR,
options,
);

View File

@ -39,7 +39,7 @@ export function Chat() {
const { t, i18n } = useTranslate();
const { subscriber } = useChat();
const { user } = useAuth();
const { mutateAsync: createMessage } = useCreate(EntityType.MESSAGE);
const { mutate: createMessage } = useCreate(EntityType.MESSAGE);
const { replyTo, messages, fetchNextPage, hasNextPage, isFetching } =
useInfinitedLiveMessages();

View File

@ -1,11 +1,12 @@
/*
* 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:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/
import { Flag } from "@mui/icons-material";
import AddIcon from "@mui/icons-material/Add";
import { Button, Grid, Paper, Switch } from "@mui/material";
@ -52,7 +53,7 @@ export const Languages = () => {
params: searchPayload,
},
);
const { mutateAsync: updateLanguage } = useUpdate(EntityType.LANGUAGE, {
const { mutate: updateLanguage } = useUpdate(EntityType.LANGUAGE, {
onError: () => {
toast.error(t("message.internal_server_error"));
},
@ -61,7 +62,7 @@ export const Languages = () => {
toast.success(t("message.success_save"));
},
});
const { mutateAsync: deleteLanguage } = useDelete(EntityType.LANGUAGE, {
const { mutate: deleteLanguage } = useDelete(EntityType.LANGUAGE, {
onError: () => {
toast.error(t("message.internal_server_error"));
},

View File

@ -110,7 +110,7 @@ export default function NlpSample() {
toast.success(t("message.item_delete_success"));
},
});
const { mutateAsync: importDataset, isLoading } = useImport(
const { mutate: importDataset, isLoading } = useImport(
EntityType.NLP_SAMPLE,
{
onError: () => {
@ -297,8 +297,8 @@ export default function NlpSample() {
const handleSelectionChange = (selection: GridRowSelectionModel) => {
setSelectedNlpSamples(selection as string[]);
};
const handleImportChange = async (file: File) => {
await importDataset(file);
const handleImportChange = (file: File) => {
importDataset(file);
};
return (

View File

@ -62,7 +62,7 @@ export const Nlp = ({
};
const { t } = useTranslate();
const { toast } = useToast();
const { mutateAsync: createSample } = useCreate<
const { mutate: createSample } = useCreate<
EntityType.NLP_SAMPLE,
INlpDatasetSampleAttributes,
INlpSample,

View File

@ -34,7 +34,7 @@ export const ProfileForm: FC<ProfileFormProps> = ({ user }) => {
const { t } = useTranslate();
const queryClient = useQueryClient();
const { toast } = useToast();
const { mutateAsync: updateProfile, isLoading } = useUpdateProfile({
const { mutate: updateProfile, isLoading } = useUpdateProfile({
onError: () => {
toast.error(t("message.internal_server_error"));
},
@ -84,7 +84,7 @@ export const ProfileForm: FC<ProfileFormProps> = ({ user }) => {
password2: _password2,
...rest
}: IProfileAttributes) => {
await updateProfile({
updateProfile({
...rest,
password: password || undefined,
});

View File

@ -1,11 +1,12 @@
/*
* 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:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/
import { faCogs } from "@fortawesome/free-solid-svg-icons";
import {
debounce,
@ -85,7 +86,7 @@ export const Settings = () => {
initialSortState: [{ field: "weight", sort: "asc" }],
},
);
const { mutateAsync: updateSetting } = useUpdate(EntityType.SETTING, {
const { mutate: updateSetting } = useUpdate(EntityType.SETTING, {
onError: () => {
toast.error(t("message.internal_server_error"));
},

View File

@ -46,7 +46,7 @@ export const BlockEditForm: FC<ComponentFormProps<IBlock>> = ({
setSelectedTab(newValue);
};
const { toast } = useToast();
const { mutateAsync: updateBlock } = useUpdate(EntityType.BLOCK, {
const { mutate: updateBlock } = useUpdate(EntityType.BLOCK, {
onError: () => {
rest.onError?.();
toast.error(t("message.internal_server_error"));
@ -94,7 +94,7 @@ export const BlockEditForm: FC<ComponentFormProps<IBlock>> = ({
required: t("message.name_is_required"),
},
};
const onSubmitForm = async (params: IBlockAttributes) => {
const onSubmitForm = (params: IBlockAttributes) => {
if (block) {
updateBlock({ id: block.id, params });
}

View File

@ -1,11 +1,12 @@
/*
* 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:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/
import { debounce } from "@mui/material";
import createEngine, { DiagramModel } from "@projectstorm/react-diagrams";
import * as React from "react";
@ -252,12 +253,12 @@ const VisualEditorProvider: React.FC<VisualEditorContextProps> = ({
children,
}) => {
const [selectedCategoryId, setSelectedCategoryId] = React.useState("");
const { mutateAsync: createBlock } = useCreate(EntityType.BLOCK);
const createNode = async (payload: any) => {
const { mutate: createBlock } = useCreate(EntityType.BLOCK);
const createNode = (payload: any) => {
payload.position = payload.position || getCentroid();
payload.category = payload.category || selectedCategoryId;
return await createBlock(payload, {
return createBlock(payload, {
onSuccess({ id }) {
addNode({
...payload,

View File

@ -1,16 +1,17 @@
/*
* 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:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/
import {
NodeModel,
DiagramModel,
DiagramEngine,
DiagramModel,
DiagramModelGenerics,
NodeModel,
} from "@projectstorm/react-diagrams";
import { ReactNode } from "react";
@ -38,7 +39,7 @@ export interface IVisualEditor {
}
export interface IVisualEditorContext {
addNode: (payload: any) => NodeModel;
createNode: (payload: any) => Promise<IBlock>;
createNode;
buildDiagram: (props: IVisualEditor) => {
model: DiagramModel<DiagramModelGenerics>;
engine: DiagramEngine;