refactor: modals refactored

This commit is contained in:
2025-09-05 14:25:36 +04:00
parent 7694b4ae03
commit d0c734d481
24 changed files with 292 additions and 97 deletions

View File

@ -4,23 +4,23 @@ import { Button, Flex, rem, TextInput } from "@mantine/core";
import { useForm } from "@mantine/form";
import { ContextModalProps } from "@mantine/modals";
type Props = {
onComplete: (value: string) => void;
defaultValue?: string;
};
type FormType = {
name: string;
};
type Props = {
onChange: (value: FormType) => void;
value?: FormType;
};
const EnterNameModal = ({
id,
context,
innerProps,
}: ContextModalProps<Props>) => {
const form = useForm<FormType>({
initialValues: {
name: innerProps.defaultValue ?? "",
initialValues: innerProps.value || {
name: "",
},
validate: {
name: name => !name && "Введите название",
@ -28,7 +28,7 @@ const EnterNameModal = ({
});
const onSubmit = (values: FormType) => {
innerProps.onComplete(values.name);
innerProps.onChange(values);
context.closeModal(id);
};