process/add-product: fixes

This commit is contained in:
vchikalkin 2024-02-07 13:57:10 +03:00
parent 5291e9ff2e
commit 267c669975

View File

@ -1,3 +1,4 @@
/* eslint-disable sonarjs/cognitive-complexity */
import { createValidationReaction } from '../tools';
import type { ProcessContext } from '../types';
import { createValidationSchema } from './validation';
@ -227,30 +228,30 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
$calculation.element('selectRequirementTelematic').setValue(100_000_003).block();
} else {
$calculation.element('selectRequirementTelematic').unblock();
}
if (leaseObjectTypeId) {
const {
data: { evo_leasingobject_type },
} = await apolloClient.query({
query: CRMTypes.GetLeaseObjectTypeDocument,
variables: { leaseObjectTypeId },
});
if (leaseObjectTypeId) {
const {
data: { evo_leasingobject_type },
} = await apolloClient.query({
query: CRMTypes.GetLeaseObjectTypeDocument,
variables: { leaseObjectTypeId },
});
if (evo_leasingobject_type?.evo_id === '8') {
$calculation
.element('selectRequirementTelematic')
.setOptions(
selectRequirementTelematic.filter((x) =>
[100_000_000, 100_000_001].includes(x.value)
)
);
}
if (evo_leasingobject_type?.evo_id === '8') {
$calculation
.element('selectRequirementTelematic')
.setOptions(
selectRequirementTelematic.filter((x) =>
[100_000_000, 100_000_001].includes(x.value)
)
);
}
if (evo_leasingobject_type?.evo_id === '11') {
$calculation.element('selectRequirementTelematic').setValue(100_000_002).block();
} else {
$calculation.element('selectRequirementTelematic').unblock();
if (evo_leasingobject_type?.evo_id === '11') {
$calculation.element('selectRequirementTelematic').setValue(100_000_002).block();
} else {
$calculation.element('selectRequirementTelematic').unblock();
}
}
}
} else {
@ -309,25 +310,33 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
if (engineType === 100_000_003) {
filteredTelematicTypes = telematicTypes?.filter(
(x) =>
x?.evo_controls_program?.includes(100_000_003) && x.label?.toLowerCase().includes('аво')
x?.evo_controls_program?.includes(100_000_003) &&
x.label?.toLowerCase().includes('аво') &&
!x.label?.toLowerCase().includes('pro')
);
}
if (leaseObjectTypeId) {
const {
data: { evo_leasingobject_type },
} = await apolloClient.query({
query: CRMTypes.GetLeaseObjectTypeDocument,
variables: { leaseObjectTypeId },
});
$calculation.element('selectTracker').resetValue().block();
$calculation.element('selectTelematic').block();
} else {
$calculation.element('selectTracker').unblock();
$calculation.element('selectTelematic').unblock();
if (evo_leasingobject_type?.evo_id === '11') {
filteredTelematicTypes = telematicTypes?.filter(
(x) =>
x?.evo_controls_program?.includes(100_000_002) &&
x.label?.toLowerCase().includes('delta') &&
!x.label?.toLowerCase().includes('pro')
);
if (leaseObjectTypeId) {
const {
data: { evo_leasingobject_type },
} = await apolloClient.query({
query: CRMTypes.GetLeaseObjectTypeDocument,
variables: { leaseObjectTypeId },
});
if (evo_leasingobject_type?.evo_id === '11') {
filteredTelematicTypes = telematicTypes?.filter(
(x) =>
x?.evo_controls_program?.includes(100_000_002) &&
x.label?.toLowerCase().includes('delta') &&
!x.label?.toLowerCase().includes('pro')
);
}
}
}