59 lines
1.3 KiB
TypeScript
59 lines
1.3 KiB
TypeScript
import type { ApolloClient } from '@apollo/client';
|
|
import { gql } from '@apollo/client';
|
|
import type { GetInsuranceDataQuery } from 'graphql/crm.types';
|
|
|
|
const QUERY_GET_INSURANCE_DATA = gql`
|
|
query GetInsuranceData($evo_account_type: [Int!]) {
|
|
osago: accounts(
|
|
evo_account_type: $evo_account_type
|
|
evo_type_ins_policy: [100000001]
|
|
statecode: 0
|
|
) {
|
|
value: accountid
|
|
label: name
|
|
}
|
|
|
|
kasko: accounts(
|
|
evo_account_type: $evo_account_type
|
|
evo_type_ins_policy: [100000000]
|
|
statecode: 0
|
|
) {
|
|
value: accountid
|
|
label: name
|
|
}
|
|
|
|
fingap: accounts(
|
|
evo_account_type: $evo_account_type
|
|
evo_type_ins_policy: [100000002]
|
|
statecode: 0
|
|
) {
|
|
value: accountid
|
|
label: name
|
|
}
|
|
}
|
|
`;
|
|
|
|
export default async function getInsuranceData(apolloClient: ApolloClient<object>) {
|
|
const { data: insuranceData } = await apolloClient.query<GetInsuranceDataQuery>({
|
|
query: QUERY_GET_INSURANCE_DATA,
|
|
});
|
|
|
|
const insurance = {
|
|
osago: {
|
|
insuranceCompany: insuranceData.osago,
|
|
},
|
|
kasko: {
|
|
insuranceCompany: insuranceData.kasko,
|
|
},
|
|
fingap: {
|
|
insuranceCompany: insuranceData.fingap,
|
|
},
|
|
};
|
|
|
|
return {
|
|
tables: {
|
|
insurance,
|
|
},
|
|
};
|
|
}
|