feat: small refactor, address now is telegram
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
/* tslint:disable */
|
/* tslint:disable */
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
export type ClientDetailsSchema = {
|
export type ClientDetailsSchema = {
|
||||||
address?: (string | null);
|
telegram?: (string | null);
|
||||||
phoneNumber?: (string | null);
|
phoneNumber?: (string | null);
|
||||||
inn?: (string | null);
|
inn?: (string | null);
|
||||||
email?: (string | null);
|
email?: (string | null);
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
export type DealQuickCreateRequest = {
|
export type DealQuickCreateRequest = {
|
||||||
name: string;
|
name: string;
|
||||||
clientName: string;
|
clientName: string;
|
||||||
clientAddress: string;
|
|
||||||
comment: string;
|
comment: string;
|
||||||
acceptanceDate: string;
|
acceptanceDate: string;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export type DealSummaryReorderRequest = {
|
|||||||
dealId: number;
|
dealId: number;
|
||||||
status: number;
|
status: number;
|
||||||
index: number;
|
index: number;
|
||||||
deadline: string;
|
deadline?: (string | null);
|
||||||
comment: string;
|
comment?: (string | null);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -39,12 +39,9 @@ const CreateDealFrom: FC<Props> = ({onSubmit, onCancel}) => {
|
|||||||
{...form.getInputProps('name')}
|
{...form.getInputProps('name')}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className={styles['inputs']}>
|
<div className={styles['inputs']}>
|
||||||
<ClientAutocomplete
|
<ClientAutocomplete
|
||||||
withAddress
|
|
||||||
nameRestProps={form.getInputProps('clientName')}
|
nameRestProps={form.getInputProps('clientName')}
|
||||||
addressRestProps={form.getInputProps('clientAddress')}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {useDebouncedValue} from "@mantine/hooks";
|
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 {FC, useEffect, useState} from "react";
|
||||||
import {Client} from "../../../types/Client.ts";
|
import {Client} from "../../../types/Client.ts";
|
||||||
import {ClientService} from "../../../client";
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,16 +10,20 @@ export const useClientsTableColumns = () => {
|
|||||||
header: "Имя",
|
header: "Имя",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: "details.address",
|
accessorKey: "details.telegram",
|
||||||
header: "Адрес"
|
header: "Телеграм"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: "details.email",
|
accessorKey: "details.email",
|
||||||
header: "EMAIL"
|
header: "EMAIL"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorKey: "details.phone_number",
|
accessorKey: "details.phoneNumber",
|
||||||
header: "Телефон"
|
header: "Телефон"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorKey: "details.inn",
|
||||||
|
header: "ИНН"
|
||||||
}
|
}
|
||||||
], []);
|
], []);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {ContextModalProps} from "@mantine/modals";
|
import {ContextModalProps} from "@mantine/modals";
|
||||||
import {Fieldset, NumberInput, 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 {getDigitsCount} from "../../../../shared/lib/utils.ts";
|
||||||
@@ -19,7 +19,7 @@ const ClientFormModal = ({
|
|||||||
id: innerProps.element.id,
|
id: innerProps.element.id,
|
||||||
name: innerProps.element.name,
|
name: innerProps.element.name,
|
||||||
details: {
|
details: {
|
||||||
address: innerProps.element.details?.address,
|
telegram: innerProps.element.details?.telegram,
|
||||||
phoneNumber: innerProps.element.details?.phoneNumber,
|
phoneNumber: innerProps.element.details?.phoneNumber,
|
||||||
email: innerProps.element.details?.email,
|
email: innerProps.element.details?.email,
|
||||||
inn: innerProps.element.details?.inn
|
inn: innerProps.element.details?.inn
|
||||||
@@ -28,7 +28,7 @@ const ClientFormModal = ({
|
|||||||
id: -1,
|
id: -1,
|
||||||
name: '',
|
name: '',
|
||||||
details: {
|
details: {
|
||||||
address: '',
|
telegram: '',
|
||||||
phoneNumber: '',
|
phoneNumber: '',
|
||||||
email: '',
|
email: '',
|
||||||
inn: undefined
|
inn: undefined
|
||||||
@@ -39,7 +39,7 @@ const ClientFormModal = ({
|
|||||||
validate: {
|
validate: {
|
||||||
name: (name: string) => name.trim() !== '' ? null : "Необходимо ввести название клиента",
|
name: (name: string) => name.trim() !== '' ? null : "Необходимо ввести название клиента",
|
||||||
details: {
|
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 : "Необходимо ввести номер телефона",
|
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 цифр",
|
||||||
@@ -71,9 +71,9 @@ const ClientFormModal = ({
|
|||||||
<Fieldset legend={"Дополнительная информация"}>
|
<Fieldset legend={"Дополнительная информация"}>
|
||||||
<TextInput
|
<TextInput
|
||||||
required
|
required
|
||||||
label={"Адрес"}
|
label={"Телеграм"}
|
||||||
placeholder={"Введите адрес"}
|
placeholder={"Введите телеграм"}
|
||||||
{...form.getInputProps('details.address')}
|
{...form.getInputProps('details.telegram')}
|
||||||
/>
|
/>
|
||||||
<TextInput
|
<TextInput
|
||||||
required
|
required
|
||||||
@@ -87,9 +87,8 @@ const ClientFormModal = ({
|
|||||||
placeholder={"Введите почту"}
|
placeholder={"Введите почту"}
|
||||||
{...form.getInputProps('details.email')}
|
{...form.getInputProps('details.email')}
|
||||||
/>
|
/>
|
||||||
<NumberInput
|
<TextInput
|
||||||
required
|
required
|
||||||
hideControls
|
|
||||||
label={"ИНН"}
|
label={"ИНН"}
|
||||||
placeholder={"Введите ИНН"}
|
placeholder={"Введите ИНН"}
|
||||||
{...form.getInputProps('details.inn')}
|
{...form.getInputProps('details.inn')}
|
||||||
|
|||||||
@@ -109,9 +109,9 @@ const Content: FC<Props> = ({deal}) => {
|
|||||||
{...form.getInputProps('client.details.email')}
|
{...form.getInputProps('client.details.email')}
|
||||||
/>
|
/>
|
||||||
<TextInput
|
<TextInput
|
||||||
placeholder={"Введите адрес"}
|
placeholder={"Введите телеграм"}
|
||||||
label={"Адрес"}
|
label={"Телеграм"}
|
||||||
{...form.getInputProps('client.details.address')}
|
{...form.getInputProps('client.details.telegram')}
|
||||||
/>
|
/>
|
||||||
<TextInput
|
<TextInput
|
||||||
placeholder={"Введите ИНН"}
|
placeholder={"Введите ИНН"}
|
||||||
|
|||||||
@@ -47,20 +47,36 @@ export const LeadsPage: FC = () => {
|
|||||||
}
|
}
|
||||||
const onDragEnd = async (result: DropResult) => {
|
const onDragEnd = async (result: DropResult) => {
|
||||||
setIsDragEnded(true);
|
setIsDragEnded(true);
|
||||||
|
// If there is no changes
|
||||||
if (!result.destination || result.destination == result.source) return;
|
if (!result.destination || result.destination == result.source) return;
|
||||||
|
|
||||||
|
// Checking for valid dealId
|
||||||
const dealId = parseInt(result.draggableId);
|
const dealId = parseInt(result.draggableId);
|
||||||
if (isNaN(dealId)) return;
|
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;
|
const droppableId = result.destination.droppableId;
|
||||||
if (droppableId === 'DELETE') {
|
if (droppableId === 'DELETE') {
|
||||||
onDelete(dealId);
|
onDelete(dealId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const status = getDealStatusByName(droppableId);
|
||||||
const request: Partial<DealSummaryReorderRequest> = {
|
const request: Partial<DealSummaryReorderRequest> = {
|
||||||
dealId: dealId,
|
dealId: dealId,
|
||||||
index: result.destination.index,
|
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({
|
modals.openContextModal({
|
||||||
modal: 'enterDeadline',
|
modal: 'enterDeadline',
|
||||||
|
|||||||
@@ -78,7 +78,11 @@ export const ProductsPage: FC = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!paginationInfo) return;
|
if (!paginationInfo) return;
|
||||||
setTotalPages(paginationInfo.totalPages);
|
setTotalPages(paginationInfo.totalPages);
|
||||||
|
if (currentPage > paginationInfo.totalPages) {
|
||||||
|
setCurrentPage(1);
|
||||||
|
}
|
||||||
}, [paginationInfo]);
|
}, [paginationInfo]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className={styles['container']}>
|
<div className={styles['container']}>
|
||||||
|
|||||||
Reference in New Issue
Block a user