mirror of
https://github.com/hexastack/hexabot
synced 2025-04-30 03:03:16 +00:00
fix(frontend): refactor NLP value logic to use synchronous methods
This commit is contained in:
parent
d5863d2413
commit
cd31b873fd
@ -6,7 +6,6 @@
|
||||
* 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 { faGraduationCap } from "@fortawesome/free-solid-svg-icons";
|
||||
import AddIcon from "@mui/icons-material/Add";
|
||||
import ArrowBackIcon from "@mui/icons-material/ArrowBack";
|
||||
@ -64,22 +63,23 @@ export const NlpValues = ({ entityId }: { entityId: string }) => {
|
||||
params: searchPayload,
|
||||
},
|
||||
);
|
||||
const options = {
|
||||
const { mutate: deleteNlpValue } = useDelete(EntityType.NLP_VALUE, {
|
||||
onError: (error: Error) => {
|
||||
toast.error(error.message || t("message.internal_server_error"));
|
||||
},
|
||||
onSuccess() {
|
||||
refetchEntity();
|
||||
toast.success(t("message.item_delete_success"));
|
||||
},
|
||||
});
|
||||
const { mutate: deleteNlpValues } = useDeleteMany(EntityType.NLP_VALUE, {
|
||||
onError: (error: Error) => {
|
||||
toast.error(error.message || t("message.internal_server_error"));
|
||||
},
|
||||
onSuccess() {
|
||||
toast.success(t("message.item_delete_success"));
|
||||
},
|
||||
};
|
||||
const { mutateAsync: deleteNlpValue } = useDelete(
|
||||
EntityType.NLP_VALUE,
|
||||
options,
|
||||
);
|
||||
const { mutate: deleteNlpValues } = useDeleteMany(
|
||||
EntityType.NLP_VALUE,
|
||||
options,
|
||||
);
|
||||
});
|
||||
const [selectedNlpValues, setSelectedNlpValues] = useState<string[]>([]);
|
||||
const actionColumns = useActionColumns<INlpValue>(
|
||||
EntityType.NLP_VALUE,
|
||||
@ -95,8 +95,7 @@ export const NlpValues = ({ entityId }: { entityId: string }) => {
|
||||
const isConfirmed = await dialogs.confirm(ConfirmDialogBody);
|
||||
|
||||
if (isConfirmed) {
|
||||
await deleteNlpValue(id);
|
||||
refetchEntity();
|
||||
deleteNlpValue(id);
|
||||
}
|
||||
},
|
||||
},
|
||||
|
@ -33,7 +33,18 @@ export const NlpValueForm: FC<
|
||||
entity: EntityType.NLP_ENTITY,
|
||||
format: Format.FULL,
|
||||
});
|
||||
const options = {
|
||||
const { mutate: createNlpValue } = useCreate(EntityType.NLP_VALUE, {
|
||||
onError: () => {
|
||||
rest.onError?.();
|
||||
toast.error(t("message.internal_server_error"));
|
||||
},
|
||||
onSuccess() {
|
||||
rest.onSuccess?.();
|
||||
refetchEntity();
|
||||
toast.success(t("message.success_save"));
|
||||
},
|
||||
});
|
||||
const { mutate: updateNlpValue } = useUpdate(EntityType.NLP_VALUE, {
|
||||
onError: () => {
|
||||
rest.onError?.();
|
||||
toast.error(t("message.internal_server_error"));
|
||||
@ -42,12 +53,7 @@ export const NlpValueForm: FC<
|
||||
rest.onSuccess?.();
|
||||
toast.success(t("message.success_save"));
|
||||
},
|
||||
};
|
||||
const { mutateAsync: createNlpValue } = useCreate(
|
||||
EntityType.NLP_VALUE,
|
||||
options,
|
||||
);
|
||||
const { mutate: updateNlpValue } = useUpdate(EntityType.NLP_VALUE, options);
|
||||
});
|
||||
const { reset, register, handleSubmit, control } = useForm<
|
||||
INlpValueAttributes & {
|
||||
expressions: string[];
|
||||
@ -69,8 +75,7 @@ export const NlpValueForm: FC<
|
||||
if (data) {
|
||||
updateNlpValue({ id: data.id, params });
|
||||
} else {
|
||||
await createNlpValue({ ...params, entity: String(query.id) });
|
||||
refetchEntity();
|
||||
createNlpValue({ ...params, entity: String(query.id) });
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user