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