feat: module dependencies

This commit is contained in:
2025-09-18 17:53:26 +04:00
parent a95d05e28b
commit 0805a86335
17 changed files with 153 additions and 119 deletions

View File

@ -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>