Merge pull request 'add error handling' (#467) from feat/configure-modules into main

This commit is contained in:
clan-bot
2023-11-04 14:12:27 +00:00
2 changed files with 17 additions and 7 deletions

View File

@@ -9,6 +9,7 @@ import MenuItem from "@mui/material/MenuItem";
import OutlinedInput from "@mui/material/OutlinedInput"; import OutlinedInput from "@mui/material/OutlinedInput";
import Select, { SelectChangeEvent } from "@mui/material/Select"; import Select, { SelectChangeEvent } from "@mui/material/Select";
import { useEffect } from "react"; import { useEffect } from "react";
import { toast } from "react-hot-toast";
import { CreateMachineForm, FormStepContentProps } from "./interfaces"; import { CreateMachineForm, FormStepContentProps } from "./interfaces";
const ITEM_HEIGHT = 48; const ITEM_HEIGHT = 48;
@@ -52,11 +53,17 @@ export default function ClanModules(props: ClanModulesProps) {
const newValue = typeof value === "string" ? value.split(",") : value; const newValue = typeof value === "string" ? value.split(",") : value;
formHooks.setValue("modules", newValue); formHooks.setValue("modules", newValue);
setMachineSchema(clanName, "example_machine", { setMachineSchema(clanName, "example_machine", {
imports: selectedModules, imports: newValue,
}).then((response) => { })
.then((response) => {
if (response.statusText == "OK") { if (response.statusText == "OK") {
formHooks.setValue("schema", response.data.schema); formHooks.setValue("schema", response.data.schema);
} }
})
.catch((error) => {
formHooks.setValue("schema", {});
console.error({ error });
toast.error(`${error.message}`);
}); });
}; };
return ( return (

View File

@@ -100,7 +100,10 @@ export function CreateMachineForm() {
<> <>
{activeStep !== steps.length - 1 && ( {activeStep !== steps.length - 1 && (
<Button <Button
disabled={!formHooks.formState.isValid} disabled={
!formHooks.formState.isValid ||
(activeStep == 1 && !formHooks.watch("schema")?.type)
}
onClick={handleNext} onClick={handleNext}
color="secondary" color="secondary"
> >