process/gibdd: fix reactions
This commit is contained in:
parent
35fd102746
commit
776c2354be
@ -319,6 +319,32 @@ export function common({ store, apolloClient, queryClient }: ProcessContext) {
|
||||
}
|
||||
);
|
||||
|
||||
reaction(
|
||||
() => $calculation.element('selectRegistration').getValue(),
|
||||
async (registrationId) => {
|
||||
if (!registrationId) {
|
||||
$calculation.element('labelRegistrationDescription').resetValue();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const {
|
||||
data: { evo_addproduct_type },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetAddProductTypeDocument,
|
||||
variables: { addproductTypeId: registrationId },
|
||||
});
|
||||
|
||||
if (evo_addproduct_type?.evo_description) {
|
||||
$calculation
|
||||
.element('labelRegistrationDescription')
|
||||
.setValue(evo_addproduct_type?.evo_description);
|
||||
} else {
|
||||
$calculation.element('labelRegistrationDescription').resetValue();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
reaction(
|
||||
() => $calculation.element('selectLegalClientRegion').getValue(),
|
||||
async (regionId) => {
|
||||
@ -471,13 +497,71 @@ export function common({ store, apolloClient, queryClient }: ProcessContext) {
|
||||
const town = evo_towns?.find((x) => x?.evo_fias_id === evo_city_fias_id);
|
||||
if (town) {
|
||||
$calculation.element('selectLegalClientTown').setValue(town.value).block();
|
||||
$calculation.element('selectTownRegistration').setValue(town.value).block();
|
||||
} else {
|
||||
$calculation.element('selectLegalClientTown').resetValue().unblock();
|
||||
$calculation.element('selectTownRegistration').resetValue().unblock();
|
||||
}
|
||||
} else {
|
||||
$calculation.element('selectLegalClientTown').resetValue().unblock();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
reaction(
|
||||
() => $calculation.$values.getValues(['regionRegistration', 'objectRegistration']),
|
||||
async ({ regionRegistration: regionId, objectRegistration }) => {
|
||||
if (!regionId) {
|
||||
$calculation.element('selectTownRegistration').resetValue().unblock();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const leadid = $calculation.element('selectLead').getValue();
|
||||
const opportunityid = $calculation.element('selectOpportunity').getValue();
|
||||
|
||||
let evo_city_fias_id: string | undefined;
|
||||
|
||||
if (leadid) {
|
||||
const {
|
||||
data: { lead },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetLeadDocument,
|
||||
variables: { leadid },
|
||||
});
|
||||
|
||||
if (lead?.accountidData?.evo_address_legalidData?.evo_city_fias_id)
|
||||
evo_city_fias_id = lead?.accountidData?.evo_address_legalidData?.evo_city_fias_id;
|
||||
}
|
||||
|
||||
if (opportunityid) {
|
||||
const {
|
||||
data: { opportunity },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetOpportunityDocument,
|
||||
variables: { opportunityid },
|
||||
});
|
||||
|
||||
if (
|
||||
!evo_city_fias_id &&
|
||||
opportunity?.accountidData?.evo_address_legalidData?.evo_city_fias_id
|
||||
)
|
||||
evo_city_fias_id = opportunity?.accountidData?.evo_address_legalidData?.evo_city_fias_id;
|
||||
}
|
||||
|
||||
if (evo_city_fias_id && objectRegistration === 100_000_000) {
|
||||
const {
|
||||
data: { evo_towns },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetTownsDocument,
|
||||
variables: { regionId },
|
||||
});
|
||||
|
||||
const town = evo_towns?.find((x) => x?.evo_fias_id === evo_city_fias_id);
|
||||
if (town) {
|
||||
$calculation.element('selectTownRegistration').setValue(town.value).block();
|
||||
} else {
|
||||
$calculation.element('selectTownRegistration').resetValue().unblock();
|
||||
}
|
||||
} else {
|
||||
$calculation.element('selectTownRegistration').resetValue().unblock();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user