fix type errors
This commit is contained in:
parent
7a02483534
commit
74c8b85e4a
@ -15,14 +15,10 @@ import InputLabel from "@mui/material/InputLabel";
|
||||
import MenuItem from "@mui/material/MenuItem";
|
||||
import OutlinedInput from "@mui/material/OutlinedInput";
|
||||
import Select, { SelectChangeEvent } from "@mui/material/Select";
|
||||
import { Dispatch, SetStateAction, useEffect, useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Controller } from "react-hook-form";
|
||||
import { toast } from "react-hot-toast";
|
||||
import {
|
||||
CreateMachineForm,
|
||||
FormHooks,
|
||||
FormStepContentProps,
|
||||
} from "./interfaces";
|
||||
import { CreateMachineForm, FormStepContentProps } from "./interfaces";
|
||||
|
||||
const ITEM_HEIGHT = 48;
|
||||
const ITEM_PADDING_TOP = 8;
|
||||
@ -35,39 +31,39 @@ const MenuProps = {
|
||||
},
|
||||
};
|
||||
|
||||
interface IupdateSchema {
|
||||
clanName: string;
|
||||
modules: string[];
|
||||
formHooks: FormHooks;
|
||||
setSchemaError: Dispatch<SetStateAction<null | string>>;
|
||||
}
|
||||
// interface IupdateSchema {
|
||||
// clanName: string;
|
||||
// modules: string[];
|
||||
// formHooks: FormHooks;
|
||||
// setSchemaError: Dispatch<SetStateAction<null | string>>;
|
||||
// }
|
||||
|
||||
const updateSchema = ({
|
||||
clanName,
|
||||
modules,
|
||||
formHooks,
|
||||
setSchemaError,
|
||||
}: IupdateSchema) => {
|
||||
formHooks.setValue("isSchemaLoading", true);
|
||||
getMachineSchema(clanName, {
|
||||
clanImports: modules,
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.statusText == "OK") {
|
||||
formHooks.setValue("schema", response.data.schema);
|
||||
setSchemaError(null);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
formHooks.setValue("schema", {});
|
||||
console.error({ error });
|
||||
setSchemaError(error.message);
|
||||
toast.error(`${error.message}`);
|
||||
})
|
||||
.finally(() => {
|
||||
formHooks.setValue("isSchemaLoading", false);
|
||||
});
|
||||
};
|
||||
// const updateSchema = ({
|
||||
// clanName,
|
||||
// modules,
|
||||
// formHooks,
|
||||
// setSchemaError,
|
||||
// }: IupdateSchema) => {
|
||||
// formHooks.setValue("isSchemaLoading", true);
|
||||
// getMachineSchema(clanName, {
|
||||
// clanImports: modules,
|
||||
// })
|
||||
// .then((response) => {
|
||||
// if (response.statusText == "OK") {
|
||||
// formHooks.setValue("schema", response.data.schema);
|
||||
// setSchemaError(null);
|
||||
// }
|
||||
// })
|
||||
// .catch((error) => {
|
||||
// formHooks.setValue("schema", {});
|
||||
// console.error({ error });
|
||||
// setSchemaError(error.message);
|
||||
// toast.error(`${error.message}`);
|
||||
// })
|
||||
// .finally(() => {
|
||||
// formHooks.setValue("isSchemaLoading", false);
|
||||
// });
|
||||
// };
|
||||
|
||||
type ClanModulesProps = FormStepContentProps;
|
||||
|
||||
@ -99,7 +95,7 @@ const SchemaErrorMsg = (props: SchemaErrorMsgProps) => (
|
||||
export default function ClanModules(props: ClanModulesProps) {
|
||||
const { clanName, formHooks } = props;
|
||||
const { data, isLoading } = useListClanModules(clanName);
|
||||
const [schemaError, setSchemaError] = useState<string | null>(null);
|
||||
const [schemaError] = useState<string | null>(null);
|
||||
const selectedModules = formHooks.watch("modules");
|
||||
useEffect(() => {
|
||||
getMachineSchema(clanName, {
|
||||
|
@ -32,7 +32,7 @@ export function CreateMachineForm() {
|
||||
},
|
||||
});
|
||||
|
||||
const { handleSubmit, reset, watch } = formHooks;
|
||||
const { handleSubmit, watch } = formHooks;
|
||||
const theme = useTheme();
|
||||
const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
|
||||
const [activeStep, setActiveStep] = useState<number>(0);
|
||||
@ -83,7 +83,7 @@ export function CreateMachineForm() {
|
||||
name: data.name,
|
||||
});
|
||||
await setMachineConfig(clanName, data.name, {
|
||||
config: data.config.formData,
|
||||
clan: data.config.formData,
|
||||
clanImports: data.modules,
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user