feat: module dependencies
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import { FC } from "react";
|
||||
import { isEqual } from "lodash";
|
||||
import { Button, Stack } from "@mantine/core";
|
||||
import { useForm } from "@mantine/form";
|
||||
import resolveDependencies from "@/app/deals/drawers/ProjectEditorDrawer/tabs/ModulesTab/utils/resolveDependencies";
|
||||
import { ProjectSchema } from "@/lib/client";
|
||||
import ModulesTable from "./components/ModulesTable";
|
||||
|
||||
@ -16,8 +16,16 @@ export const ModulesTab: FC<Props> = ({ value, onChange }) => {
|
||||
});
|
||||
|
||||
const onSubmit = (values: ProjectSchema) => {
|
||||
onChange(values);
|
||||
form.setInitialValues(values);
|
||||
const modulesWithDependencies = resolveDependencies(
|
||||
values.builtInModules
|
||||
);
|
||||
const updatedValues = {
|
||||
...values,
|
||||
builtInModules: modulesWithDependencies,
|
||||
};
|
||||
form.setValues(updatedValues);
|
||||
form.resetDirty();
|
||||
onChange(updatedValues);
|
||||
};
|
||||
|
||||
return (
|
||||
@ -32,7 +40,7 @@ export const ModulesTab: FC<Props> = ({ value, onChange }) => {
|
||||
<Button
|
||||
type={"submit"}
|
||||
variant={"default"}
|
||||
disabled={isEqual(value, form.values)}>
|
||||
disabled={!form.isDirty()}>
|
||||
Сохранить
|
||||
</Button>
|
||||
</Stack>
|
||||
|
||||
Reference in New Issue
Block a user