diff --git a/src/client/Elements/TextArea.jsx b/src/client/Elements/TextArea.jsx index 907a5ba..e63b1d5 100644 --- a/src/client/Elements/TextArea.jsx +++ b/src/client/Elements/TextArea.jsx @@ -2,9 +2,16 @@ import { Form, Input as AntInput } from 'antd'; import { Status } from 'core/types/statuses'; import React from 'react'; -const TextArea = ({ value, setCurrentValue, status, ...props }) => { +const TextArea = ({ + value, + setCurrentValue, + status, + validateStatus, + message, + ...props +}) => { return ( - + { - console.log('createLead action'); + const { + contactClient, + contact, + newClient, + account, + commentLead, + phoneNumber, + } = CalculationStore.values; + if (!contactClient && !contact) { + CalculationStore.setValidation('selectContactClient', false); + CalculationStore.setValidation('tbxContact', false); + openNotification({ + type: 'error', + title: 'Ошибка во время создания интереса', + description: 'Не указан контакт клиента!', + })(); + } + if (!newClient && !account) { + CalculationStore.setValidation('tbxNewClient', false); + CalculationStore.setValidation('selectAccount', false); + openNotification({ + type: 'error', + title: 'Ошибка во время создания интереса', + description: 'Не указан клиент!', + })(); + } + if (!commentLead) { + CalculationStore.setValidation('tbxCommentLead', false); + openNotification({ + type: 'error', + title: 'Ошибка во время создания интереса', + description: 'Не указан комментарий к интересу!', + })(); + } + if (contact && !phoneNumber) { + CalculationStore.setValidation('tbxPhoneNumber', false); + openNotification({ + type: 'error', + title: 'Ошибка во время создания интереса', + description: 'Не указан телефон контактного лица', + })(); + } }, }; diff --git a/src/client/stores/CalculationStore/Effects/autorun.ts b/src/client/stores/CalculationStore/Effects/autorun.ts index 2fba7d5..24bf8d0 100644 --- a/src/client/stores/CalculationStore/Effects/autorun.ts +++ b/src/client/stores/CalculationStore/Effects/autorun.ts @@ -1,11 +1,32 @@ import { IAutorunEffect } from 'core/types/effect'; const autorunEffects: IAutorunEffect[] = [ - // calculationStore => () => { - // if (parseInt(calculationStore.values.price) > 25) { - // calculationStore.setValue('one', 100500); - // } - // } + calculationStore => () => { + const { contactClient, contact } = calculationStore.values; + if (contactClient || contact) { + calculationStore.setValidation('selectContactClient', true); + calculationStore.setValidation('tbxContact', true); + } + }, + calculationStore => () => { + const { newClient, account } = calculationStore.values; + if (newClient || account) { + calculationStore.setValidation('tbxNewClient', true); + calculationStore.setValidation('selectAccount', true); + } + }, + calculationStore => () => { + const { commentLead } = calculationStore.values; + if (commentLead) { + calculationStore.setValidation('tbxCommentLead', true); + } + }, + calculationStore => () => { + const { phoneNumber } = calculationStore.values; + if (phoneNumber) { + calculationStore.setValidation('tbxPhoneNumber', true); + } + }, ]; export default autorunEffects; diff --git a/src/core/types/effect.ts b/src/core/types/effect.ts index f2730f5..9435f98 100644 --- a/src/core/types/effect.ts +++ b/src/core/types/effect.ts @@ -7,10 +7,7 @@ type TCommonStore = typeof CommonStore; export type ActionsNames = 'createLead'; export type TAction = { - [actionName in ActionsNames]?: ( - CalculationStore: ICalculationStore, - CommonStore?: TCommonStore, - ) => void; + [actionName in ActionsNames]?: () => void; }; export interface IAutorunEffect {