diff --git a/apps/web/process/add-product/reactions.ts b/apps/web/process/add-product/reactions.ts index bc61fcc..7af6f15 100644 --- a/apps/web/process/add-product/reactions.ts +++ b/apps/web/process/add-product/reactions.ts @@ -231,8 +231,18 @@ export default function reactions({ store, apolloClient }: ProcessContext) { 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 === '11') { - $calculation.element('selectRequirementTelematic').setValue(100_000_000).block(); + $calculation.element('selectRequirementTelematic').setValue(100_000_002).block(); } else { $calculation.element('selectRequirementTelematic').unblock(); } @@ -247,8 +257,13 @@ export default function reactions({ store, apolloClient }: ProcessContext) { ); reaction( - () => $calculation.$values.getValues(['requirementTelematic', 'recalcWithRevision']), - async ({ requirementTelematic, recalcWithRevision }) => { + () => + $calculation.$values.getValues([ + 'requirementTelematic', + 'recalcWithRevision', + 'leaseObjectType', + ]), + async ({ requirementTelematic, recalcWithRevision, leaseObjectType: leaseObjectTypeId }) => { const currentDate = dayjs().utc(false).toISOString(); const { data: { evo_addproduct_types: trackerTypes }, @@ -279,6 +294,24 @@ export default function reactions({ store, apolloClient }: ProcessContext) { ); } + 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') + ); + } + } + $calculation.element('selectTracker').setOptions(normalizeOptions(filteredTrackerTypes)); $calculation.element('selectTelematic').setOptions(normalizeOptions(filteredTelematicTypes)); },