UNPKG

@procraft/widget-order

Version:

Order widget for landing

89 lines 3.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getCatalogItems = void 0; // import { Scalars } from '../../modules/gql/generated/types' const getCatalogItemData_1 = require("../getCatalogItemData"); /** * Из запроса всех данных получаем элементы каталога * @deprecated */ const getCatalogItems = (course, catalogItem // courseUid: Scalars['Int'], // tariffUid: Scalars['Int'] ) => { // console.log('getCatalogItems course', course); // console.log('getCatalogItems catalogItem', catalogItem); var _a, _b; const items = []; // const course = courses.find((n) => n.uid === courseUid) // if (!course) { // console.error('getCatalogItems. Can not get course') // } else { const tariff = (_a = course.tariffs) === null || _a === void 0 ? void 0 : _a.find((n) => { var _a; return n.uid === ((_a = catalogItem.course) === null || _a === void 0 ? void 0 : _a.tariffId); }); if (!tariff) { console.error('getCatalogItems. Can not get tariff'); } else { (_b = catalogItem.fieldValues) === null || _b === void 0 ? void 0 : _b.map((fieldValue) => { /** * Получаем каталогитем по потоку, курсу и тарифу */ // const catalogItem = course.catalogItems?.find((catalogItem) => { // return ( // catalogItem.course?.courseId === course.uid && // catalogItem.course.flowId === flow.uid && // catalogItem.course.tariffId === tariff.uid // ) // }) // if (!catalogItem) { // // console.error('getCatalogItems. Can not get catalogItem'); // return null // } fieldValue; // const catalogItemData = getCatalogItemData(catalogItem, course, tariff, flow); // const catalogItemData = getCatalogItemData(catalogItem, course) const catalogItemData = (0, getCatalogItemData_1.getCatalogItemData)(fieldValue); if (!catalogItemData) { console.error('getCatalogItems. Can not get catalogItemData'); return null; } const { placesLeft } = catalogItemData; // items.push({ // id: flow.id, // uid: flow.uid, // name: flow.name, // price: catalogItem.unitPrice || 0, // oldPrice: catalogItem.unitPriceOriginal || null, // catalogItem, // course: { // flow, // tariff, // }, // placesLeft, // reviewsCount: catalogItem.reviewsCount || undefined, // reviews: catalogItem.reviews || undefined, // subscriptions: catalogItem.subscriptions || undefined, // }) items.push({ // id: fieldValue.id, // uid: fieldValue.uid, name: fieldValue.optionName, price: catalogItem.unitPrice || 0, oldPrice: catalogItem.unitPriceOriginal || null, catalogItem, course: { // flow, tariff, }, placesLeft, reviewsCount: catalogItem.reviewsCount || undefined, reviews: catalogItem.reviews || undefined, // subscriptions: catalogItem.subscriptions || undefined, }); }); } // } return items; }; exports.getCatalogItems = getCatalogItems; //# sourceMappingURL=index.js.map