UNPKG

@pisell/pisellos

Version:

一个可扩展的前端模块化SDK框架,支持插件系统

64 lines (62 loc) 2.75 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/solution/BookingByStep/utils/products.ts var products_exports = {}; __export(products_exports, { getAvailableProductResources: () => getAvailableProductResources }); module.exports = __toCommonJS(products_exports); var getAvailableProductResources = (products) => { const rules = []; const resourcesMap = {}; const resourceIds = []; products.forEach((product) => { var _a, _b, _c; const tempResourceIds = []; (_c = (_b = (_a = product == null ? void 0 : product.product_resource) == null ? void 0 : _a.resources) == null ? void 0 : _b.forEach) == null ? void 0 : _c.call(_b, (resource) => { var _a2, _b2; if ((resource == null ? void 0 : resource.status) == 1) { tempResourceIds.push(resource == null ? void 0 : resource.id); if (!resourcesMap[resource == null ? void 0 : resource.id]) { resourcesMap[resource == null ? void 0 : resource.id] = resource; } if ((_a2 = resource == null ? void 0 : resource.default_resource) == null ? void 0 : _a2.length) { resourceIds.push(...resource == null ? void 0 : resource.default_resource); } else if ((_b2 = resource == null ? void 0 : resource.optional_resource) == null ? void 0 : _b2.length) { resourceIds.push(...resource == null ? void 0 : resource.optional_resource); } } }); const rule = {}; if (product == null ? void 0 : product.cut_off_time) { rule.cut_off_time = product == null ? void 0 : product.cut_off_time; } if (tempResourceIds) { rule.resourceFormIds = [...new Set(tempResourceIds)]; } if (product == null ? void 0 : product._schedule) { rule.schedule = product == null ? void 0 : product._schedule; } rules.push(rule); }); return { resourceIds: [...new Set(resourceIds)], rules, resourcesMap }; }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { getAvailableProductResources });