feat: client details

This commit is contained in:
2024-04-30 02:44:04 +03:00
parent c402271bbe
commit e157406787

View File

@@ -2,7 +2,6 @@ import {ContextModalProps} from "@mantine/modals";
import {Fieldset, TextInput} from "@mantine/core"; import {Fieldset, TextInput} from "@mantine/core";
import {useForm} from "@mantine/form"; import {useForm} from "@mantine/form";
import {ClientSchema} from "../../../../client"; import {ClientSchema} from "../../../../client";
import {getDigitsCount} from "../../../../shared/lib/utils.ts";
import BaseFormModal, {CreateEditFormProps} from "../BaseFormModal/BaseFormModal.tsx"; import BaseFormModal, {CreateEditFormProps} from "../BaseFormModal/BaseFormModal.tsx";
@@ -38,12 +37,12 @@ const ClientFormModal = ({
initialValues: initialValues, initialValues: initialValues,
validate: { validate: {
name: (name: string) => name.trim() !== '' ? null : "Необходимо ввести название клиента", name: (name: string) => name.trim() !== '' ? null : "Необходимо ввести название клиента",
details: { // details: {
telegram: (address: string | undefined | null) => (address && address.trim() !== '') ? null : "Необходимо ввести телеграм", // telegram: (address: string | undefined | null) => (address && address.trim() !== '') ? null : "Необходимо ввести телеграм",
phoneNumber: (phoneNumber: string | undefined | null) => (phoneNumber && phoneNumber.trim() !== '') ? null : "Необходимо ввести номер телефона", // phoneNumber: (phoneNumber: string | undefined | null) => (phoneNumber && phoneNumber.trim() !== '') ? null : "Необходимо ввести номер телефона",
email: (email: string | undefined | null) => (email && email.trim() !== '') ? null : "Необходимо ввести почту", // email: (email: string | undefined | null) => (email && email.trim() !== '') ? null : "Необходимо ввести почту",
inn: (inn: string | undefined | null) => (inn && getDigitsCount(parseInt(inn)) >= 10) ? null : "ИНН должен содержать не менее 10 цифр", // inn: (inn: string | undefined | null) => (inn && getDigitsCount(parseInt(inn)) >= 10) ? null : "ИНН должен содержать не менее 10 цифр",
} // }
} }
}) })
@@ -70,25 +69,21 @@ const ClientFormModal = ({
</Fieldset> </Fieldset>
<Fieldset legend={"Дополнительная информация"}> <Fieldset legend={"Дополнительная информация"}>
<TextInput <TextInput
required
label={"Телеграм"} label={"Телеграм"}
placeholder={"Введите телеграм"} placeholder={"Введите телеграм"}
{...form.getInputProps('details.telegram')} {...form.getInputProps('details.telegram')}
/> />
<TextInput <TextInput
required
label={"Номер телефона"} label={"Номер телефона"}
placeholder={"Введите номер телефона"} placeholder={"Введите номер телефона"}
{...form.getInputProps('details.phoneNumber')} {...form.getInputProps('details.phoneNumber')}
/> />
<TextInput <TextInput
required
label={"Почта"} label={"Почта"}
placeholder={"Введите почту"} placeholder={"Введите почту"}
{...form.getInputProps('details.email')} {...form.getInputProps('details.email')}
/> />
<TextInput <TextInput
required
label={"ИНН"} label={"ИНН"}
placeholder={"Введите ИНН"} placeholder={"Введите ИНН"}
{...form.getInputProps('details.inn')} {...form.getInputProps('details.inn')}