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

@@ -3,7 +3,7 @@
/* tslint:disable */
/* eslint-disable */
export type ClientDetailsSchema = {
address?: (string | null);
telegram?: (string | null);
phoneNumber?: (string | null);
inn?: (string | null);
email?: (string | null);

View File

@@ -5,7 +5,6 @@
export type DealQuickCreateRequest = {
name: string;
clientName: string;
clientAddress: string;
comment: string;
acceptanceDate: string;
};

View File

@@ -6,7 +6,7 @@ export type DealSummaryReorderRequest = {
dealId: number;
status: number;
index: number;
deadline: string;
comment: string;
deadline?: (string | null);
comment?: (string | null);
};

View File

@@ -39,12 +39,9 @@ const CreateDealFrom: FC<Props> = ({onSubmit, onCancel}) => {
{...form.getInputProps('name')}
/>
</div>
<div className={styles['inputs']}>
<ClientAutocomplete
withAddress
nameRestProps={form.getInputProps('clientName')}
addressRestProps={form.getInputProps('clientAddress')}
/>
</div>

View File

@@ -1,5 +1,5 @@
import {useDebouncedValue} from "@mantine/hooks";
import {Autocomplete, AutocompleteProps, TextInput, TextInputProps} from "@mantine/core";
import {Autocomplete, AutocompleteProps, TextInputProps} from "@mantine/core";
import {FC, useEffect, useState} from "react";
import {Client} from "../../../types/Client.ts";
import {ClientService} from "../../../client";
@@ -71,23 +71,13 @@ const ClientAutocomplete: FC<Props> = ({onSelect, addressRestProps, nameRestProp
} : {}}
/>
{withAddress &&
<TextInput
placeholder={'Клиент: адрес'}
styles={{
input: {
borderTopLeftRadius: 0,
borderTopRightRadius: 0,
}
}}
value={selectedClient?.address || ''}
onChange={event => {
selectClient(prevState => prevState && {...prevState, address: event.target.value})
}}
/>
}
</>
)
}
export default ClientAutocomplete;
export default ClientAutocomplete;

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']}>