feat: small refactor, address now is telegram

This commit is contained in:
2024-04-28 19:58:41 +03:00
parent 95e256bcff
commit 532bb738bd
10 changed files with 50 additions and 41 deletions

View File

@@ -10,16 +10,20 @@ export const useClientsTableColumns = () => {
header: "Имя",
},
{
accessorKey: "details.address",
header: "Адрес"
accessorKey: "details.telegram",
header: "Телеграм"
},
{
accessorKey: "details.email",
header: "EMAIL"
},
{
accessorKey: "details.phone_number",
accessorKey: "details.phoneNumber",
header: "Телефон"
},
{
accessorKey: "details.inn",
header: "ИНН"
}
], []);
}

View File

@@ -1,5 +1,5 @@
import {ContextModalProps} from "@mantine/modals";
import {Fieldset, NumberInput, TextInput} from "@mantine/core";
import {Fieldset, TextInput} from "@mantine/core";
import {useForm} from "@mantine/form";
import {ClientSchema} from "../../../../client";
import {getDigitsCount} from "../../../../shared/lib/utils.ts";
@@ -19,7 +19,7 @@ const ClientFormModal = ({
id: innerProps.element.id,
name: innerProps.element.name,
details: {
address: innerProps.element.details?.address,
telegram: innerProps.element.details?.telegram,
phoneNumber: innerProps.element.details?.phoneNumber,
email: innerProps.element.details?.email,
inn: innerProps.element.details?.inn
@@ -28,7 +28,7 @@ const ClientFormModal = ({
id: -1,
name: '',
details: {
address: '',
telegram: '',
phoneNumber: '',
email: '',
inn: undefined
@@ -39,7 +39,7 @@ const ClientFormModal = ({
validate: {
name: (name: string) => name.trim() !== '' ? null : "Необходимо ввести название клиента",
details: {
address: (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 : "Необходимо ввести номер телефона",
email: (email: string | undefined | null) => (email && email.trim() !== '') ? null : "Необходимо ввести почту",
inn: (inn: string | undefined | null) => (inn && getDigitsCount(parseInt(inn)) >= 10) ? null : "ИНН должен содержать не менее 10 цифр",
@@ -71,9 +71,9 @@ const ClientFormModal = ({
<Fieldset legend={"Дополнительная информация"}>
<TextInput
required
label={"Адрес"}
placeholder={"Введите адрес"}
{...form.getInputProps('details.address')}
label={"Телеграм"}
placeholder={"Введите телеграм"}
{...form.getInputProps('details.telegram')}
/>
<TextInput
required
@@ -87,9 +87,8 @@ const ClientFormModal = ({
placeholder={"Введите почту"}
{...form.getInputProps('details.email')}
/>
<NumberInput
<TextInput
required
hideControls
label={"ИНН"}
placeholder={"Введите ИНН"}
{...form.getInputProps('details.inn')}

View File

@@ -109,9 +109,9 @@ const Content: FC<Props> = ({deal}) => {
{...form.getInputProps('client.details.email')}
/>
<TextInput
placeholder={"Введите адрес"}
label={"Адрес"}
{...form.getInputProps('client.details.address')}
placeholder={"Введите телеграм"}
label={"Телеграм"}
{...form.getInputProps('client.details.telegram')}
/>
<TextInput
placeholder={"Введите ИНН"}

View File

@@ -47,20 +47,36 @@ export const LeadsPage: FC = () => {
}
const onDragEnd = async (result: DropResult) => {
setIsDragEnded(true);
// If there is no changes
if (!result.destination || result.destination == result.source) return;
// Checking for valid dealId
const dealId = parseInt(result.draggableId);
if (isNaN(dealId)) return;
// Checking for valid deal
const summary = summaries.find(summary => summary.id == dealId);
if (!summary) return;
// Checking if it is custom actions
const droppableId = result.destination.droppableId;
if (droppableId === 'DELETE') {
onDelete(dealId);
return;
}
const status = getDealStatusByName(droppableId);
const request: Partial<DealSummaryReorderRequest> = {
dealId: dealId,
index: result.destination.index,
status: getDealStatusByName(droppableId)
status: status
}
if (status == summary.status) {
DealService.reorderDealSummaries({requestBody: request as DealSummaryReorderRequest})
.then(async response => {
setSummaries(response.summaries);
await refetch();
});
return;
}
modals.openContextModal({
modal: 'enterDeadline',

View File

@@ -78,7 +78,11 @@ export const ProductsPage: FC = () => {
useEffect(() => {
if (!paginationInfo) return;
setTotalPages(paginationInfo.totalPages);
if (currentPage > paginationInfo.totalPages) {
setCurrentPage(1);
}
}, [paginationInfo]);
return (
<>
<div className={styles['container']}>