feat: add comment, creating refactor

This commit is contained in:
2024-10-15 07:41:43 +03:00
parent f1566cdf44
commit b1f3df5c05
3 changed files with 31 additions and 16 deletions

View File

@@ -1,5 +1,5 @@
import { ContextModalProps } from "@mantine/modals";
import { Fieldset, TextInput } from "@mantine/core";
import { Fieldset, Textarea, TextInput } from "@mantine/core";
import { useForm } from "@mantine/form";
import { ClientSchema } from "../../../../client";
import BaseFormModal, {
@@ -10,25 +10,26 @@ import BarcodeTemplateSelect from "../../../../components/Selects/BarcodeTemplat
type Props = CreateEditFormProps<ClientSchema>;
const ClientFormModal = ({
context,
id,
innerProps,
}: ContextModalProps<Props>) => {
context,
id,
innerProps,
}: ContextModalProps<Props>) => {
const isEditing = "onChange" in innerProps;
const initialValues: ClientSchema = isEditing
? innerProps.element
: {
id: -1,
name: "",
companyName: "",
details: {
telegram: "",
phoneNumber: "",
email: "",
inn: undefined,
},
};
id: -1,
name: "",
companyName: "",
details: {
telegram: "",
phoneNumber: "",
email: "",
inn: undefined,
},
comment: "",
};
const form = useForm<ClientSchema>({
initialValues: initialValues,
validate: {
@@ -63,6 +64,7 @@ const ClientFormModal = ({
placeholder={"Введите название клиента"}
{...form.getInputProps("name")}
/>
</Fieldset>
<Fieldset legend={"Дополнительная информация"}>
<TextInput
@@ -90,6 +92,12 @@ const ClientFormModal = ({
placeholder={"Введите название компании"}
{...form.getInputProps("companyName")}
/>
<Textarea
label={"Комментарий"}
placeholder={"Введите комментарий"}
{...form.getInputProps("comment")}
/>
</Fieldset>
<Fieldset legend={"Настройки"}>
<BarcodeTemplateSelect

View File

@@ -1,4 +1,4 @@
import { Button, Fieldset, Flex, rem, TextInput } from "@mantine/core";
import { Button, Fieldset, Flex, rem, Textarea, TextInput } from "@mantine/core";
import { useDealPageContext } from "../../../contexts/DealPageContext.tsx";
import { useForm } from "@mantine/form";
import { DealGeneralFormType } from "./DealEditDrawerGeneralTab.tsx";
@@ -75,6 +75,12 @@ const ClientTab = () => {
label={"ИНН"}
{...form.getInputProps("client.details.inn")}
/>
<Textarea
placeholder={"Введите комментарий"}
label={"Комментарий"}
{...form.getInputProps("client.comment")}
/>
</Fieldset>
</Flex>
<Flex