apollo: modify evo_addproduct_type.evo_name
This commit is contained in:
parent
29460f4509
commit
7b401c2365
@ -1,5 +1,6 @@
|
||||
import { cache } from './config';
|
||||
import getUrls from '@/config/urls';
|
||||
import { ApolloClient, InMemoryCache } from '@apollo/client';
|
||||
import { ApolloClient } from '@apollo/client';
|
||||
import { isServer } from 'tools/common';
|
||||
|
||||
/** @type {import('@apollo/client').ApolloClient<import('@apollo/client').NormalizedCacheObject>} */
|
||||
@ -9,7 +10,7 @@ const { URL_CRM_GRAPHQL } = getUrls();
|
||||
|
||||
function createApolloClient() {
|
||||
return new ApolloClient({
|
||||
cache: new InMemoryCache(),
|
||||
cache,
|
||||
ssrMode: isServer(),
|
||||
uri: URL_CRM_GRAPHQL,
|
||||
});
|
||||
|
||||
15
apps/web/apollo/config.js
Normal file
15
apps/web/apollo/config.js
Normal file
@ -0,0 +1,15 @@
|
||||
import { InMemoryCache } from '@apollo/client';
|
||||
|
||||
export const cache = new InMemoryCache({
|
||||
typePolicies: {
|
||||
evo_addproduct_type: {
|
||||
fields: {
|
||||
evo_name: {
|
||||
read(_, { readField }) {
|
||||
return `${_} (${readField('evo_graph_price')} руб.)`;
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
@ -289,32 +289,27 @@ export function common({ store, apolloClient, queryClient }: ProcessContext) {
|
||||
variables: { currentDate },
|
||||
});
|
||||
|
||||
const options = evo_addproduct_types
|
||||
?.filter(
|
||||
(x) =>
|
||||
x?.evo_leasingobject_types?.find(
|
||||
(evo_leasingobject_type) =>
|
||||
evo_leasingobject_type?.evo_leasingobject_typeid === leaseObjectType
|
||||
) &&
|
||||
x.evo_whom_register === objectRegistration &&
|
||||
Boolean(
|
||||
leaseObjectCategory === 100_000_001
|
||||
? x.evo_towtruck === true || x.evo_towtruck === false
|
||||
: x.evo_towtruck === false
|
||||
) &&
|
||||
x.evo_gibdd_region === (objectRegionRegistrationId === regionRegistrationId) &&
|
||||
Boolean(typePTS && x.evo_pts_type?.includes(typePTS)) &&
|
||||
Boolean(
|
||||
x.evo_accountid &&
|
||||
evo_region?.accounts?.some(
|
||||
(evo_region_account) => evo_region_account?.accountid === x.evo_accountid
|
||||
)
|
||||
)
|
||||
)
|
||||
.map((x) => ({
|
||||
...x,
|
||||
label: `${x?.label} (${x?.evo_graph_price} руб.)`,
|
||||
}));
|
||||
const options = evo_addproduct_types?.filter(
|
||||
(x) =>
|
||||
x?.evo_leasingobject_types?.find(
|
||||
(evo_leasingobject_type) =>
|
||||
evo_leasingobject_type?.evo_leasingobject_typeid === leaseObjectType
|
||||
) &&
|
||||
x.evo_whom_register === objectRegistration &&
|
||||
Boolean(
|
||||
leaseObjectCategory === 100_000_001
|
||||
? x.evo_towtruck === true || x.evo_towtruck === false
|
||||
: x.evo_towtruck === false
|
||||
) &&
|
||||
x.evo_gibdd_region === (objectRegionRegistrationId === regionRegistrationId) &&
|
||||
Boolean(typePTS && x.evo_pts_type?.includes(typePTS)) &&
|
||||
Boolean(
|
||||
x.evo_accountid &&
|
||||
evo_region?.accounts?.some(
|
||||
(evo_region_account) => evo_region_account?.accountid === x.evo_accountid
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$calculation.element('selectRegistration').setOptions(normalizeOptions(options));
|
||||
}
|
||||
|
||||
@ -103,33 +103,21 @@ function getMainData({ query }, onCompleted) {
|
||||
currentDate,
|
||||
},
|
||||
}).then(({ data }) => {
|
||||
// const selectRegistration = data.evo_addproduct_types
|
||||
// ?.filter((x) => x?.evo_product_type === 100_000_001)
|
||||
// .map((x) => ({
|
||||
// ...x,
|
||||
// label: `${x?.label} (${x?.evo_graph_price} руб.)`,
|
||||
// }));
|
||||
// const selectRegistration = data.evo_addproduct_types?.filter(
|
||||
// (x) => x?.evo_product_type === 100_000_001
|
||||
// );
|
||||
|
||||
const selectTechnicalCard = data.evo_addproduct_types
|
||||
?.filter((x) => x?.evo_product_type === 100_000_000)
|
||||
.map((x) => ({
|
||||
...x,
|
||||
label: `${x?.label} (${x?.evo_graph_price} руб.)`,
|
||||
}));
|
||||
const selectTechnicalCard = data.evo_addproduct_types?.filter(
|
||||
(x) => x?.evo_product_type === 100_000_000
|
||||
);
|
||||
|
||||
const selectTelematic = data.evo_addproduct_types
|
||||
?.filter((x) => x?.evo_product_type === 100_000_004)
|
||||
.map((x) => ({
|
||||
...x,
|
||||
label: `${x?.label} (${x?.evo_graph_price} руб.)`,
|
||||
}));
|
||||
const selectTelematic = data.evo_addproduct_types?.filter(
|
||||
(x) => x?.evo_product_type === 100_000_004
|
||||
);
|
||||
|
||||
const selectTracker = data.evo_addproduct_types
|
||||
?.filter((x) => x?.evo_product_type === 100_000_003)
|
||||
.map((x) => ({
|
||||
...x,
|
||||
label: `${x?.label} (${x?.evo_graph_price} руб.)`,
|
||||
}));
|
||||
const selectTracker = data.evo_addproduct_types?.filter(
|
||||
(x) => x?.evo_product_type === 100_000_003
|
||||
);
|
||||
|
||||
const selectInsNSIB = data.evo_addproduct_types?.filter(
|
||||
(x) => x?.evo_product_type === 100_000_002
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user