import getAddProductTypes from './get-addproduct-types-data'; import getBrands from './get-brands'; import getDealers from './get-dealers'; import getInsuranceData from './get-insurance-data'; import getMainData from './get-main-data'; export default function getData(apolloClient, store) { const { $calculation, $tables } = store; function setManyOptions(options) { Object.keys(options).forEach((elementName) => { const elementOptions = options[elementName]; $calculation.element(elementName).setOptions(elementOptions); }); } getMainData(apolloClient).then(({ options }) => setManyOptions(options)); getBrands(apolloClient).then(({ options }) => setManyOptions(options)); getDealers(apolloClient).then(({ options }) => setManyOptions(options)); getAddProductTypes(apolloClient).then(({ options }) => setManyOptions(options)); function setManyRowOptions(options) { Object.keys(options).forEach((key) => { const rowOptions = options[key]; if (rowOptions !== undefined) { Object.keys(rowOptions).forEach((valueName) => { $tables.insurance.row(key).setOptions(valueName, rowOptions[valueName]); }); } }); } getInsuranceData(apolloClient).then(({ tables }) => setManyRowOptions(tables.insurance)); } export { default as getOwnerData } from './get-owner-data';