@dainamite/cpq 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +70 -0
- package/LICENSE +21 -0
- package/MIGRATION.md +236 -0
- package/README.md +108 -0
- package/dist/modules/cpq/acl.js +30 -0
- package/dist/modules/cpq/acl.js.map +7 -0
- package/dist/modules/cpq/api/_helpers/handleArcError.js +37 -0
- package/dist/modules/cpq/api/_helpers/handleArcError.js.map +7 -0
- package/dist/modules/cpq/api/attribute-options/route.js +47 -0
- package/dist/modules/cpq/api/attribute-options/route.js.map +7 -0
- package/dist/modules/cpq/api/bundle-slots/route.js +101 -0
- package/dist/modules/cpq/api/bundle-slots/route.js.map +7 -0
- package/dist/modules/cpq/api/bundle-tree/route.js +28 -0
- package/dist/modules/cpq/api/bundle-tree/route.js.map +7 -0
- package/dist/modules/cpq/api/context.js +29 -0
- package/dist/modules/cpq/api/context.js.map +7 -0
- package/dist/modules/cpq/api/inventory/assets/route.js +113 -0
- package/dist/modules/cpq/api/inventory/assets/route.js.map +7 -0
- package/dist/modules/cpq/api/inventory/assets/status/route.js +35 -0
- package/dist/modules/cpq/api/inventory/assets/status/route.js.map +7 -0
- package/dist/modules/cpq/api/inventory/customer/[customerId]/parent-items/route.js +30 -0
- package/dist/modules/cpq/api/inventory/customer/[customerId]/parent-items/route.js.map +7 -0
- package/dist/modules/cpq/api/inventory/customer/[customerId]/route.js +31 -0
- package/dist/modules/cpq/api/inventory/customer/[customerId]/route.js.map +7 -0
- package/dist/modules/cpq/api/inventory/subscription-items/route.js +99 -0
- package/dist/modules/cpq/api/inventory/subscription-items/route.js.map +7 -0
- package/dist/modules/cpq/api/inventory/subscriptions/[subscriptionId]/change-log/route.js +57 -0
- package/dist/modules/cpq/api/inventory/subscriptions/[subscriptionId]/change-log/route.js.map +7 -0
- package/dist/modules/cpq/api/inventory/subscriptions/expiring/route.js +62 -0
- package/dist/modules/cpq/api/inventory/subscriptions/expiring/route.js.map +7 -0
- package/dist/modules/cpq/api/inventory/subscriptions/route.js +116 -0
- package/dist/modules/cpq/api/inventory/subscriptions/route.js.map +7 -0
- package/dist/modules/cpq/api/inventory/subscriptions/status/route.js +35 -0
- package/dist/modules/cpq/api/inventory/subscriptions/status/route.js.map +7 -0
- package/dist/modules/cpq/api/offering-components/route.js +91 -0
- package/dist/modules/cpq/api/offering-components/route.js.map +7 -0
- package/dist/modules/cpq/api/orders/[orderId]/activate/route.js +39 -0
- package/dist/modules/cpq/api/orders/[orderId]/activate/route.js.map +7 -0
- package/dist/modules/cpq/api/orders/[orderId]/route.js +28 -0
- package/dist/modules/cpq/api/orders/[orderId]/route.js.map +7 -0
- package/dist/modules/cpq/api/orders/[orderId]/status/route.js +38 -0
- package/dist/modules/cpq/api/orders/[orderId]/status/route.js.map +7 -0
- package/dist/modules/cpq/api/orders/route.js +71 -0
- package/dist/modules/cpq/api/orders/route.js.map +7 -0
- package/dist/modules/cpq/api/price-rules/route.js +180 -0
- package/dist/modules/cpq/api/price-rules/route.js.map +7 -0
- package/dist/modules/cpq/api/pricing-table-entries/route.js +142 -0
- package/dist/modules/cpq/api/pricing-table-entries/route.js.map +7 -0
- package/dist/modules/cpq/api/pricing-tables/route.js +179 -0
- package/dist/modules/cpq/api/pricing-tables/route.js.map +7 -0
- package/dist/modules/cpq/api/product-attributes/route.js +160 -0
- package/dist/modules/cpq/api/product-attributes/route.js.map +7 -0
- package/dist/modules/cpq/api/product-charges/route.js +166 -0
- package/dist/modules/cpq/api/product-charges/route.js.map +7 -0
- package/dist/modules/cpq/api/product-offerings/route.js +294 -0
- package/dist/modules/cpq/api/product-offerings/route.js.map +7 -0
- package/dist/modules/cpq/api/product-relationships/route.js +144 -0
- package/dist/modules/cpq/api/product-relationships/route.js.map +7 -0
- package/dist/modules/cpq/api/product-specifications/route.js +292 -0
- package/dist/modules/cpq/api/product-specifications/route.js.map +7 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/cancel-meta/route.js +71 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/cancel-meta/route.js.map +7 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/clone/route.js +29 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/clone/route.js.map +7 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/items/[lineId]/route.js +54 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/items/[lineId]/route.js.map +7 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/items/route.js +27 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/items/route.js.map +7 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/merge-meta/route.js +72 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/merge-meta/route.js.map +7 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/recalculate/route.js +35 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/recalculate/route.js.map +7 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/route.js +102 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/route.js.map +7 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/status/route.js +27 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/status/route.js.map +7 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/target-subscriptions/[targetId]/route.js +79 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/target-subscriptions/[targetId]/route.js.map +7 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/target-subscriptions/route.js +95 -0
- package/dist/modules/cpq/api/quotes/[quoteId]/target-subscriptions/route.js.map +7 -0
- package/dist/modules/cpq/api/quotes/attributes/route.js +52 -0
- package/dist/modules/cpq/api/quotes/attributes/route.js.map +7 -0
- package/dist/modules/cpq/api/quotes/from-subscription/route.js +72 -0
- package/dist/modules/cpq/api/quotes/from-subscription/route.js.map +7 -0
- package/dist/modules/cpq/api/quotes/price/route.js +69 -0
- package/dist/modules/cpq/api/quotes/price/route.js.map +7 -0
- package/dist/modules/cpq/api/quotes/route.js +97 -0
- package/dist/modules/cpq/api/quotes/route.js.map +7 -0
- package/dist/modules/cpq/api/quotes/validate-relationships/route.js +86 -0
- package/dist/modules/cpq/api/quotes/validate-relationships/route.js.map +7 -0
- package/dist/modules/cpq/api/resolveQuotingService.js +7 -0
- package/dist/modules/cpq/api/resolveQuotingService.js.map +7 -0
- package/dist/modules/cpq/api/wizards/resolve/route.js +38 -0
- package/dist/modules/cpq/api/wizards/resolve/route.js.map +7 -0
- package/dist/modules/cpq/api/wizards/route.js +111 -0
- package/dist/modules/cpq/api/wizards/route.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/inventory/AssetsTable.js +136 -0
- package/dist/modules/cpq/backend/cpq/inventory/AssetsTable.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/inventory/SubscriptionsTable.js +185 -0
- package/dist/modules/cpq/backend/cpq/inventory/SubscriptionsTable.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/inventory/assets/[id]/page.js +343 -0
- package/dist/modules/cpq/backend/cpq/inventory/assets/[id]/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/inventory/assets/[id]/page.meta.js +13 -0
- package/dist/modules/cpq/backend/cpq/inventory/assets/[id]/page.meta.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/inventory/page.js +35 -0
- package/dist/modules/cpq/backend/cpq/inventory/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/inventory/page.meta.js +18 -0
- package/dist/modules/cpq/backend/cpq/inventory/page.meta.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/inventory/shared.js +20 -0
- package/dist/modules/cpq/backend/cpq/inventory/shared.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/inventory/subscriptions/[id]/page.js +794 -0
- package/dist/modules/cpq/backend/cpq/inventory/subscriptions/[id]/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/inventory/subscriptions/[id]/page.meta.js +13 -0
- package/dist/modules/cpq/backend/cpq/inventory/subscriptions/[id]/page.meta.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/offerings/[id]/page.js +917 -0
- package/dist/modules/cpq/backend/cpq/offerings/[id]/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/offerings/page.js +405 -0
- package/dist/modules/cpq/backend/cpq/offerings/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/offerings/page.meta.js +18 -0
- package/dist/modules/cpq/backend/cpq/offerings/page.meta.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/orders/[id]/page.js +677 -0
- package/dist/modules/cpq/backend/cpq/orders/[id]/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/orders/page.js +134 -0
- package/dist/modules/cpq/backend/cpq/orders/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/orders/page.meta.js +18 -0
- package/dist/modules/cpq/backend/cpq/orders/page.meta.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/price-rules/PriceRuleForm.js +272 -0
- package/dist/modules/cpq/backend/cpq/price-rules/PriceRuleForm.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/price-rules/[id]/page.js +407 -0
- package/dist/modules/cpq/backend/cpq/price-rules/[id]/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/price-rules/[id]/page.meta.js +13 -0
- package/dist/modules/cpq/backend/cpq/price-rules/[id]/page.meta.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/price-rules/page.js +211 -0
- package/dist/modules/cpq/backend/cpq/price-rules/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/price-rules/page.meta.js +18 -0
- package/dist/modules/cpq/backend/cpq/price-rules/page.meta.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/pricing/[id]/EntriesEditor.js +275 -0
- package/dist/modules/cpq/backend/cpq/pricing/[id]/EntriesEditor.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/pricing/[id]/ImportPreview.js +112 -0
- package/dist/modules/cpq/backend/cpq/pricing/[id]/ImportPreview.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/pricing/[id]/page.js +492 -0
- package/dist/modules/cpq/backend/cpq/pricing/[id]/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/pricing/[id]/xlsxExport.js +50 -0
- package/dist/modules/cpq/backend/cpq/pricing/[id]/xlsxExport.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/pricing/[id]/xlsxImport.js +249 -0
- package/dist/modules/cpq/backend/cpq/pricing/[id]/xlsxImport.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/pricing/page.js +87 -0
- package/dist/modules/cpq/backend/cpq/pricing/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/pricing/page.meta.js +18 -0
- package/dist/modules/cpq/backend/cpq/pricing/page.meta.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/quotes/[id]/_components/ArcQuoteConfigurator.js +652 -0
- package/dist/modules/cpq/backend/cpq/quotes/[id]/_components/ArcQuoteConfigurator.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/quotes/[id]/page.js +1289 -0
- package/dist/modules/cpq/backend/cpq/quotes/[id]/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/quotes/page.js +283 -0
- package/dist/modules/cpq/backend/cpq/quotes/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/quotes/page.meta.js +18 -0
- package/dist/modules/cpq/backend/cpq/quotes/page.meta.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/specifications/[id]/DependsOnRulesEditor.js +214 -0
- package/dist/modules/cpq/backend/cpq/specifications/[id]/DependsOnRulesEditor.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/specifications/[id]/page.js +1399 -0
- package/dist/modules/cpq/backend/cpq/specifications/[id]/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/specifications/page.js +148 -0
- package/dist/modules/cpq/backend/cpq/specifications/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/specifications/page.meta.js +18 -0
- package/dist/modules/cpq/backend/cpq/specifications/page.meta.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/wizards/[definitionCode]/detail/page.js +204 -0
- package/dist/modules/cpq/backend/cpq/wizards/[definitionCode]/detail/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/wizards/[definitionCode]/page.js +191 -0
- package/dist/modules/cpq/backend/cpq/wizards/[definitionCode]/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/wizards/page.js +119 -0
- package/dist/modules/cpq/backend/cpq/wizards/page.js.map +7 -0
- package/dist/modules/cpq/backend/cpq/wizards/page.meta.js +18 -0
- package/dist/modules/cpq/backend/cpq/wizards/page.meta.js.map +7 -0
- package/dist/modules/cpq/ce.js +151 -0
- package/dist/modules/cpq/ce.js.map +7 -0
- package/dist/modules/cpq/cli.js +11 -0
- package/dist/modules/cpq/cli.js.map +7 -0
- package/dist/modules/cpq/components/CpqListView.js +265 -0
- package/dist/modules/cpq/components/CpqListView.js.map +7 -0
- package/dist/modules/cpq/components/NumberInput.js +95 -0
- package/dist/modules/cpq/components/NumberInput.js.map +7 -0
- package/dist/modules/cpq/components/StatusPath.js +60 -0
- package/dist/modules/cpq/components/StatusPath.js.map +7 -0
- package/dist/modules/cpq/components/statusMaps.js +66 -0
- package/dist/modules/cpq/components/statusMaps.js.map +7 -0
- package/dist/modules/cpq/components/useCpqRowActions.js +125 -0
- package/dist/modules/cpq/components/useCpqRowActions.js.map +7 -0
- package/dist/modules/cpq/data/entities.js +1556 -0
- package/dist/modules/cpq/data/entities.js.map +7 -0
- package/dist/modules/cpq/data/validators.js +575 -0
- package/dist/modules/cpq/data/validators.js.map +7 -0
- package/dist/modules/cpq/di.js +57 -0
- package/dist/modules/cpq/di.js.map +7 -0
- package/dist/modules/cpq/events.js +50 -0
- package/dist/modules/cpq/events.js.map +7 -0
- package/dist/modules/cpq/index.js +16 -0
- package/dist/modules/cpq/index.js.map +7 -0
- package/dist/modules/cpq/lib/seeds/api.js +32 -0
- package/dist/modules/cpq/lib/seeds/api.js.map +7 -0
- package/dist/modules/cpq/lib/seeds/tenant-provisioning.js +158 -0
- package/dist/modules/cpq/lib/seeds/tenant-provisioning.js.map +7 -0
- package/dist/modules/cpq/lib/seeds.js +6 -0
- package/dist/modules/cpq/lib/seeds.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260220220000_cpq.js +40 -0
- package/dist/modules/cpq/migrations/Migration20260220220000_cpq.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260330000000_cpq_product_domain.js +54 -0
- package/dist/modules/cpq/migrations/Migration20260330000000_cpq_product_domain.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260331000000_cpq_charge_unique_per_offering.js +15 -0
- package/dist/modules/cpq/migrations/Migration20260331000000_cpq_charge_unique_per_offering.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260401000000_cpq_quoting_v2.js +62 -0
- package/dist/modules/cpq/migrations/Migration20260401000000_cpq_quoting_v2.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260402000000_cpq_workflows.js +56 -0
- package/dist/modules/cpq/migrations/Migration20260402000000_cpq_workflows.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260407000000_cpq_pricing_tables_v2.js +26 -0
- package/dist/modules/cpq/migrations/Migration20260407000000_cpq_pricing_tables_v2.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260407100000_cpq_price_rules.js +37 -0
- package/dist/modules/cpq/migrations/Migration20260407100000_cpq_price_rules.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260408000000_cpq_price_rules.js +35 -0
- package/dist/modules/cpq/migrations/Migration20260408000000_cpq_price_rules.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260410000000_cpq_drop_datacentres_inventory.js +21 -0
- package/dist/modules/cpq/migrations/Migration20260410000000_cpq_drop_datacentres_inventory.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260410000000_cpq_wizard_rename.js +46 -0
- package/dist/modules/cpq/migrations/Migration20260410000000_cpq_wizard_rename.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260410100000_cpq_inventory.js +118 -0
- package/dist/modules/cpq/migrations/Migration20260410100000_cpq_inventory.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260411000000_cpq_orders.js +63 -0
- package/dist/modules/cpq/migrations/Migration20260411000000_cpq_orders.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260412000000_cpq_bundled_offerings.js +28 -0
- package/dist/modules/cpq/migrations/Migration20260412000000_cpq_bundled_offerings.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260504064621_cpq_arc.js +36 -0
- package/dist/modules/cpq/migrations/Migration20260504064621_cpq_arc.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260514000000_cpq_spec_merge_retired_deprecated.js +14 -0
- package/dist/modules/cpq/migrations/Migration20260514000000_cpq_spec_merge_retired_deprecated.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260514100000_cpq_offering_merge_retired_deprecated.js +14 -0
- package/dist/modules/cpq/migrations/Migration20260514100000_cpq_offering_merge_retired_deprecated.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260514110000_cpq_list_search_indexes.js +58 -0
- package/dist/modules/cpq/migrations/Migration20260514110000_cpq_list_search_indexes.js.map +7 -0
- package/dist/modules/cpq/migrations/Migration20260515000000_cpq_inventory_subscriptions_search_indexes.js +29 -0
- package/dist/modules/cpq/migrations/Migration20260515000000_cpq_inventory_subscriptions_search_indexes.js.map +7 -0
- package/dist/modules/cpq/services/cpqBundleService.js +447 -0
- package/dist/modules/cpq/services/cpqBundleService.js.map +7 -0
- package/dist/modules/cpq/services/cpqInventoryService.js +1371 -0
- package/dist/modules/cpq/services/cpqInventoryService.js.map +7 -0
- package/dist/modules/cpq/services/cpqOrderService.js +901 -0
- package/dist/modules/cpq/services/cpqOrderService.js.map +7 -0
- package/dist/modules/cpq/services/cpqPricingService.js +289 -0
- package/dist/modules/cpq/services/cpqPricingService.js.map +7 -0
- package/dist/modules/cpq/services/cpqProductService.js +204 -0
- package/dist/modules/cpq/services/cpqProductService.js.map +7 -0
- package/dist/modules/cpq/services/cpqQuotingService.js +1867 -0
- package/dist/modules/cpq/services/cpqQuotingService.js.map +7 -0
- package/dist/modules/cpq/services/cpqValidationService.js +234 -0
- package/dist/modules/cpq/services/cpqValidationService.js.map +7 -0
- package/dist/modules/cpq/services/cpqWizardService.js +137 -0
- package/dist/modules/cpq/services/cpqWizardService.js.map +7 -0
- package/dist/modules/cpq/services/types.js +114 -0
- package/dist/modules/cpq/services/types.js.map +7 -0
- package/dist/modules/cpq/setup.js +49 -0
- package/dist/modules/cpq/setup.js.map +7 -0
- package/dist/modules/cpq/subscribers/subscription-amended-log.js +18 -0
- package/dist/modules/cpq/subscribers/subscription-amended-log.js.map +7 -0
- package/dist/modules/cpq/subscribers/subscription-cancelled-log.js +19 -0
- package/dist/modules/cpq/subscribers/subscription-cancelled-log.js.map +7 -0
- package/dist/modules/cpq/subscribers/subscription-merged-log.js +20 -0
- package/dist/modules/cpq/subscribers/subscription-merged-log.js.map +7 -0
- package/dist/modules/cpq/subscribers/subscription-renewed-log.js +18 -0
- package/dist/modules/cpq/subscribers/subscription-renewed-log.js.map +7 -0
- package/dist/modules/cpq/subscribers/subscription-superseded-log.js +18 -0
- package/dist/modules/cpq/subscribers/subscription-superseded-log.js.map +7 -0
- package/dist/modules/cpq/widgets/injection/customer-inventory/widget.client.js +192 -0
- package/dist/modules/cpq/widgets/injection/customer-inventory/widget.client.js.map +7 -0
- package/dist/modules/cpq/widgets/injection/customer-inventory/widget.js +17 -0
- package/dist/modules/cpq/widgets/injection/customer-inventory/widget.js.map +7 -0
- package/dist/modules/cpq/widgets/injection/order-cpq-tab/widget.client.js +79 -0
- package/dist/modules/cpq/widgets/injection/order-cpq-tab/widget.client.js.map +7 -0
- package/dist/modules/cpq/widgets/injection/order-cpq-tab/widget.js +17 -0
- package/dist/modules/cpq/widgets/injection/order-cpq-tab/widget.js.map +7 -0
- package/dist/modules/cpq/widgets/injection/quote-configurator/widget.client.js +181 -0
- package/dist/modules/cpq/widgets/injection/quote-configurator/widget.client.js.map +7 -0
- package/dist/modules/cpq/widgets/injection/quote-configurator/widget.js +17 -0
- package/dist/modules/cpq/widgets/injection/quote-configurator/widget.js.map +7 -0
- package/dist/modules/cpq/widgets/injection-table.js +44 -0
- package/dist/modules/cpq/widgets/injection-table.js.map +7 -0
- package/dist/modules/cpq/workflows/WizardRunner.js +113 -0
- package/dist/modules/cpq/workflows/WizardRunner.js.map +7 -0
- package/dist/modules/cpq/workflows/WizardTrigger.js +116 -0
- package/dist/modules/cpq/workflows/WizardTrigger.js.map +7 -0
- package/dist/modules/cpq/workflows/engine.js +188 -0
- package/dist/modules/cpq/workflows/engine.js.map +7 -0
- package/dist/modules/cpq/workflows/registry.js +16 -0
- package/dist/modules/cpq/workflows/registry.js.map +7 -0
- package/dist/modules/cpq/workflows/steps/CustomerSelectStep.js +119 -0
- package/dist/modules/cpq/workflows/steps/CustomerSelectStep.js.map +7 -0
- package/dist/modules/cpq/workflows/steps/InventorySelectStep.js +24 -0
- package/dist/modules/cpq/workflows/steps/InventorySelectStep.js.map +7 -0
- package/dist/modules/cpq/workflows/steps/ItemListStep.js +115 -0
- package/dist/modules/cpq/workflows/steps/ItemListStep.js.map +7 -0
- package/dist/modules/cpq/workflows/steps/OfferingSelectStep.js +327 -0
- package/dist/modules/cpq/workflows/steps/OfferingSelectStep.js.map +7 -0
- package/dist/modules/cpq/workflows/steps/ProductConfigureStep.js +231 -0
- package/dist/modules/cpq/workflows/steps/ProductConfigureStep.js.map +7 -0
- package/dist/modules/cpq/workflows/steps/ReviewStep.js +152 -0
- package/dist/modules/cpq/workflows/steps/ReviewStep.js.map +7 -0
- package/dist/modules/cpq/workflows/steps/index.js +49 -0
- package/dist/modules/cpq/workflows/steps/index.js.map +7 -0
- package/dist/modules/cpq/workflows/types.js +1 -0
- package/dist/modules/cpq/workflows/types.js.map +7 -0
- package/package.json +150 -0
- package/src/modules/cpq/__integration__/TC-CPQ-001.spec.ts +177 -0
- package/src/modules/cpq/__integration__/TC-CPQ-002.spec.ts +123 -0
- package/src/modules/cpq/__integration__/TC-CPQ-003.spec.ts +115 -0
- package/src/modules/cpq/__integration__/TC-CPQ-004.spec.ts +184 -0
- package/src/modules/cpq/__integration__/TC-CPQ-005.spec.ts +43 -0
- package/src/modules/cpq/__integration__/TC-CPQ-006.spec.ts +87 -0
- package/src/modules/cpq/__integration__/TC-CPQ-007.spec.ts +79 -0
- package/src/modules/cpq/__integration__/TC-CPQ-008.spec.ts +55 -0
- package/src/modules/cpq/__integration__/TC-CPQ-009.spec.ts +45 -0
- package/src/modules/cpq/__integration__/TC-CPQ-010.spec.ts +54 -0
- package/src/modules/cpq/__integration__/TC-CPQ-011.spec.ts +24 -0
- package/src/modules/cpq/__integration__/TC-CPQ-012.spec.ts +62 -0
- package/src/modules/cpq/__integration__/TC-CPQ-ARC-001.spec.ts +52 -0
- package/src/modules/cpq/__integration__/TC-CPQ-ARC-002.spec.ts +65 -0
- package/src/modules/cpq/__integration__/TC-CPQ-ARC-003.spec.ts +107 -0
- package/src/modules/cpq/__integration__/TC-CPQ-ARC-004.spec.ts +74 -0
- package/src/modules/cpq/__integration__/TC-CPQ-ARC-005.spec.ts +86 -0
- package/src/modules/cpq/__integration__/TC-CPQ-ARC-006.spec.ts +79 -0
- package/src/modules/cpq/__integration__/TC-CPQ-ARC-007.spec.ts +63 -0
- package/src/modules/cpq/__integration__/TC-CPQ-ARC-008.spec.ts +62 -0
- package/src/modules/cpq/__integration__/TC-CPQ-ARC-009.spec.ts +62 -0
- package/src/modules/cpq/__integration__/TC-CPQ-ARC-010.spec.ts +59 -0
- package/src/modules/cpq/__integration__/TC-CPQ-ARC-011.spec.ts +128 -0
- package/src/modules/cpq/__integration__/_helpers/cpqArcFixtures.ts +208 -0
- package/src/modules/cpq/__tests__/package-isolation.test.ts +232 -0
- package/src/modules/cpq/acl.ts +26 -0
- package/src/modules/cpq/api/_helpers/__tests__/handleArcError.test.ts +117 -0
- package/src/modules/cpq/api/_helpers/handleArcError.ts +81 -0
- package/src/modules/cpq/api/attribute-options/route.ts +55 -0
- package/src/modules/cpq/api/bundle-slots/route.ts +112 -0
- package/src/modules/cpq/api/bundle-tree/route.ts +31 -0
- package/src/modules/cpq/api/context.ts +39 -0
- package/src/modules/cpq/api/inventory/assets/route.ts +123 -0
- package/src/modules/cpq/api/inventory/assets/status/route.ts +34 -0
- package/src/modules/cpq/api/inventory/customer/[customerId]/parent-items/route.ts +30 -0
- package/src/modules/cpq/api/inventory/customer/[customerId]/route.ts +31 -0
- package/src/modules/cpq/api/inventory/subscription-items/route.ts +107 -0
- package/src/modules/cpq/api/inventory/subscriptions/[subscriptionId]/change-log/route.ts +64 -0
- package/src/modules/cpq/api/inventory/subscriptions/expiring/route.ts +66 -0
- package/src/modules/cpq/api/inventory/subscriptions/route.ts +126 -0
- package/src/modules/cpq/api/inventory/subscriptions/status/route.ts +34 -0
- package/src/modules/cpq/api/offering-components/route.ts +103 -0
- package/src/modules/cpq/api/orders/[orderId]/activate/route.ts +48 -0
- package/src/modules/cpq/api/orders/[orderId]/route.ts +28 -0
- package/src/modules/cpq/api/orders/[orderId]/status/route.ts +38 -0
- package/src/modules/cpq/api/orders/route.ts +77 -0
- package/src/modules/cpq/api/price-rules/route.ts +210 -0
- package/src/modules/cpq/api/pricing-table-entries/route.ts +159 -0
- package/src/modules/cpq/api/pricing-tables/route.ts +202 -0
- package/src/modules/cpq/api/product-attributes/route.ts +175 -0
- package/src/modules/cpq/api/product-charges/route.ts +181 -0
- package/src/modules/cpq/api/product-offerings/route.ts +329 -0
- package/src/modules/cpq/api/product-relationships/route.ts +156 -0
- package/src/modules/cpq/api/product-specifications/route.ts +325 -0
- package/src/modules/cpq/api/quotes/[quoteId]/cancel-meta/route.ts +77 -0
- package/src/modules/cpq/api/quotes/[quoteId]/clone/route.ts +28 -0
- package/src/modules/cpq/api/quotes/[quoteId]/items/[lineId]/route.ts +55 -0
- package/src/modules/cpq/api/quotes/[quoteId]/items/route.ts +26 -0
- package/src/modules/cpq/api/quotes/[quoteId]/merge-meta/route.ts +78 -0
- package/src/modules/cpq/api/quotes/[quoteId]/recalculate/route.ts +34 -0
- package/src/modules/cpq/api/quotes/[quoteId]/route.ts +109 -0
- package/src/modules/cpq/api/quotes/[quoteId]/status/route.ts +26 -0
- package/src/modules/cpq/api/quotes/[quoteId]/target-subscriptions/[targetId]/route.ts +91 -0
- package/src/modules/cpq/api/quotes/[quoteId]/target-subscriptions/route.ts +107 -0
- package/src/modules/cpq/api/quotes/attributes/route.ts +61 -0
- package/src/modules/cpq/api/quotes/from-subscription/route.ts +85 -0
- package/src/modules/cpq/api/quotes/price/route.ts +81 -0
- package/src/modules/cpq/api/quotes/route.ts +114 -0
- package/src/modules/cpq/api/quotes/validate-relationships/route.ts +100 -0
- package/src/modules/cpq/api/resolveQuotingService.ts +11 -0
- package/src/modules/cpq/api/wizards/resolve/route.ts +39 -0
- package/src/modules/cpq/api/wizards/route.ts +127 -0
- package/src/modules/cpq/backend/cpq/inventory/AssetsTable.tsx +166 -0
- package/src/modules/cpq/backend/cpq/inventory/SubscriptionsTable.tsx +251 -0
- package/src/modules/cpq/backend/cpq/inventory/assets/[id]/page.meta.ts +9 -0
- package/src/modules/cpq/backend/cpq/inventory/assets/[id]/page.tsx +440 -0
- package/src/modules/cpq/backend/cpq/inventory/page.meta.ts +16 -0
- package/src/modules/cpq/backend/cpq/inventory/page.tsx +49 -0
- package/src/modules/cpq/backend/cpq/inventory/shared.tsx +32 -0
- package/src/modules/cpq/backend/cpq/inventory/subscriptions/[id]/page.meta.ts +9 -0
- package/src/modules/cpq/backend/cpq/inventory/subscriptions/[id]/page.tsx +1085 -0
- package/src/modules/cpq/backend/cpq/offerings/[id]/page.tsx +1165 -0
- package/src/modules/cpq/backend/cpq/offerings/page.meta.ts +16 -0
- package/src/modules/cpq/backend/cpq/offerings/page.tsx +468 -0
- package/src/modules/cpq/backend/cpq/orders/[id]/page.tsx +921 -0
- package/src/modules/cpq/backend/cpq/orders/page.meta.ts +16 -0
- package/src/modules/cpq/backend/cpq/orders/page.tsx +182 -0
- package/src/modules/cpq/backend/cpq/price-rules/PriceRuleForm.tsx +310 -0
- package/src/modules/cpq/backend/cpq/price-rules/[id]/page.meta.ts +9 -0
- package/src/modules/cpq/backend/cpq/price-rules/[id]/page.tsx +472 -0
- package/src/modules/cpq/backend/cpq/price-rules/page.meta.ts +16 -0
- package/src/modules/cpq/backend/cpq/price-rules/page.tsx +253 -0
- package/src/modules/cpq/backend/cpq/pricing/[id]/EntriesEditor.tsx +431 -0
- package/src/modules/cpq/backend/cpq/pricing/[id]/ImportPreview.tsx +122 -0
- package/src/modules/cpq/backend/cpq/pricing/[id]/page.tsx +588 -0
- package/src/modules/cpq/backend/cpq/pricing/[id]/xlsxExport.ts +90 -0
- package/src/modules/cpq/backend/cpq/pricing/[id]/xlsxImport.ts +338 -0
- package/src/modules/cpq/backend/cpq/pricing/page.meta.ts +16 -0
- package/src/modules/cpq/backend/cpq/pricing/page.tsx +111 -0
- package/src/modules/cpq/backend/cpq/quotes/[id]/_components/ArcQuoteConfigurator.tsx +737 -0
- package/src/modules/cpq/backend/cpq/quotes/[id]/page.tsx +1721 -0
- package/src/modules/cpq/backend/cpq/quotes/page.meta.ts +16 -0
- package/src/modules/cpq/backend/cpq/quotes/page.tsx +370 -0
- package/src/modules/cpq/backend/cpq/specifications/[id]/DependsOnRulesEditor.tsx +300 -0
- package/src/modules/cpq/backend/cpq/specifications/[id]/page.tsx +1722 -0
- package/src/modules/cpq/backend/cpq/specifications/page.meta.ts +16 -0
- package/src/modules/cpq/backend/cpq/specifications/page.tsx +191 -0
- package/src/modules/cpq/backend/cpq/wizards/[definitionCode]/detail/page.tsx +319 -0
- package/src/modules/cpq/backend/cpq/wizards/[definitionCode]/page.tsx +234 -0
- package/src/modules/cpq/backend/cpq/wizards/page.meta.ts +16 -0
- package/src/modules/cpq/backend/cpq/wizards/page.tsx +141 -0
- package/src/modules/cpq/ce.ts +150 -0
- package/src/modules/cpq/cli.ts +10 -0
- package/src/modules/cpq/components/CpqListView.tsx +431 -0
- package/src/modules/cpq/components/NumberInput.tsx +166 -0
- package/src/modules/cpq/components/StatusPath.tsx +116 -0
- package/src/modules/cpq/components/statusMaps.ts +148 -0
- package/src/modules/cpq/components/useCpqRowActions.tsx +183 -0
- package/src/modules/cpq/data/__tests__/validators.arc.test.ts +271 -0
- package/src/modules/cpq/data/__tests__/validators.test.ts +782 -0
- package/src/modules/cpq/data/entities.ts +1467 -0
- package/src/modules/cpq/data/validators.ts +663 -0
- package/src/modules/cpq/di.ts +70 -0
- package/src/modules/cpq/events.ts +62 -0
- package/src/modules/cpq/index.ts +15 -0
- package/src/modules/cpq/lib/seeds/__tests__/api.test.ts +86 -0
- package/src/modules/cpq/lib/seeds/__tests__/tenant-provisioning.test.ts +349 -0
- package/src/modules/cpq/lib/seeds/api.ts +119 -0
- package/src/modules/cpq/lib/seeds/tenant-provisioning.ts +239 -0
- package/src/modules/cpq/lib/seeds.ts +18 -0
- package/src/modules/cpq/migrations/.snapshot-open-mercato.json +7473 -0
- package/src/modules/cpq/migrations/Migration20260220220000_cpq.ts +51 -0
- package/src/modules/cpq/migrations/Migration20260330000000_cpq_product_domain.ts +70 -0
- package/src/modules/cpq/migrations/Migration20260331000000_cpq_charge_unique_per_offering.ts +15 -0
- package/src/modules/cpq/migrations/Migration20260401000000_cpq_quoting_v2.ts +73 -0
- package/src/modules/cpq/migrations/Migration20260402000000_cpq_workflows.ts +59 -0
- package/src/modules/cpq/migrations/Migration20260407000000_cpq_pricing_tables_v2.ts +30 -0
- package/src/modules/cpq/migrations/Migration20260407100000_cpq_price_rules.ts +36 -0
- package/src/modules/cpq/migrations/Migration20260408000000_cpq_price_rules.ts +33 -0
- package/src/modules/cpq/migrations/Migration20260410000000_cpq_drop_datacentres_inventory.ts +22 -0
- package/src/modules/cpq/migrations/Migration20260410000000_cpq_wizard_rename.ts +56 -0
- package/src/modules/cpq/migrations/Migration20260410100000_cpq_inventory.ts +118 -0
- package/src/modules/cpq/migrations/Migration20260411000000_cpq_orders.ts +62 -0
- package/src/modules/cpq/migrations/Migration20260412000000_cpq_bundled_offerings.ts +33 -0
- package/src/modules/cpq/migrations/Migration20260504064621_cpq_arc.ts +68 -0
- package/src/modules/cpq/migrations/Migration20260514000000_cpq_spec_merge_retired_deprecated.ts +30 -0
- package/src/modules/cpq/migrations/Migration20260514100000_cpq_offering_merge_retired_deprecated.ts +27 -0
- package/src/modules/cpq/migrations/Migration20260514110000_cpq_list_search_indexes.ts +82 -0
- package/src/modules/cpq/migrations/Migration20260515000000_cpq_inventory_subscriptions_search_indexes.ts +52 -0
- package/src/modules/cpq/services/__tests__/_helpers/mockEm.ts +59 -0
- package/src/modules/cpq/services/__tests__/cpqBundleService.test.ts +661 -0
- package/src/modules/cpq/services/__tests__/cpqInventoryService.arc.test.ts +357 -0
- package/src/modules/cpq/services/__tests__/cpqInventoryService.test.ts +718 -0
- package/src/modules/cpq/services/__tests__/cpqOrderService.test.ts +603 -0
- package/src/modules/cpq/services/__tests__/cpqPricingService.test.ts +1012 -0
- package/src/modules/cpq/services/__tests__/cpqProductService.test.ts +603 -0
- package/src/modules/cpq/services/__tests__/cpqQuotingService.arc.test.ts +143 -0
- package/src/modules/cpq/services/__tests__/cpqQuotingService.test.ts +658 -0
- package/src/modules/cpq/services/__tests__/cpqValidationService.test.ts +811 -0
- package/src/modules/cpq/services/__tests__/cpqWizardService.test.ts +389 -0
- package/src/modules/cpq/services/__tests__/types.test.ts +359 -0
- package/src/modules/cpq/services/cpqBundleService.ts +671 -0
- package/src/modules/cpq/services/cpqInventoryService.ts +1929 -0
- package/src/modules/cpq/services/cpqOrderService.ts +1230 -0
- package/src/modules/cpq/services/cpqPricingService.ts +412 -0
- package/src/modules/cpq/services/cpqProductService.ts +311 -0
- package/src/modules/cpq/services/cpqQuotingService.ts +2638 -0
- package/src/modules/cpq/services/cpqValidationService.ts +323 -0
- package/src/modules/cpq/services/cpqWizardService.ts +204 -0
- package/src/modules/cpq/services/types.ts +303 -0
- package/src/modules/cpq/setup.ts +63 -0
- package/src/modules/cpq/subscribers/subscription-amended-log.ts +20 -0
- package/src/modules/cpq/subscribers/subscription-cancelled-log.ts +19 -0
- package/src/modules/cpq/subscribers/subscription-merged-log.ts +22 -0
- package/src/modules/cpq/subscribers/subscription-renewed-log.ts +18 -0
- package/src/modules/cpq/subscribers/subscription-superseded-log.ts +19 -0
- package/src/modules/cpq/widgets/injection/customer-inventory/widget.client.tsx +339 -0
- package/src/modules/cpq/widgets/injection/customer-inventory/widget.ts +16 -0
- package/src/modules/cpq/widgets/injection/order-cpq-tab/widget.client.tsx +96 -0
- package/src/modules/cpq/widgets/injection/order-cpq-tab/widget.ts +16 -0
- package/src/modules/cpq/widgets/injection/quote-configurator/widget.client.tsx +265 -0
- package/src/modules/cpq/widgets/injection/quote-configurator/widget.ts +16 -0
- package/src/modules/cpq/widgets/injection-table.ts +42 -0
- package/src/modules/cpq/workflows/WizardRunner.tsx +158 -0
- package/src/modules/cpq/workflows/WizardTrigger.tsx +142 -0
- package/src/modules/cpq/workflows/engine.tsx +278 -0
- package/src/modules/cpq/workflows/registry.ts +15 -0
- package/src/modules/cpq/workflows/steps/CustomerSelectStep.tsx +136 -0
- package/src/modules/cpq/workflows/steps/InventorySelectStep.tsx +34 -0
- package/src/modules/cpq/workflows/steps/ItemListStep.tsx +146 -0
- package/src/modules/cpq/workflows/steps/OfferingSelectStep.tsx +438 -0
- package/src/modules/cpq/workflows/steps/ProductConfigureStep.tsx +287 -0
- package/src/modules/cpq/workflows/steps/ReviewStep.tsx +219 -0
- package/src/modules/cpq/workflows/steps/index.ts +51 -0
- package/src/modules/cpq/workflows/types.ts +102 -0
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState, useEffect, useCallback } from "react";
|
|
4
|
+
import { NumberInput } from "../../components/NumberInput.js";
|
|
5
|
+
function ConfigPanel({
|
|
6
|
+
offering,
|
|
7
|
+
configuration,
|
|
8
|
+
onChange,
|
|
9
|
+
onRemove
|
|
10
|
+
}) {
|
|
11
|
+
const [attributes, setAttributes] = useState([]);
|
|
12
|
+
const [loading, setLoading] = useState(true);
|
|
13
|
+
const [configVersion, setConfigVersion] = useState(0);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
let cancelled = false;
|
|
16
|
+
async function load() {
|
|
17
|
+
setLoading(true);
|
|
18
|
+
try {
|
|
19
|
+
const params = new URLSearchParams({ offeringId: offering.id });
|
|
20
|
+
if (Object.keys(configuration).length > 0) {
|
|
21
|
+
params.set("configuration", JSON.stringify(configuration));
|
|
22
|
+
}
|
|
23
|
+
const res = await fetch(`/api/cpq/quotes/attributes?${params}`);
|
|
24
|
+
if (res.ok && !cancelled) {
|
|
25
|
+
const data = await res.json();
|
|
26
|
+
const attrs = data.attributes ?? [];
|
|
27
|
+
setAttributes(attrs.filter((a) => !a.resolutionTime || a.resolutionTime === "run_time"));
|
|
28
|
+
}
|
|
29
|
+
} finally {
|
|
30
|
+
if (!cancelled) setLoading(false);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
load();
|
|
34
|
+
return () => {
|
|
35
|
+
cancelled = true;
|
|
36
|
+
};
|
|
37
|
+
}, [offering.id, configVersion]);
|
|
38
|
+
const handleChange = useCallback((code, value) => {
|
|
39
|
+
onChange(code, value);
|
|
40
|
+
const hasDependents = attributes.some((a) => {
|
|
41
|
+
const dep = a.constraints;
|
|
42
|
+
const depOn = dep?.dependsOn;
|
|
43
|
+
const dynSrc = dep?.dynamicOptionsSource;
|
|
44
|
+
return depOn?.attributeCode === code || dynSrc?.filterByDimension && Object.values(dynSrc.filterByDimension).some((v) => v === `$${code}`);
|
|
45
|
+
});
|
|
46
|
+
if (hasDependents) setConfigVersion((v) => v + 1);
|
|
47
|
+
}, [onChange, attributes]);
|
|
48
|
+
const renderAttribute = (attr) => {
|
|
49
|
+
const value = configuration[attr.code] ?? "";
|
|
50
|
+
if (attr.attributeType === "select" || attr.attributeType === "enum") {
|
|
51
|
+
return /* @__PURE__ */ jsxs("select", { value: String(value), onChange: (e) => handleChange(attr.code, e.target.value), className: "w-full rounded-md border px-3 py-2 text-sm", children: [
|
|
52
|
+
/* @__PURE__ */ jsx("option", { value: "", children: "Select..." }),
|
|
53
|
+
attr.options?.map((opt) => /* @__PURE__ */ jsx("option", { value: opt.value, children: opt.label }, opt.value))
|
|
54
|
+
] });
|
|
55
|
+
}
|
|
56
|
+
if (attr.attributeType === "boolean") {
|
|
57
|
+
return /* @__PURE__ */ jsxs("label", { className: "flex items-center gap-2 text-sm", children: [
|
|
58
|
+
/* @__PURE__ */ jsx("input", { type: "checkbox", checked: Boolean(value), onChange: (e) => handleChange(attr.code, e.target.checked), className: "rounded border" }),
|
|
59
|
+
attr.name
|
|
60
|
+
] });
|
|
61
|
+
}
|
|
62
|
+
if (attr.attributeType === "number") {
|
|
63
|
+
return /* @__PURE__ */ jsx(
|
|
64
|
+
NumberInput,
|
|
65
|
+
{
|
|
66
|
+
value: value === "" || value == null ? null : Number(value),
|
|
67
|
+
onChange: (n) => handleChange(attr.code, n ?? "")
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
return /* @__PURE__ */ jsx("input", { type: "text", value: String(value), onChange: (e) => handleChange(attr.code, e.target.value), className: "w-full rounded-md border px-3 py-2 text-sm" });
|
|
72
|
+
};
|
|
73
|
+
return /* @__PURE__ */ jsxs("div", { className: "rounded-lg border p-4 space-y-3", children: [
|
|
74
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between border-b pb-2", children: [
|
|
75
|
+
/* @__PURE__ */ jsx("h4", { className: "text-sm font-medium", children: offering.name }),
|
|
76
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: onRemove, className: "text-xs text-muted-foreground hover:text-foreground", children: "Remove" })
|
|
77
|
+
] }),
|
|
78
|
+
loading ? /* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground", children: "Loading attributes..." }) : attributes.length === 0 ? /* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground", children: "No configurable attributes." }) : /* @__PURE__ */ jsx("div", { className: "space-y-3", children: attributes.map((attr) => /* @__PURE__ */ jsxs("div", { children: [
|
|
79
|
+
/* @__PURE__ */ jsxs("label", { className: "block text-sm font-medium mb-1", children: [
|
|
80
|
+
attr.name,
|
|
81
|
+
attr.isRequired && /* @__PURE__ */ jsx("span", { className: "text-destructive ml-0.5", children: "*" })
|
|
82
|
+
] }),
|
|
83
|
+
renderAttribute(attr),
|
|
84
|
+
attr.helpText && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mt-1", children: attr.helpText })
|
|
85
|
+
] }, attr.code)) })
|
|
86
|
+
] });
|
|
87
|
+
}
|
|
88
|
+
function BandwidthIndicator({
|
|
89
|
+
portCapacityMb,
|
|
90
|
+
items
|
|
91
|
+
}) {
|
|
92
|
+
const totalBandwidth = items.reduce((sum, item) => {
|
|
93
|
+
const bw = Number(item.configuration.bandwidth_mb) || 0;
|
|
94
|
+
return sum + bw;
|
|
95
|
+
}, 0);
|
|
96
|
+
const pct = portCapacityMb > 0 ? Math.min(100, totalBandwidth / portCapacityMb * 100) : 0;
|
|
97
|
+
const overCapacity = totalBandwidth > portCapacityMb;
|
|
98
|
+
return /* @__PURE__ */ jsxs("div", { className: "rounded-lg border p-3 space-y-2", children: [
|
|
99
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between text-xs", children: [
|
|
100
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", children: "Bandwidth Utilization" }),
|
|
101
|
+
/* @__PURE__ */ jsxs("span", { className: overCapacity ? "text-destructive font-medium" : "text-muted-foreground", children: [
|
|
102
|
+
totalBandwidth,
|
|
103
|
+
" / ",
|
|
104
|
+
portCapacityMb,
|
|
105
|
+
" MB"
|
|
106
|
+
] })
|
|
107
|
+
] }),
|
|
108
|
+
/* @__PURE__ */ jsx("div", { className: "h-2 rounded-full bg-muted overflow-hidden", children: /* @__PURE__ */ jsx(
|
|
109
|
+
"div",
|
|
110
|
+
{
|
|
111
|
+
className: `h-full rounded-full transition-all ${overCapacity ? "bg-destructive" : "bg-primary"}`,
|
|
112
|
+
style: { width: `${Math.min(100, pct)}%` }
|
|
113
|
+
}
|
|
114
|
+
) }),
|
|
115
|
+
overCapacity && /* @__PURE__ */ jsxs("p", { className: "text-xs text-destructive", children: [
|
|
116
|
+
"Total bandwidth exceeds port capacity by ",
|
|
117
|
+
totalBandwidth - portCapacityMb,
|
|
118
|
+
" MB"
|
|
119
|
+
] })
|
|
120
|
+
] });
|
|
121
|
+
}
|
|
122
|
+
const PORT_SIZE_MB = { "1G": 1e3, "10G": 1e4, "100G": 1e5 };
|
|
123
|
+
function OfferingSelectStep({ config, onComplete, onBack, stepData, currentStepId, completedSteps, quoteId, customerId }) {
|
|
124
|
+
const [offerings, setOfferings] = useState([]);
|
|
125
|
+
const [selectedItems, setSelectedItems] = useState([]);
|
|
126
|
+
const [loading, setLoading] = useState(true);
|
|
127
|
+
const [saving, setSaving] = useState(false);
|
|
128
|
+
const enableConfiguration = config.enableConfiguration === true;
|
|
129
|
+
const multiSelect = config.multiSelect !== false;
|
|
130
|
+
const offeringFilter = config.offeringFilter;
|
|
131
|
+
const displayMode = config.displayMode ?? "grid";
|
|
132
|
+
const portCapacityMb = (() => {
|
|
133
|
+
for (const data of Object.values(stepData)) {
|
|
134
|
+
const cfg = data.configuration;
|
|
135
|
+
if (cfg?.port_size) return PORT_SIZE_MB[String(cfg.port_size)] ?? 0;
|
|
136
|
+
}
|
|
137
|
+
return 0;
|
|
138
|
+
})();
|
|
139
|
+
const previousData = stepData[currentStepId];
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
async function load() {
|
|
142
|
+
setLoading(true);
|
|
143
|
+
try {
|
|
144
|
+
const params = new URLSearchParams({ page: "1", pageSize: "100" });
|
|
145
|
+
const res = await fetch(`/api/cpq/product-offerings?${params}`);
|
|
146
|
+
if (res.ok) {
|
|
147
|
+
const data = await res.json();
|
|
148
|
+
let items = data.items ?? [];
|
|
149
|
+
if (offeringFilter?.offeringCodes?.length) {
|
|
150
|
+
const codeOrder = offeringFilter.offeringCodes;
|
|
151
|
+
items = items.filter((o) => codeOrder.includes(o.code)).sort((a, b) => codeOrder.indexOf(a.code) - codeOrder.indexOf(b.code));
|
|
152
|
+
}
|
|
153
|
+
items = items.filter((o) => o.isActive);
|
|
154
|
+
setOfferings(items);
|
|
155
|
+
if (previousData?.items?.length) {
|
|
156
|
+
const restored = previousData.items.map((prev) => {
|
|
157
|
+
const o = items.find((i) => i.id === prev.offering.id);
|
|
158
|
+
return o ? { offering: o, configuration: prev.configuration, lineId: prev.lineId } : null;
|
|
159
|
+
}).filter(Boolean);
|
|
160
|
+
setSelectedItems(restored);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
} finally {
|
|
164
|
+
setLoading(false);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
load();
|
|
168
|
+
}, []);
|
|
169
|
+
const addItem = useCallback((offering) => {
|
|
170
|
+
setSelectedItems((prev) => {
|
|
171
|
+
if (!multiSelect) return [{ offering, configuration: {} }];
|
|
172
|
+
return [...prev, { offering, configuration: {} }];
|
|
173
|
+
});
|
|
174
|
+
}, [multiSelect]);
|
|
175
|
+
const removeItem = useCallback((index) => {
|
|
176
|
+
setSelectedItems((prev) => prev.filter((_, i) => i !== index));
|
|
177
|
+
}, []);
|
|
178
|
+
const updateItemConfig = useCallback((index, code, value) => {
|
|
179
|
+
setSelectedItems((prev) => prev.map(
|
|
180
|
+
(item, i) => i === index ? { ...item, configuration: { ...item.configuration, [code]: value } } : item
|
|
181
|
+
));
|
|
182
|
+
}, []);
|
|
183
|
+
const resolvedCustomerId = customerId ?? (() => {
|
|
184
|
+
for (const data of Object.values(stepData)) {
|
|
185
|
+
if (data.customerId) return data.customerId;
|
|
186
|
+
}
|
|
187
|
+
return null;
|
|
188
|
+
})();
|
|
189
|
+
const handleNext = useCallback(async () => {
|
|
190
|
+
if (selectedItems.length === 0) return;
|
|
191
|
+
setSaving(true);
|
|
192
|
+
try {
|
|
193
|
+
let activeQuoteId = quoteId;
|
|
194
|
+
const output = { items: selectedItems };
|
|
195
|
+
if (enableConfiguration) {
|
|
196
|
+
if (!activeQuoteId && resolvedCustomerId) {
|
|
197
|
+
const createRes = await fetch("/api/cpq/quotes", {
|
|
198
|
+
method: "POST",
|
|
199
|
+
headers: { "Content-Type": "application/json" },
|
|
200
|
+
body: JSON.stringify({ customerId: resolvedCustomerId })
|
|
201
|
+
});
|
|
202
|
+
if (createRes.ok) {
|
|
203
|
+
const quoteData = await createRes.json();
|
|
204
|
+
activeQuoteId = quoteData.id;
|
|
205
|
+
output.quoteId = activeQuoteId;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (activeQuoteId) {
|
|
209
|
+
for (const item of selectedItems) {
|
|
210
|
+
if (item.lineId) {
|
|
211
|
+
await fetch(`/api/cpq/quotes/${activeQuoteId}/items/${item.lineId}`, {
|
|
212
|
+
method: "PUT",
|
|
213
|
+
headers: { "Content-Type": "application/json" },
|
|
214
|
+
body: JSON.stringify({ configuration: item.configuration })
|
|
215
|
+
});
|
|
216
|
+
} else {
|
|
217
|
+
const res = await fetch(`/api/cpq/quotes/${activeQuoteId}/items`, {
|
|
218
|
+
method: "POST",
|
|
219
|
+
headers: { "Content-Type": "application/json" },
|
|
220
|
+
body: JSON.stringify({ offeringId: item.offering.id, configuration: item.configuration })
|
|
221
|
+
});
|
|
222
|
+
if (res.ok) {
|
|
223
|
+
const data = await res.json();
|
|
224
|
+
const line = data.lines?.find((l) => l.offeringId === item.offering.id);
|
|
225
|
+
item.lineId = line?.lineId;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
output.quoteId = activeQuoteId;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (selectedItems.length === 1) {
|
|
233
|
+
const first = selectedItems[0];
|
|
234
|
+
output.offeringId = first.offering.id;
|
|
235
|
+
output.offeringCode = first.offering.code;
|
|
236
|
+
output.offeringName = first.offering.name;
|
|
237
|
+
output.specId = first.offering.specId;
|
|
238
|
+
if (enableConfiguration) output.configuration = first.configuration;
|
|
239
|
+
}
|
|
240
|
+
onComplete(output);
|
|
241
|
+
} finally {
|
|
242
|
+
setSaving(false);
|
|
243
|
+
}
|
|
244
|
+
}, [selectedItems, enableConfiguration, quoteId, resolvedCustomerId, onComplete]);
|
|
245
|
+
if (loading) {
|
|
246
|
+
return /* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground", children: "Loading offerings..." });
|
|
247
|
+
}
|
|
248
|
+
const availableOfferings = offerings.filter(
|
|
249
|
+
(o) => multiSelect ? true : !selectedItems.some((s) => s.offering.id === o.id)
|
|
250
|
+
);
|
|
251
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
252
|
+
/* @__PURE__ */ jsxs(
|
|
253
|
+
"div",
|
|
254
|
+
{
|
|
255
|
+
className: displayMode === "grid" ? "grid grid-cols-[repeat(auto-fill,minmax(240px,1fr))] gap-3" : "flex flex-col gap-2",
|
|
256
|
+
children: [
|
|
257
|
+
availableOfferings.map((o) => {
|
|
258
|
+
const isAdded = selectedItems.some((s) => s.offering.id === o.id);
|
|
259
|
+
return /* @__PURE__ */ jsxs(
|
|
260
|
+
"div",
|
|
261
|
+
{
|
|
262
|
+
onClick: () => !isAdded && addItem(o),
|
|
263
|
+
className: `rounded-lg border-2 p-4 transition-colors ${isAdded ? "border-primary/30 bg-primary/5 opacity-60 cursor-default" : "border-muted cursor-pointer hover:bg-muted/30"}`,
|
|
264
|
+
children: [
|
|
265
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
266
|
+
/* @__PURE__ */ jsx("h4", { className: "text-sm font-medium", children: o.name }),
|
|
267
|
+
isAdded && /* @__PURE__ */ jsx("span", { className: "text-xs text-primary font-medium", children: "Added" })
|
|
268
|
+
] }),
|
|
269
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mt-1", children: o.description || o.code }),
|
|
270
|
+
!isAdded && /* @__PURE__ */ jsx("span", { className: "text-xs text-primary mt-2 inline-block", children: "+ Add" })
|
|
271
|
+
]
|
|
272
|
+
},
|
|
273
|
+
o.id
|
|
274
|
+
);
|
|
275
|
+
}),
|
|
276
|
+
offerings.length === 0 && /* @__PURE__ */ jsx("div", { className: "rounded-lg border bg-card p-6 text-center text-sm text-muted-foreground", children: "No offerings available." })
|
|
277
|
+
]
|
|
278
|
+
}
|
|
279
|
+
),
|
|
280
|
+
portCapacityMb > 0 && selectedItems.length > 0 && /* @__PURE__ */ jsx(BandwidthIndicator, { portCapacityMb, items: selectedItems }),
|
|
281
|
+
enableConfiguration && selectedItems.length > 0 && /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
282
|
+
/* @__PURE__ */ jsxs("h4", { className: "text-sm font-medium", children: [
|
|
283
|
+
"Selected Services (",
|
|
284
|
+
selectedItems.length,
|
|
285
|
+
")"
|
|
286
|
+
] }),
|
|
287
|
+
selectedItems.map((item, index) => /* @__PURE__ */ jsx(
|
|
288
|
+
ConfigPanel,
|
|
289
|
+
{
|
|
290
|
+
offering: item.offering,
|
|
291
|
+
configuration: item.configuration,
|
|
292
|
+
onChange: (code, value) => updateItemConfig(index, code, value),
|
|
293
|
+
onRemove: () => removeItem(index)
|
|
294
|
+
},
|
|
295
|
+
`${item.offering.id}-${index}`
|
|
296
|
+
))
|
|
297
|
+
] }),
|
|
298
|
+
!enableConfiguration && selectedItems.length > 0 && /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
299
|
+
/* @__PURE__ */ jsxs("h4", { className: "text-sm font-medium", children: [
|
|
300
|
+
"Selected (",
|
|
301
|
+
selectedItems.length,
|
|
302
|
+
")"
|
|
303
|
+
] }),
|
|
304
|
+
selectedItems.map((item, index) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded-md border p-3", children: [
|
|
305
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: item.offering.name }),
|
|
306
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: () => removeItem(index), className: "text-xs text-muted-foreground hover:text-foreground", children: "Remove" })
|
|
307
|
+
] }, `${item.offering.id}-${index}`))
|
|
308
|
+
] }),
|
|
309
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-2 justify-end pt-2", children: [
|
|
310
|
+
completedSteps.length > 0 && /* @__PURE__ */ jsx("button", { type: "button", onClick: onBack, className: "inline-flex items-center justify-center rounded-md border px-4 py-2 text-sm font-medium hover:bg-muted", children: "Back" }),
|
|
311
|
+
/* @__PURE__ */ jsx(
|
|
312
|
+
"button",
|
|
313
|
+
{
|
|
314
|
+
type: "button",
|
|
315
|
+
onClick: handleNext,
|
|
316
|
+
disabled: selectedItems.length === 0 || saving,
|
|
317
|
+
className: "inline-flex items-center justify-center rounded-md bg-primary px-5 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed",
|
|
318
|
+
children: saving ? "Saving..." : "Next"
|
|
319
|
+
}
|
|
320
|
+
)
|
|
321
|
+
] })
|
|
322
|
+
] });
|
|
323
|
+
}
|
|
324
|
+
export {
|
|
325
|
+
OfferingSelectStep
|
|
326
|
+
};
|
|
327
|
+
//# sourceMappingURL=OfferingSelectStep.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/modules/cpq/workflows/steps/OfferingSelectStep.tsx"],
|
|
4
|
+
"sourcesContent": ["'use client'\n\nimport React, { useState, useEffect, useCallback } from 'react'\nimport type { WizardStepProps } from '../types'\nimport { NumberInput } from '../../components/NumberInput'\n\ntype Offering = {\n id: string\n code: string\n name: string\n description: string | null\n specId: string\n isActive: boolean\n}\n\ntype ConstrainedAttribute = {\n code: string\n name: string\n attributeType: string\n isRequired: boolean\n options: Array<{ value: string; label: string }> | null\n constraints: Record<string, unknown> | null\n defaultValue: unknown | null\n helpText: string | null\n}\n\ntype SelectedItem = {\n offering: Offering\n configuration: Record<string, unknown>\n lineId?: string\n}\n\n// \u2500\u2500\u2500 Inline configuration panel for a single offering \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction ConfigPanel({\n offering,\n configuration,\n onChange,\n onRemove,\n}: {\n offering: Offering\n configuration: Record<string, unknown>\n onChange: (code: string, value: unknown) => void\n onRemove: () => void\n}) {\n const [attributes, setAttributes] = useState<ConstrainedAttribute[]>([])\n const [loading, setLoading] = useState(true)\n const [configVersion, setConfigVersion] = useState(0)\n\n useEffect(() => {\n let cancelled = false\n async function load() {\n setLoading(true)\n try {\n const params = new URLSearchParams({ offeringId: offering.id })\n if (Object.keys(configuration).length > 0) {\n params.set('configuration', JSON.stringify(configuration))\n }\n const res = await fetch(`/api/cpq/quotes/attributes?${params}`)\n if (res.ok && !cancelled) {\n const data = await res.json()\n const attrs = (data.attributes ?? []) as ConstrainedAttribute[]\n setAttributes(attrs.filter((a: ConstrainedAttribute & { resolutionTime?: string }) => !a.resolutionTime || a.resolutionTime === 'run_time'))\n }\n } finally {\n if (!cancelled) setLoading(false)\n }\n }\n load()\n return () => { cancelled = true }\n }, [offering.id, configVersion]) // eslint-disable-line react-hooks/exhaustive-deps\n\n const handleChange = useCallback((code: string, value: unknown) => {\n onChange(code, value)\n // Check for dependent attributes\n const hasDependents = attributes.some((a) => {\n const dep = a.constraints as Record<string, unknown> | null\n const depOn = dep?.dependsOn as { attributeCode?: string } | undefined\n const dynSrc = dep?.dynamicOptionsSource as { filterByDimension?: Record<string, string> } | undefined\n return depOn?.attributeCode === code ||\n (dynSrc?.filterByDimension && Object.values(dynSrc.filterByDimension).some((v) => v === `$${code}`))\n })\n if (hasDependents) setConfigVersion((v) => v + 1)\n }, [onChange, attributes])\n\n const renderAttribute = (attr: ConstrainedAttribute) => {\n const value = configuration[attr.code] ?? ''\n\n if (attr.attributeType === 'select' || attr.attributeType === 'enum') {\n return (\n <select value={String(value)} onChange={(e) => handleChange(attr.code, e.target.value)} className=\"w-full rounded-md border px-3 py-2 text-sm\">\n <option value=\"\">Select...</option>\n {attr.options?.map((opt) => <option key={opt.value} value={opt.value}>{opt.label}</option>)}\n </select>\n )\n }\n if (attr.attributeType === 'boolean') {\n return (\n <label className=\"flex items-center gap-2 text-sm\">\n <input type=\"checkbox\" checked={Boolean(value)} onChange={(e) => handleChange(attr.code, e.target.checked)} className=\"rounded border\" />\n {attr.name}\n </label>\n )\n }\n if (attr.attributeType === 'number') {\n return (\n <NumberInput\n value={value === '' || value == null ? null : Number(value)}\n onChange={(n) => handleChange(attr.code, n ?? '')}\n />\n )\n }\n return <input type=\"text\" value={String(value)} onChange={(e) => handleChange(attr.code, e.target.value)} className=\"w-full rounded-md border px-3 py-2 text-sm\" />\n }\n\n return (\n <div className=\"rounded-lg border p-4 space-y-3\">\n <div className=\"flex items-center justify-between border-b pb-2\">\n <h4 className=\"text-sm font-medium\">{offering.name}</h4>\n <button type=\"button\" onClick={onRemove} className=\"text-xs text-muted-foreground hover:text-foreground\">Remove</button>\n </div>\n {loading ? (\n <div className=\"text-sm text-muted-foreground\">Loading attributes...</div>\n ) : attributes.length === 0 ? (\n <div className=\"text-sm text-muted-foreground\">No configurable attributes.</div>\n ) : (\n <div className=\"space-y-3\">\n {attributes.map((attr) => (\n <div key={attr.code}>\n <label className=\"block text-sm font-medium mb-1\">\n {attr.name}\n {attr.isRequired && <span className=\"text-destructive ml-0.5\">*</span>}\n </label>\n {renderAttribute(attr)}\n {attr.helpText && <p className=\"text-xs text-muted-foreground mt-1\">{attr.helpText}</p>}\n </div>\n ))}\n </div>\n )}\n </div>\n )\n}\n\n// \u2500\u2500\u2500 Port capacity indicator \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nfunction BandwidthIndicator({\n portCapacityMb,\n items,\n}: {\n portCapacityMb: number\n items: SelectedItem[]\n}) {\n const totalBandwidth = items.reduce((sum, item) => {\n const bw = Number(item.configuration.bandwidth_mb) || 0\n return sum + bw\n }, 0)\n\n const pct = portCapacityMb > 0 ? Math.min(100, (totalBandwidth / portCapacityMb) * 100) : 0\n const overCapacity = totalBandwidth > portCapacityMb\n\n return (\n <div className=\"rounded-lg border p-3 space-y-2\">\n <div className=\"flex items-center justify-between text-xs\">\n <span className=\"font-medium\">Bandwidth Utilization</span>\n <span className={overCapacity ? 'text-destructive font-medium' : 'text-muted-foreground'}>\n {totalBandwidth} / {portCapacityMb} MB\n </span>\n </div>\n <div className=\"h-2 rounded-full bg-muted overflow-hidden\">\n <div\n className={`h-full rounded-full transition-all ${overCapacity ? 'bg-destructive' : 'bg-primary'}`}\n style={{ width: `${Math.min(100, pct)}%` }}\n />\n </div>\n {overCapacity && (\n <p className=\"text-xs text-destructive\">\n Total bandwidth exceeds port capacity by {totalBandwidth - portCapacityMb} MB\n </p>\n )}\n </div>\n )\n}\n\n// \u2500\u2500\u2500 Main component \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\nconst PORT_SIZE_MB: Record<string, number> = { '1G': 1000, '10G': 10000, '100G': 100000 }\n\nexport function OfferingSelectStep({ config, onComplete, onBack, stepData, currentStepId, completedSteps, quoteId, customerId }: WizardStepProps) {\n const [offerings, setOfferings] = useState<Offering[]>([])\n const [selectedItems, setSelectedItems] = useState<SelectedItem[]>([])\n const [loading, setLoading] = useState(true)\n const [saving, setSaving] = useState(false)\n\n const enableConfiguration = config.enableConfiguration === true\n const multiSelect = config.multiSelect !== false // default true for offering_select\n const offeringFilter = config.offeringFilter as { specCodes?: string[]; offeringCodes?: string[] } | undefined\n const displayMode = (config.displayMode as string) ?? 'grid'\n\n // Resolve port capacity from prior step data\n const portCapacityMb = (() => {\n for (const data of Object.values(stepData)) {\n const cfg = data.configuration as Record<string, unknown> | undefined\n if (cfg?.port_size) return PORT_SIZE_MB[String(cfg.port_size)] ?? 0\n }\n return 0\n })()\n\n // Restore previous selections\n const previousData = stepData[currentStepId] as { items?: SelectedItem[] } | undefined\n\n useEffect(() => {\n async function load() {\n setLoading(true)\n try {\n const params = new URLSearchParams({ page: '1', pageSize: '100' })\n const res = await fetch(`/api/cpq/product-offerings?${params}`)\n if (res.ok) {\n const data = await res.json()\n let items = (data.items ?? []) as Offering[]\n if (offeringFilter?.offeringCodes?.length) {\n const codeOrder = offeringFilter.offeringCodes!\n items = items\n .filter((o) => codeOrder.includes(o.code))\n .sort((a, b) => codeOrder.indexOf(a.code) - codeOrder.indexOf(b.code))\n }\n items = items.filter((o) => o.isActive)\n setOfferings(items)\n\n // Restore previous selections\n if (previousData?.items?.length) {\n const restored = previousData.items\n .map((prev) => {\n const o = items.find((i) => i.id === prev.offering.id)\n return o ? { offering: o, configuration: prev.configuration, lineId: prev.lineId } : null\n })\n .filter(Boolean) as SelectedItem[]\n setSelectedItems(restored)\n }\n }\n } finally {\n setLoading(false)\n }\n }\n load()\n }, []) // eslint-disable-line react-hooks/exhaustive-deps\n\n const addItem = useCallback((offering: Offering) => {\n setSelectedItems((prev) => {\n if (!multiSelect) return [{ offering, configuration: {} }]\n return [...prev, { offering, configuration: {} }]\n })\n }, [multiSelect])\n\n const removeItem = useCallback((index: number) => {\n setSelectedItems((prev) => prev.filter((_, i) => i !== index))\n }, [])\n\n const updateItemConfig = useCallback((index: number, code: string, value: unknown) => {\n setSelectedItems((prev) => prev.map((item, i) =>\n i === index ? { ...item, configuration: { ...item.configuration, [code]: value } } : item\n ))\n }, [])\n\n // Resolve customerId from props or stepData\n const resolvedCustomerId = customerId ?? (() => {\n for (const data of Object.values(stepData)) {\n if (data.customerId) return data.customerId as string\n }\n return null\n })()\n\n const handleNext = useCallback(async () => {\n if (selectedItems.length === 0) return\n setSaving(true)\n try {\n let activeQuoteId = quoteId\n const output: Record<string, unknown> = { items: selectedItems }\n\n if (enableConfiguration) {\n // Auto-create quote if needed\n if (!activeQuoteId && resolvedCustomerId) {\n const createRes = await fetch('/api/cpq/quotes', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ customerId: resolvedCustomerId }),\n })\n if (createRes.ok) {\n const quoteData = await createRes.json()\n activeQuoteId = quoteData.id\n output.quoteId = activeQuoteId\n }\n }\n\n // Add or update each selected item on the quote\n if (activeQuoteId) {\n for (const item of selectedItems) {\n if (item.lineId) {\n // Update existing line\n await fetch(`/api/cpq/quotes/${activeQuoteId}/items/${item.lineId}`, {\n method: 'PUT',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ configuration: item.configuration }),\n })\n } else {\n // Create new line\n const res = await fetch(`/api/cpq/quotes/${activeQuoteId}/items`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ offeringId: item.offering.id, configuration: item.configuration }),\n })\n if (res.ok) {\n const data = await res.json()\n const line = data.lines?.find((l: { offeringId: string }) => l.offeringId === item.offering.id)\n item.lineId = line?.lineId\n }\n }\n }\n output.quoteId = activeQuoteId\n }\n }\n\n // Also set single-item compat fields\n if (selectedItems.length === 1) {\n const first = selectedItems[0]\n output.offeringId = first.offering.id\n output.offeringCode = first.offering.code\n output.offeringName = first.offering.name\n output.specId = first.offering.specId\n if (enableConfiguration) output.configuration = first.configuration\n }\n\n onComplete(output)\n } finally {\n setSaving(false)\n }\n }, [selectedItems, enableConfiguration, quoteId, resolvedCustomerId, onComplete])\n\n if (loading) {\n return <div className=\"text-sm text-muted-foreground\">Loading offerings...</div>\n }\n\n // Offerings not yet added\n const availableOfferings = offerings.filter((o) =>\n multiSelect ? true : !selectedItems.some((s) => s.offering.id === o.id)\n )\n\n return (\n <div className=\"space-y-4\">\n {/* Offering cards */}\n <div\n className={\n displayMode === 'grid'\n ? 'grid grid-cols-[repeat(auto-fill,minmax(240px,1fr))] gap-3'\n : 'flex flex-col gap-2'\n }\n >\n {availableOfferings.map((o) => {\n const isAdded = selectedItems.some((s) => s.offering.id === o.id)\n return (\n <div\n key={o.id}\n onClick={() => !isAdded && addItem(o)}\n className={`rounded-lg border-2 p-4 transition-colors ${\n isAdded\n ? 'border-primary/30 bg-primary/5 opacity-60 cursor-default'\n : 'border-muted cursor-pointer hover:bg-muted/30'\n }`}\n >\n <div className=\"flex items-center justify-between\">\n <h4 className=\"text-sm font-medium\">{o.name}</h4>\n {isAdded && <span className=\"text-xs text-primary font-medium\">Added</span>}\n </div>\n <p className=\"text-xs text-muted-foreground mt-1\">{o.description || o.code}</p>\n {!isAdded && (\n <span className=\"text-xs text-primary mt-2 inline-block\">+ Add</span>\n )}\n </div>\n )\n })}\n {offerings.length === 0 && (\n <div className=\"rounded-lg border bg-card p-6 text-center text-sm text-muted-foreground\">\n No offerings available.\n </div>\n )}\n </div>\n\n {/* Bandwidth indicator */}\n {portCapacityMb > 0 && selectedItems.length > 0 && (\n <BandwidthIndicator portCapacityMb={portCapacityMb} items={selectedItems} />\n )}\n\n {/* Configuration panels for selected items */}\n {enableConfiguration && selectedItems.length > 0 && (\n <div className=\"space-y-3\">\n <h4 className=\"text-sm font-medium\">Selected Services ({selectedItems.length})</h4>\n {selectedItems.map((item, index) => (\n <ConfigPanel\n key={`${item.offering.id}-${index}`}\n offering={item.offering}\n configuration={item.configuration}\n onChange={(code, value) => updateItemConfig(index, code, value)}\n onRemove={() => removeItem(index)}\n />\n ))}\n </div>\n )}\n\n {/* No configuration \u2014 just show selected list */}\n {!enableConfiguration && selectedItems.length > 0 && (\n <div className=\"space-y-2\">\n <h4 className=\"text-sm font-medium\">Selected ({selectedItems.length})</h4>\n {selectedItems.map((item, index) => (\n <div key={`${item.offering.id}-${index}`} className=\"flex items-center justify-between rounded-md border p-3\">\n <span className=\"text-sm font-medium\">{item.offering.name}</span>\n <button type=\"button\" onClick={() => removeItem(index)} className=\"text-xs text-muted-foreground hover:text-foreground\">Remove</button>\n </div>\n ))}\n </div>\n )}\n\n <div className=\"flex gap-2 justify-end pt-2\">\n {completedSteps.length > 0 && (\n <button type=\"button\" onClick={onBack} className=\"inline-flex items-center justify-center rounded-md border px-4 py-2 text-sm font-medium hover:bg-muted\">\n Back\n </button>\n )}\n <button\n type=\"button\"\n onClick={handleNext}\n disabled={selectedItems.length === 0 || saving}\n className=\"inline-flex items-center justify-center rounded-md bg-primary px-5 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed\"\n >\n {saving ? 'Saving...' : 'Next'}\n </button>\n </div>\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AA0FQ,SACE,KADF;AAxFR,SAAgB,UAAU,WAAW,mBAAmB;AAExD,SAAS,mBAAmB;AA8B5B,SAAS,YAAY;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAKG;AACD,QAAM,CAAC,YAAY,aAAa,IAAI,SAAiC,CAAC,CAAC;AACvE,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,IAAI;AAC3C,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAS,CAAC;AAEpD,YAAU,MAAM;AACd,QAAI,YAAY;AAChB,mBAAe,OAAO;AACpB,iBAAW,IAAI;AACf,UAAI;AACF,cAAM,SAAS,IAAI,gBAAgB,EAAE,YAAY,SAAS,GAAG,CAAC;AAC9D,YAAI,OAAO,KAAK,aAAa,EAAE,SAAS,GAAG;AACzC,iBAAO,IAAI,iBAAiB,KAAK,UAAU,aAAa,CAAC;AAAA,QAC3D;AACA,cAAM,MAAM,MAAM,MAAM,8BAA8B,MA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"react/jsx-runtime";
|
|
3
|
+
import { useState, useEffect, useCallback } from "react";
|
|
4
|
+
import { NumberInput } from "../../components/NumberInput.js";
|
|
5
|
+
function resolveOfferingId(config, stepData) {
|
|
6
|
+
const source = config.offeringSource;
|
|
7
|
+
if (source && stepData[source]) {
|
|
8
|
+
return stepData[source].offeringId ?? null;
|
|
9
|
+
}
|
|
10
|
+
for (const data of Object.values(stepData)) {
|
|
11
|
+
if (data.offeringId) return data.offeringId;
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
function ProductConfigureStep({ config, onComplete, onBack, stepData, currentStepId, completedSteps, quoteId, customerId }) {
|
|
16
|
+
const [attributes, setAttributes] = useState([]);
|
|
17
|
+
const [values, setValues] = useState({});
|
|
18
|
+
const [loading, setLoading] = useState(true);
|
|
19
|
+
const [saving, setSaving] = useState(false);
|
|
20
|
+
const [resolvedOfferingId, setResolvedOfferingId] = useState(null);
|
|
21
|
+
const directOfferingId = resolveOfferingId(config, stepData);
|
|
22
|
+
const offeringCode = config.offeringCode;
|
|
23
|
+
const attributeGroups = config.attributeGroups;
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (directOfferingId) {
|
|
26
|
+
setResolvedOfferingId(directOfferingId);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (!offeringCode) return;
|
|
30
|
+
async function resolve() {
|
|
31
|
+
try {
|
|
32
|
+
const res = await fetch(`/api/cpq/product-offerings?code=${encodeURIComponent(offeringCode)}`);
|
|
33
|
+
if (res.ok) {
|
|
34
|
+
const data = await res.json();
|
|
35
|
+
const items = data.items ?? data;
|
|
36
|
+
if (Array.isArray(items) && items.length > 0) {
|
|
37
|
+
setResolvedOfferingId(items[0].id);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
} catch {
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
resolve();
|
|
44
|
+
}, [directOfferingId, offeringCode]);
|
|
45
|
+
const offeringId = resolvedOfferingId;
|
|
46
|
+
const hiddenAttributes = config.hiddenAttributes ?? [];
|
|
47
|
+
const readonlyAttributes = config.readonlyAttributes ?? [];
|
|
48
|
+
const previousData = stepData[currentStepId];
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
async function loadAttributes() {
|
|
51
|
+
if (!offeringId) {
|
|
52
|
+
setLoading(false);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
setLoading(true);
|
|
56
|
+
try {
|
|
57
|
+
const params = new URLSearchParams({ offeringId });
|
|
58
|
+
if (Object.keys(values).length > 0) {
|
|
59
|
+
params.set("configuration", JSON.stringify(values));
|
|
60
|
+
}
|
|
61
|
+
const res = await fetch(`/api/cpq/quotes/attributes?${params}`);
|
|
62
|
+
if (res.ok) {
|
|
63
|
+
const data = await res.json();
|
|
64
|
+
const attrs = data.attributes ?? [];
|
|
65
|
+
setAttributes(attrs.filter((a) => !hiddenAttributes.includes(a.code)));
|
|
66
|
+
if (Object.keys(values).length === 0) {
|
|
67
|
+
const defaults = previousData?.configuration ?? {};
|
|
68
|
+
for (const attr of attrs) {
|
|
69
|
+
if (defaults[attr.code] === void 0 && attr.defaultValue != null) {
|
|
70
|
+
defaults[attr.code] = attr.defaultValue;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
setValues(defaults);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
} finally {
|
|
77
|
+
setLoading(false);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
loadAttributes();
|
|
81
|
+
}, [offeringId]);
|
|
82
|
+
const handleChange = useCallback((code, value) => {
|
|
83
|
+
setValues((prev) => ({ ...prev, [code]: value }));
|
|
84
|
+
}, []);
|
|
85
|
+
const resolvedCustomerId = customerId ?? (() => {
|
|
86
|
+
for (const data of Object.values(stepData)) {
|
|
87
|
+
if (data.customerId) return data.customerId;
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
90
|
+
})();
|
|
91
|
+
const handleComplete = useCallback(async () => {
|
|
92
|
+
setSaving(true);
|
|
93
|
+
try {
|
|
94
|
+
let activeQuoteId = quoteId;
|
|
95
|
+
if (!activeQuoteId && resolvedCustomerId && offeringId) {
|
|
96
|
+
const createRes = await fetch("/api/cpq/quotes", {
|
|
97
|
+
method: "POST",
|
|
98
|
+
headers: { "Content-Type": "application/json" },
|
|
99
|
+
body: JSON.stringify({ customerId: resolvedCustomerId })
|
|
100
|
+
});
|
|
101
|
+
if (createRes.ok) {
|
|
102
|
+
const quoteData = await createRes.json();
|
|
103
|
+
activeQuoteId = quoteData.id;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (activeQuoteId && offeringId) {
|
|
107
|
+
const existingLineId = stepData[currentStepId]?.lineId;
|
|
108
|
+
if (existingLineId) {
|
|
109
|
+
await fetch(`/api/cpq/quotes/${activeQuoteId}/items/${existingLineId}`, {
|
|
110
|
+
method: "PUT",
|
|
111
|
+
headers: { "Content-Type": "application/json" },
|
|
112
|
+
body: JSON.stringify({ configuration: values })
|
|
113
|
+
});
|
|
114
|
+
onComplete({ configuration: values, offeringId, lineId: existingLineId, quoteId: activeQuoteId });
|
|
115
|
+
} else {
|
|
116
|
+
const res = await fetch(`/api/cpq/quotes/${activeQuoteId}/items`, {
|
|
117
|
+
method: "POST",
|
|
118
|
+
headers: { "Content-Type": "application/json" },
|
|
119
|
+
body: JSON.stringify({ offeringId, configuration: values })
|
|
120
|
+
});
|
|
121
|
+
if (res.ok) {
|
|
122
|
+
const data = await res.json();
|
|
123
|
+
const line = data.lines?.find((l) => l.offeringId === offeringId);
|
|
124
|
+
onComplete({ configuration: values, offeringId, lineId: line?.lineId, quoteId: activeQuoteId });
|
|
125
|
+
} else {
|
|
126
|
+
onComplete({ configuration: values, offeringId, quoteId: activeQuoteId });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
onComplete({ configuration: values, offeringId });
|
|
131
|
+
}
|
|
132
|
+
} finally {
|
|
133
|
+
setSaving(false);
|
|
134
|
+
}
|
|
135
|
+
}, [values, quoteId, offeringId, stepData, currentStepId, onComplete, resolvedCustomerId]);
|
|
136
|
+
const renderAttribute = (attr) => {
|
|
137
|
+
const isReadonly = readonlyAttributes.includes(attr.code);
|
|
138
|
+
const value = values[attr.code] ?? "";
|
|
139
|
+
if (attr.attributeType === "select" || attr.attributeType === "enum") {
|
|
140
|
+
return /* @__PURE__ */ jsxs(
|
|
141
|
+
"select",
|
|
142
|
+
{
|
|
143
|
+
value: String(value),
|
|
144
|
+
onChange: (e) => handleChange(attr.code, e.target.value),
|
|
145
|
+
disabled: isReadonly,
|
|
146
|
+
className: "w-full rounded-md border px-3 py-2 text-sm disabled:opacity-50",
|
|
147
|
+
children: [
|
|
148
|
+
/* @__PURE__ */ jsx("option", { value: "", children: "Select..." }),
|
|
149
|
+
attr.options?.map((opt) => /* @__PURE__ */ jsx("option", { value: opt.value, children: opt.label }, opt.value))
|
|
150
|
+
]
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
if (attr.attributeType === "boolean") {
|
|
155
|
+
return /* @__PURE__ */ jsxs("label", { className: "flex items-center gap-2 text-sm", children: [
|
|
156
|
+
/* @__PURE__ */ jsx(
|
|
157
|
+
"input",
|
|
158
|
+
{
|
|
159
|
+
type: "checkbox",
|
|
160
|
+
checked: Boolean(value),
|
|
161
|
+
onChange: (e) => handleChange(attr.code, e.target.checked),
|
|
162
|
+
disabled: isReadonly,
|
|
163
|
+
className: "rounded border"
|
|
164
|
+
}
|
|
165
|
+
),
|
|
166
|
+
attr.name
|
|
167
|
+
] });
|
|
168
|
+
}
|
|
169
|
+
if (attr.attributeType === "number") {
|
|
170
|
+
return /* @__PURE__ */ jsx(
|
|
171
|
+
NumberInput,
|
|
172
|
+
{
|
|
173
|
+
value: value === "" || value == null ? null : Number(value),
|
|
174
|
+
onChange: (n) => handleChange(attr.code, n ?? ""),
|
|
175
|
+
disabled: isReadonly
|
|
176
|
+
}
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
return /* @__PURE__ */ jsx(
|
|
180
|
+
"input",
|
|
181
|
+
{
|
|
182
|
+
type: "text",
|
|
183
|
+
value: String(value),
|
|
184
|
+
onChange: (e) => handleChange(attr.code, e.target.value),
|
|
185
|
+
disabled: isReadonly,
|
|
186
|
+
className: "w-full rounded-md border px-3 py-2 text-sm disabled:opacity-50"
|
|
187
|
+
}
|
|
188
|
+
);
|
|
189
|
+
};
|
|
190
|
+
if (loading) {
|
|
191
|
+
return /* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground", children: "Loading attributes..." });
|
|
192
|
+
}
|
|
193
|
+
if (!offeringId) {
|
|
194
|
+
return /* @__PURE__ */ jsx("div", { className: "rounded-lg border bg-card p-6 text-center text-sm text-muted-foreground", children: "No offering selected. Please go back and select an offering." });
|
|
195
|
+
}
|
|
196
|
+
const renderGroup = (label, attrs) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
197
|
+
/* @__PURE__ */ jsx("h4", { className: "text-sm font-medium border-b pb-2", children: label }),
|
|
198
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-3", children: attrs.map((attr) => /* @__PURE__ */ jsxs("div", { children: [
|
|
199
|
+
/* @__PURE__ */ jsxs("label", { className: "block text-sm font-medium mb-1", children: [
|
|
200
|
+
attr.name,
|
|
201
|
+
attr.isRequired && /* @__PURE__ */ jsx("span", { className: "text-destructive ml-0.5", children: "*" })
|
|
202
|
+
] }),
|
|
203
|
+
renderAttribute(attr),
|
|
204
|
+
attr.helpText && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mt-1", children: attr.helpText })
|
|
205
|
+
] }, attr.code)) })
|
|
206
|
+
] }, label);
|
|
207
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
208
|
+
attributeGroups?.length ? attributeGroups.map((group) => {
|
|
209
|
+
const groupAttrs = attributes.filter((a) => group.attributeCodes.includes(a.code));
|
|
210
|
+
if (groupAttrs.length === 0) return null;
|
|
211
|
+
return renderGroup(group.label, groupAttrs);
|
|
212
|
+
}) : renderGroup("Configuration", attributes),
|
|
213
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-2 justify-end pt-2", children: [
|
|
214
|
+
completedSteps.length > 0 && /* @__PURE__ */ jsx("button", { type: "button", onClick: onBack, className: "inline-flex items-center justify-center rounded-md border px-4 py-2 text-sm font-medium hover:bg-muted", children: "Back" }),
|
|
215
|
+
/* @__PURE__ */ jsx(
|
|
216
|
+
"button",
|
|
217
|
+
{
|
|
218
|
+
type: "button",
|
|
219
|
+
onClick: handleComplete,
|
|
220
|
+
disabled: saving,
|
|
221
|
+
className: "inline-flex items-center justify-center rounded-md bg-primary px-5 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50",
|
|
222
|
+
children: saving ? "Saving..." : "Next"
|
|
223
|
+
}
|
|
224
|
+
)
|
|
225
|
+
] })
|
|
226
|
+
] });
|
|
227
|
+
}
|
|
228
|
+
export {
|
|
229
|
+
ProductConfigureStep
|
|
230
|
+
};
|
|
231
|
+
//# sourceMappingURL=ProductConfigureStep.js.map
|