more createLead validation
This commit is contained in:
parent
af1027bcaf
commit
4a9b062f41
@ -46,6 +46,103 @@ const actions: TAction = {
|
||||
description: 'Не указан телефон контактного лица',
|
||||
})();
|
||||
}
|
||||
|
||||
const { channel } = CalculationStore.values;
|
||||
if (!channel) {
|
||||
CalculationStore.setValidation('selectChannel', false);
|
||||
openNotification({
|
||||
type: 'error',
|
||||
title: 'Ошибка во время создания интереса',
|
||||
description: 'Не указан канал привлечения',
|
||||
})();
|
||||
} else {
|
||||
const {
|
||||
supplier,
|
||||
agent,
|
||||
finDepartment,
|
||||
broker,
|
||||
} = CalculationStore.values;
|
||||
switch (channel) {
|
||||
case 100000000: {
|
||||
CalculationStore.setValidation('selectFinDepartment', true);
|
||||
CalculationStore.setValidation('selectBroker', true);
|
||||
if (!supplier) {
|
||||
CalculationStore.setValidation('selectSupplier', false);
|
||||
openNotification({
|
||||
type: 'error',
|
||||
title: 'Ошибка во время создания интереса',
|
||||
description: 'Не указан поставщик',
|
||||
})();
|
||||
}
|
||||
if (!agent) {
|
||||
CalculationStore.setValidation('selectAgent', false);
|
||||
openNotification({
|
||||
type: 'error',
|
||||
title: 'Ошибка во время создания интереса',
|
||||
description: 'Не указан агент',
|
||||
})();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 100000001: {
|
||||
CalculationStore.setValidation('selectAgent', true);
|
||||
CalculationStore.setValidation('selectBroker', true);
|
||||
if (!supplier) {
|
||||
CalculationStore.setValidation('selectSupplier', false);
|
||||
openNotification({
|
||||
type: 'error',
|
||||
title: 'Ошибка во время создания интереса',
|
||||
description: 'Не указан поставщик',
|
||||
})();
|
||||
}
|
||||
if (!finDepartment) {
|
||||
CalculationStore.setValidation('selectFinDepartment', false);
|
||||
openNotification({
|
||||
type: 'error',
|
||||
title: 'Ошибка во время создания интереса',
|
||||
description: 'Не указан финотдел',
|
||||
})();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 100000002: {
|
||||
CalculationStore.setValidation('selectFinDepartment', true);
|
||||
CalculationStore.setValidation('selectSupplier', true);
|
||||
CalculationStore.setValidation('selectBroker', true);
|
||||
if (!agent) {
|
||||
CalculationStore.setValidation('selectAgent', false);
|
||||
openNotification({
|
||||
type: 'error',
|
||||
title: 'Ошибка во время создания интереса',
|
||||
description: 'Не указан агент',
|
||||
})();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 100000003: {
|
||||
CalculationStore.setValidation('selectFinDepartment', true);
|
||||
CalculationStore.setValidation('selectSupplier', true);
|
||||
CalculationStore.setValidation('selectAgent', true);
|
||||
if (!broker) {
|
||||
CalculationStore.setValidation('selectBroker', false);
|
||||
openNotification({
|
||||
type: 'error',
|
||||
title: 'Ошибка во время создания интереса',
|
||||
description: 'Не указан брокер',
|
||||
})();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 100000004:
|
||||
default: {
|
||||
CalculationStore.setValidation('selectFinDepartment', true);
|
||||
CalculationStore.setValidation('selectSupplier', true);
|
||||
CalculationStore.setValidation('selectAgent', true);
|
||||
CalculationStore.setValidation('selectBroker', true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@ -27,6 +27,55 @@ const autorunEffects: IAutorunEffect[] = [
|
||||
calculationStore.setValidation('tbxPhoneNumber', true);
|
||||
}
|
||||
},
|
||||
|
||||
calculationStore => () => {
|
||||
const { channel } = calculationStore.values;
|
||||
if (channel) {
|
||||
calculationStore.setValidation('selectChannel', true);
|
||||
|
||||
switch (channel) {
|
||||
case 100000000: {
|
||||
const { supplier, agent } = calculationStore.values;
|
||||
if (supplier) {
|
||||
calculationStore.setValidation('selectSupplier', true);
|
||||
}
|
||||
if (agent) {
|
||||
calculationStore.setValidation('selectAgent', true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 100000001: {
|
||||
const { supplier, finDepartment } = calculationStore.values;
|
||||
if (supplier) {
|
||||
calculationStore.setValidation('selectSupplier', true);
|
||||
}
|
||||
if (finDepartment) {
|
||||
calculationStore.setValidation('selectFinDepartment', true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 100000002: {
|
||||
const { agent } = calculationStore.values;
|
||||
if (agent) {
|
||||
calculationStore.setValidation('selectAgent', true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 100000003: {
|
||||
const { broker } = calculationStore.values;
|
||||
if (broker) {
|
||||
calculationStore.setValidation('selectBroker', true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 100000004:
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
export default autorunEffects;
|
||||
|
||||
Reference in New Issue
Block a user