@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,265 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
import * as React from 'react'
|
|
3
|
+
import type { InjectionWidgetComponentProps } from '@open-mercato/shared/modules/widgets/injection'
|
|
4
|
+
import { useRouter } from 'next/navigation'
|
|
5
|
+
import { Tag } from '@open-mercato/ui/primitives/tag'
|
|
6
|
+
import {
|
|
7
|
+
formatStatusLabel,
|
|
8
|
+
quoteCpqStatusMap,
|
|
9
|
+
type QuoteCpqStatus,
|
|
10
|
+
} from '../../../components/statusMaps'
|
|
11
|
+
|
|
12
|
+
// ─── Types ───────────────────────────────────────────────────────
|
|
13
|
+
|
|
14
|
+
type ResolvedCharge = {
|
|
15
|
+
chargeCode: string
|
|
16
|
+
chargeName: string
|
|
17
|
+
chargeType: 'nrc' | 'mrc' | 'usage'
|
|
18
|
+
unitPrice: number
|
|
19
|
+
quantity: number | null
|
|
20
|
+
totalPrice: number | null
|
|
21
|
+
currencyCode: string
|
|
22
|
+
note?: string | null
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
type QuoteLine = {
|
|
26
|
+
lineId: string
|
|
27
|
+
offeringId: string | null
|
|
28
|
+
offeringName: string
|
|
29
|
+
quantity: number
|
|
30
|
+
nrcTotal: number
|
|
31
|
+
mrcTotal: number
|
|
32
|
+
charges: ResolvedCharge[]
|
|
33
|
+
isConfigured: boolean
|
|
34
|
+
validationErrors: Array<{ message: string }> | null
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
type QuoteResult = {
|
|
38
|
+
id: string
|
|
39
|
+
quoteId: string
|
|
40
|
+
quoteNumber: string
|
|
41
|
+
customerId: string
|
|
42
|
+
cpqStatus: string
|
|
43
|
+
version: number
|
|
44
|
+
currencyCode: string
|
|
45
|
+
pricingSummary: {
|
|
46
|
+
nrcTotal: number
|
|
47
|
+
mrcTotal: number
|
|
48
|
+
usageCharges: Array<{ chargeCode: string; chargeName: string; unitPrice: number; note: string | null }>
|
|
49
|
+
usageTotalEstimated: number | null
|
|
50
|
+
currencyCode: string
|
|
51
|
+
}
|
|
52
|
+
lines: QuoteLine[]
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// ─── Helpers ─────────────────────────────────────────────────────
|
|
56
|
+
|
|
57
|
+
function fmt(amount: number, currency: string): string {
|
|
58
|
+
return new Intl.NumberFormat('en-US', { style: 'currency', currency }).format(amount)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// ─── Main Widget (read-only) ─────────────────────────────────────
|
|
62
|
+
|
|
63
|
+
export default function QuoteConfiguratorWidget({ data }: InjectionWidgetComponentProps) {
|
|
64
|
+
const router = useRouter()
|
|
65
|
+
const record = data as Record<string, unknown> | null
|
|
66
|
+
const quoteId = (record?.id as string) ?? null
|
|
67
|
+
|
|
68
|
+
const [cpqQuote, setCpqQuote] = React.useState<QuoteResult | null>(null)
|
|
69
|
+
const [loading, setLoading] = React.useState(true)
|
|
70
|
+
const [expandedLines, setExpandedLines] = React.useState<Set<string>>(new Set())
|
|
71
|
+
|
|
72
|
+
React.useEffect(() => {
|
|
73
|
+
if (!quoteId) { setLoading(false); return }
|
|
74
|
+
let cancelled = false
|
|
75
|
+
async function load() {
|
|
76
|
+
try {
|
|
77
|
+
const res = await fetch(`/api/cpq/quotes/${quoteId}`)
|
|
78
|
+
if (res.ok && !cancelled) setCpqQuote(await res.json())
|
|
79
|
+
} catch { /* no CPQ config */ }
|
|
80
|
+
finally { if (!cancelled) setLoading(false) }
|
|
81
|
+
}
|
|
82
|
+
load()
|
|
83
|
+
return () => { cancelled = true }
|
|
84
|
+
}, [quoteId])
|
|
85
|
+
|
|
86
|
+
if (!quoteId) return <div className="p-4 text-sm text-muted-foreground">No quote context available.</div>
|
|
87
|
+
|
|
88
|
+
if (loading) {
|
|
89
|
+
return (
|
|
90
|
+
<div className="flex items-center gap-2 p-6 text-sm text-muted-foreground">
|
|
91
|
+
<Spinner /> Loading CPQ configuration…
|
|
92
|
+
</div>
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// ─── No CPQ config ─────────────────────────────────────────────
|
|
97
|
+
|
|
98
|
+
if (!cpqQuote) {
|
|
99
|
+
const custId = (record?.customerEntityId as string) ?? (record?.customer_entity_id as string) ?? ''
|
|
100
|
+
return (
|
|
101
|
+
<div className="flex flex-col items-center justify-center py-12 px-4">
|
|
102
|
+
<div className="rounded-full bg-primary/10 p-3 mb-3">
|
|
103
|
+
<svg className="h-6 w-6 text-primary" fill="none" viewBox="0 0 24 24" strokeWidth="1.5" stroke="currentColor">
|
|
104
|
+
<path strokeLinecap="round" strokeLinejoin="round" d="M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.325.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 011.37.49l1.296 2.247a1.125 1.125 0 01-.26 1.431l-1.003.827c-.293.241-.438.613-.43.992a7.723 7.723 0 010 .255c-.008.378.137.75.43.991l1.004.827c.424.35.534.955.26 1.43l-1.298 2.247a1.125 1.125 0 01-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.47 6.47 0 01-.22.128c-.331.183-.581.495-.644.869l-.213 1.281c-.09.543-.56.94-1.11.94h-2.594c-.55 0-1.019-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 01-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 01-1.369-.49l-1.297-2.247a1.125 1.125 0 01.26-1.431l1.004-.827c.292-.24.437-.613.43-.991a6.932 6.932 0 010-.255c.007-.38-.138-.751-.43-.992l-1.004-.827a1.125 1.125 0 01-.26-1.43l1.297-2.247a1.125 1.125 0 011.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.086.22-.128.332-.183.582-.495.644-.869l.214-1.28z" />
|
|
105
|
+
<path strokeLinecap="round" strokeLinejoin="round" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
|
106
|
+
</svg>
|
|
107
|
+
</div>
|
|
108
|
+
<p className="text-sm text-muted-foreground mb-4">This quote has no CPQ configuration yet.</p>
|
|
109
|
+
<button
|
|
110
|
+
onClick={() => router.push(`/backend/cpq/quotes/new?quoteId=${quoteId}&customerId=${custId}`)}
|
|
111
|
+
className="inline-flex items-center gap-2 rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow-sm hover:bg-primary/90 transition-colors"
|
|
112
|
+
>
|
|
113
|
+
<svg className="h-4 w-4" fill="none" viewBox="0 0 24 24" strokeWidth="2" stroke="currentColor">
|
|
114
|
+
<path strokeLinecap="round" strokeLinejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
|
|
115
|
+
</svg>
|
|
116
|
+
Create CPQ Quote
|
|
117
|
+
</button>
|
|
118
|
+
{!custId && <p className="mt-2 text-xs text-status-warning-text">Assign a customer to this quote first.</p>}
|
|
119
|
+
</div>
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// ─── Read-only summary ─────────────────────────────────────────
|
|
124
|
+
|
|
125
|
+
const { pricingSummary: summary, currencyCode: currency } = cpqQuote
|
|
126
|
+
const toggleLine = (id: string) => {
|
|
127
|
+
setExpandedLines((prev) => {
|
|
128
|
+
const next = new Set(prev)
|
|
129
|
+
next.has(id) ? next.delete(id) : next.add(id)
|
|
130
|
+
return next
|
|
131
|
+
})
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return (
|
|
135
|
+
<div className="space-y-4">
|
|
136
|
+
{/* Header */}
|
|
137
|
+
<div className="flex items-center justify-between px-1">
|
|
138
|
+
<div className="flex items-center gap-3">
|
|
139
|
+
<Tag variant={quoteCpqStatusMap[cpqQuote.cpqStatus as QuoteCpqStatus] ?? 'neutral'} dot>
|
|
140
|
+
{formatStatusLabel(cpqQuote.cpqStatus)}
|
|
141
|
+
</Tag>
|
|
142
|
+
<span className="text-xs text-muted-foreground">v{cpqQuote.version}</span>
|
|
143
|
+
<span className="text-xs text-muted-foreground">{currency}</span>
|
|
144
|
+
</div>
|
|
145
|
+
<button
|
|
146
|
+
onClick={() => router.push(`/backend/cpq/quotes/${cpqQuote.id}`)}
|
|
147
|
+
className="inline-flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground shadow-sm hover:bg-primary/90 transition-colors"
|
|
148
|
+
>
|
|
149
|
+
Open CPQ Configurator
|
|
150
|
+
<svg className="h-4 w-4" fill="none" viewBox="0 0 24 24" strokeWidth="2" stroke="currentColor">
|
|
151
|
+
<path strokeLinecap="round" strokeLinejoin="round" d="M13.5 6H5.25A2.25 2.25 0 003 8.25v10.5A2.25 2.25 0 005.25 21h10.5A2.25 2.25 0 0018 18.75V10.5m-10.5 6L21 3m0 0h-5.25M21 3v5.25" />
|
|
152
|
+
</svg>
|
|
153
|
+
</button>
|
|
154
|
+
</div>
|
|
155
|
+
|
|
156
|
+
{/* Lines */}
|
|
157
|
+
{cpqQuote.lines.length === 0 ? (
|
|
158
|
+
<div className="rounded-lg border bg-card py-8 text-center text-sm text-muted-foreground">
|
|
159
|
+
No items configured yet.
|
|
160
|
+
</div>
|
|
161
|
+
) : (
|
|
162
|
+
<div className="rounded-lg border bg-card divide-y">
|
|
163
|
+
{cpqQuote.lines.map((line) => {
|
|
164
|
+
const isExpanded = expandedLines.has(line.lineId)
|
|
165
|
+
return (
|
|
166
|
+
<div key={line.lineId}>
|
|
167
|
+
<div
|
|
168
|
+
className="flex items-center gap-3 px-4 py-3 hover:bg-muted/30 transition-colors cursor-pointer"
|
|
169
|
+
onClick={() => toggleLine(line.lineId)}
|
|
170
|
+
>
|
|
171
|
+
<button className="flex h-5 w-5 shrink-0 items-center justify-center rounded text-muted-foreground">
|
|
172
|
+
<svg className={`h-4 w-4 transition-transform ${isExpanded ? 'rotate-90' : ''}`} fill="none" viewBox="0 0 24 24" strokeWidth="2" stroke="currentColor">
|
|
173
|
+
<path strokeLinecap="round" strokeLinejoin="round" d="M8.25 4.5l7.5 7.5-7.5 7.5" />
|
|
174
|
+
</svg>
|
|
175
|
+
</button>
|
|
176
|
+
<div className="flex-1 min-w-0">
|
|
177
|
+
<div className="flex items-center gap-2">
|
|
178
|
+
<span className="font-medium text-sm">{line.offeringName}</span>
|
|
179
|
+
{line.quantity > 1 && <span className="rounded bg-muted px-1.5 py-0.5 text-xs font-medium">×{line.quantity}</span>}
|
|
180
|
+
{line.isConfigured ? (
|
|
181
|
+
<Tag variant="success" className="px-1.5 text-xs">configured</Tag>
|
|
182
|
+
) : (
|
|
183
|
+
<Tag variant="warning" className="px-1.5 text-xs">incomplete</Tag>
|
|
184
|
+
)}
|
|
185
|
+
</div>
|
|
186
|
+
{line.validationErrors && line.validationErrors.length > 0 && (
|
|
187
|
+
<p className="text-xs text-destructive mt-0.5">{line.validationErrors[0].message}</p>
|
|
188
|
+
)}
|
|
189
|
+
</div>
|
|
190
|
+
<div className="shrink-0 text-right text-xs space-y-0.5">
|
|
191
|
+
{line.nrcTotal > 0 && <div><span className="text-muted-foreground">NRC </span><span className="font-mono font-medium">{fmt(line.nrcTotal, currency)}</span></div>}
|
|
192
|
+
{line.mrcTotal > 0 && <div><span className="text-muted-foreground">MRC </span><span className="font-mono font-medium">{fmt(line.mrcTotal, currency)}</span></div>}
|
|
193
|
+
</div>
|
|
194
|
+
</div>
|
|
195
|
+
|
|
196
|
+
{/* Charge breakdown */}
|
|
197
|
+
{isExpanded && line.charges.length > 0 && (
|
|
198
|
+
<div className="border-t bg-muted/10 px-12 py-2">
|
|
199
|
+
<table className="w-full text-xs">
|
|
200
|
+
<thead>
|
|
201
|
+
<tr className="text-muted-foreground">
|
|
202
|
+
<th className="text-left py-1 font-medium">Charge</th>
|
|
203
|
+
<th className="text-left py-1 font-medium">Type</th>
|
|
204
|
+
<th className="text-right py-1 font-medium">Unit Price</th>
|
|
205
|
+
<th className="text-right py-1 font-medium">Qty</th>
|
|
206
|
+
<th className="text-right py-1 font-medium">Total</th>
|
|
207
|
+
</tr>
|
|
208
|
+
</thead>
|
|
209
|
+
<tbody>
|
|
210
|
+
{line.charges.map((c, i) => (
|
|
211
|
+
<tr key={i} className="border-t border-dashed border-border/50">
|
|
212
|
+
<td className="py-1">{c.chargeName}</td>
|
|
213
|
+
<td className="py-1 uppercase">{c.chargeType}</td>
|
|
214
|
+
<td className="py-1 text-right font-mono">{fmt(c.unitPrice, currency)}</td>
|
|
215
|
+
<td className="py-1 text-right font-mono">{c.quantity ?? '—'}</td>
|
|
216
|
+
<td className="py-1 text-right font-mono">{c.totalPrice != null ? fmt(c.totalPrice, currency) : c.note ?? '—'}</td>
|
|
217
|
+
</tr>
|
|
218
|
+
))}
|
|
219
|
+
</tbody>
|
|
220
|
+
</table>
|
|
221
|
+
</div>
|
|
222
|
+
)}
|
|
223
|
+
</div>
|
|
224
|
+
)
|
|
225
|
+
})}
|
|
226
|
+
</div>
|
|
227
|
+
)}
|
|
228
|
+
|
|
229
|
+
{/* Pricing Summary */}
|
|
230
|
+
{cpqQuote.lines.length > 0 && (
|
|
231
|
+
<div className="rounded-lg border bg-card p-4">
|
|
232
|
+
<div className="grid grid-cols-2 sm:grid-cols-3 gap-4">
|
|
233
|
+
<div>
|
|
234
|
+
<p className="text-xs text-muted-foreground">Non-Recurring (NRC)</p>
|
|
235
|
+
<p className="text-lg font-semibold font-mono">{fmt(summary.nrcTotal, currency)}</p>
|
|
236
|
+
</div>
|
|
237
|
+
<div>
|
|
238
|
+
<p className="text-xs text-muted-foreground">Monthly Recurring (MRC)</p>
|
|
239
|
+
<p className="text-lg font-semibold font-mono">{fmt(summary.mrcTotal, currency)}</p>
|
|
240
|
+
</div>
|
|
241
|
+
{summary.usageCharges.length > 0 && (
|
|
242
|
+
<div>
|
|
243
|
+
<p className="text-xs text-muted-foreground">Usage Charges</p>
|
|
244
|
+
<div className="mt-1 space-y-0.5">
|
|
245
|
+
{summary.usageCharges.map((uc, i) => (
|
|
246
|
+
<p key={i} className="text-xs">{uc.chargeName}: {fmt(uc.unitPrice, currency)}/unit</p>
|
|
247
|
+
))}
|
|
248
|
+
</div>
|
|
249
|
+
</div>
|
|
250
|
+
)}
|
|
251
|
+
</div>
|
|
252
|
+
</div>
|
|
253
|
+
)}
|
|
254
|
+
</div>
|
|
255
|
+
)
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function Spinner() {
|
|
259
|
+
return (
|
|
260
|
+
<svg className="h-4 w-4 animate-spin" viewBox="0 0 24 24" fill="none">
|
|
261
|
+
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" />
|
|
262
|
+
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z" />
|
|
263
|
+
</svg>
|
|
264
|
+
)
|
|
265
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { InjectionWidgetModule } from '@open-mercato/shared/modules/widgets/injection'
|
|
2
|
+
import QuoteConfiguratorWidget from './widget.client'
|
|
3
|
+
|
|
4
|
+
const widget: InjectionWidgetModule<any, any> = {
|
|
5
|
+
metadata: {
|
|
6
|
+
id: 'cpq.injection.quote-configurator',
|
|
7
|
+
title: 'CPQ Configuration',
|
|
8
|
+
description: 'Configure, price, and manage quote offerings',
|
|
9
|
+
features: ['cpq.quotes.view'],
|
|
10
|
+
priority: 70,
|
|
11
|
+
enabled: true,
|
|
12
|
+
},
|
|
13
|
+
Widget: QuoteConfiguratorWidget,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default widget
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ModuleInjectionTable } from '@open-mercato/shared/modules/widgets/injection'
|
|
2
|
+
|
|
3
|
+
export const injectionTable: ModuleInjectionTable = {
|
|
4
|
+
'sales.document.detail.quote:tabs': [
|
|
5
|
+
{
|
|
6
|
+
widgetId: 'cpq.injection.quote-configurator',
|
|
7
|
+
kind: 'tab',
|
|
8
|
+
groupLabel: 'CPQ Configuration',
|
|
9
|
+
groupDescription: 'Configure, price, and manage quote offerings',
|
|
10
|
+
priority: 70,
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
'sales.document.detail.order:tabs': [
|
|
14
|
+
{
|
|
15
|
+
widgetId: 'cpq.injection.order-cpq-tab',
|
|
16
|
+
kind: 'tab',
|
|
17
|
+
groupLabel: 'CPQ Order',
|
|
18
|
+
groupDescription: 'View the CPQ order associated with this sales order',
|
|
19
|
+
priority: 60,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
'detail:customers.company:tabs': [
|
|
23
|
+
{
|
|
24
|
+
widgetId: 'cpq.injection.customer-inventory',
|
|
25
|
+
kind: 'tab',
|
|
26
|
+
groupLabel: 'Inventory',
|
|
27
|
+
groupDescription: 'Products and services purchased by this customer',
|
|
28
|
+
priority: 60,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
'detail:customers.person:tabs': [
|
|
32
|
+
{
|
|
33
|
+
widgetId: 'cpq.injection.customer-inventory',
|
|
34
|
+
kind: 'tab',
|
|
35
|
+
groupLabel: 'Inventory',
|
|
36
|
+
groupDescription: 'Products and services purchased by this customer',
|
|
37
|
+
priority: 60,
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default injectionTable
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import React from 'react'
|
|
4
|
+
import { WizardEngineProvider, useWizardEngine } from './engine'
|
|
5
|
+
import { getStepType } from './registry'
|
|
6
|
+
import type { WizardDefinitionResult, WizardStepProps } from './types'
|
|
7
|
+
import type { TenantScope } from '../services/types'
|
|
8
|
+
|
|
9
|
+
// ─── Step renderer ──────────────────────────────────────────────
|
|
10
|
+
|
|
11
|
+
function StepRenderer({ scope }: { scope: TenantScope }) {
|
|
12
|
+
const { state, completeStep, goBack, skipStep } = useWizardEngine()
|
|
13
|
+
const { currentStep, stepData, completedSteps, currentStepId, params, quoteId, customerId } = state
|
|
14
|
+
|
|
15
|
+
const stepType = getStepType(currentStep.type)
|
|
16
|
+
|
|
17
|
+
const stepProps: WizardStepProps = {
|
|
18
|
+
stepData,
|
|
19
|
+
completedSteps,
|
|
20
|
+
currentStepId,
|
|
21
|
+
stepDefinition: currentStep,
|
|
22
|
+
config: currentStep.config,
|
|
23
|
+
params,
|
|
24
|
+
onComplete: completeStep,
|
|
25
|
+
onBack: goBack,
|
|
26
|
+
onSkip: skipStep,
|
|
27
|
+
quoteId,
|
|
28
|
+
customerId,
|
|
29
|
+
scope,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (!stepType) {
|
|
33
|
+
return (
|
|
34
|
+
<div className="rounded-lg border bg-card p-6 text-center space-y-3">
|
|
35
|
+
<p className="text-sm text-destructive">
|
|
36
|
+
Unknown step type: <strong>{currentStep.type}</strong>
|
|
37
|
+
</p>
|
|
38
|
+
<p className="text-sm text-muted-foreground">This step type is not registered. Register it via <code className="font-mono text-xs bg-muted px-1 py-0.5 rounded">registerStepType()</code>.</p>
|
|
39
|
+
<div className="flex gap-2 justify-center pt-2">
|
|
40
|
+
{state.canGoBack && (
|
|
41
|
+
<button type="button" onClick={goBack} className="inline-flex items-center justify-center rounded-md border px-4 py-2 text-sm font-medium hover:bg-muted">
|
|
42
|
+
Back
|
|
43
|
+
</button>
|
|
44
|
+
)}
|
|
45
|
+
{state.canSkip && (
|
|
46
|
+
<button type="button" onClick={skipStep} className="inline-flex items-center justify-center rounded-md border px-4 py-2 text-sm font-medium hover:bg-muted">
|
|
47
|
+
Skip
|
|
48
|
+
</button>
|
|
49
|
+
)}
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const Component = stepType.component
|
|
56
|
+
return <Component {...stepProps} />
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// ─── Progress bar ───────────────────────────────────────────────
|
|
60
|
+
|
|
61
|
+
function WizardProgress() {
|
|
62
|
+
const { state } = useWizardEngine()
|
|
63
|
+
const { definition, completedSteps, currentStepId, completionPercent } = state
|
|
64
|
+
const steps = definition.steps
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<div className="flex items-center gap-1 py-2">
|
|
68
|
+
{steps.map((step, idx) => {
|
|
69
|
+
const isCompleted = completedSteps.includes(step.stepId)
|
|
70
|
+
const isCurrent = step.stepId === currentStepId
|
|
71
|
+
return (
|
|
72
|
+
<div key={step.stepId} className="flex items-center gap-1">
|
|
73
|
+
<div
|
|
74
|
+
className={`w-7 h-7 rounded-full flex items-center justify-center text-xs ${
|
|
75
|
+
isCompleted
|
|
76
|
+
? 'bg-primary text-primary-foreground font-medium'
|
|
77
|
+
: isCurrent
|
|
78
|
+
? 'bg-primary text-primary-foreground font-bold'
|
|
79
|
+
: 'bg-muted text-muted-foreground'
|
|
80
|
+
}`}
|
|
81
|
+
title={step.title}
|
|
82
|
+
>
|
|
83
|
+
{isCompleted ? '\u2713' : idx + 1}
|
|
84
|
+
</div>
|
|
85
|
+
{idx < steps.length - 1 && (
|
|
86
|
+
<div className={`w-6 h-0.5 ${isCompleted ? 'bg-primary' : 'bg-muted'}`} />
|
|
87
|
+
)}
|
|
88
|
+
</div>
|
|
89
|
+
)
|
|
90
|
+
})}
|
|
91
|
+
<span className="ml-2 text-xs text-muted-foreground">
|
|
92
|
+
{completionPercent}%
|
|
93
|
+
</span>
|
|
94
|
+
</div>
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// ─── Header ─────────────────────────────────────────────────────
|
|
99
|
+
|
|
100
|
+
function WizardHeader() {
|
|
101
|
+
const { state } = useWizardEngine()
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<div className="flex items-center justify-between">
|
|
105
|
+
<div>
|
|
106
|
+
<h2 className="text-lg font-semibold">{state.definition.name}</h2>
|
|
107
|
+
<p className="text-sm text-muted-foreground">
|
|
108
|
+
Step: {state.currentStep.title}
|
|
109
|
+
</p>
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// ─── Main Runner component ──────────────────────────────────────
|
|
116
|
+
|
|
117
|
+
interface WizardRunnerProps {
|
|
118
|
+
definition: WizardDefinitionResult
|
|
119
|
+
params?: Record<string, unknown>
|
|
120
|
+
initialQuoteId?: string | null
|
|
121
|
+
initialCustomerId?: string | null
|
|
122
|
+
scope: TenantScope
|
|
123
|
+
onComplete?: (stepData: Record<string, Record<string, unknown>>) => void
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function WizardRunner({
|
|
127
|
+
definition,
|
|
128
|
+
params,
|
|
129
|
+
initialQuoteId,
|
|
130
|
+
initialCustomerId,
|
|
131
|
+
scope,
|
|
132
|
+
onComplete,
|
|
133
|
+
}: WizardRunnerProps) {
|
|
134
|
+
const handleComplete = React.useCallback(
|
|
135
|
+
(stepData: Record<string, Record<string, unknown>>) => {
|
|
136
|
+
onComplete?.(stepData)
|
|
137
|
+
},
|
|
138
|
+
[onComplete],
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<WizardEngineProvider
|
|
143
|
+
definition={definition}
|
|
144
|
+
params={params}
|
|
145
|
+
initialQuoteId={initialQuoteId}
|
|
146
|
+
initialCustomerId={initialCustomerId}
|
|
147
|
+
onComplete={handleComplete}
|
|
148
|
+
>
|
|
149
|
+
<div className="space-y-4">
|
|
150
|
+
<WizardHeader />
|
|
151
|
+
<WizardProgress />
|
|
152
|
+
<div className="min-h-[200px]">
|
|
153
|
+
<StepRenderer scope={scope} />
|
|
154
|
+
</div>
|
|
155
|
+
</div>
|
|
156
|
+
</WizardEngineProvider>
|
|
157
|
+
)
|
|
158
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import React, { useCallback, useState } from 'react'
|
|
4
|
+
import { useRouter } from 'next/navigation'
|
|
5
|
+
import type { WizardDefinitionResult } from './types'
|
|
6
|
+
|
|
7
|
+
// ─── API helper ─────────────────────────────────────────────────
|
|
8
|
+
|
|
9
|
+
async function apiJson<T>(url: string): Promise<T> {
|
|
10
|
+
const res = await fetch(url)
|
|
11
|
+
if (!res.ok) {
|
|
12
|
+
const body = await res.json().catch(() => ({}))
|
|
13
|
+
throw new Error(body.error ?? `API error ${res.status}`)
|
|
14
|
+
}
|
|
15
|
+
return res.json() as Promise<T>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// ─── Props ──────────────────────────────────────────────────────
|
|
19
|
+
|
|
20
|
+
export interface WizardTriggerProps {
|
|
21
|
+
/** Explicit wizard definition code. If set, uses this wizard directly. */
|
|
22
|
+
wizardCode?: string
|
|
23
|
+
/** Offering code for wizard resolution (when no explicit wizard). */
|
|
24
|
+
offeringCode?: string
|
|
25
|
+
/** Launch params passed to the wizard engine. */
|
|
26
|
+
params?: Record<string, unknown>
|
|
27
|
+
/** Surface context. */
|
|
28
|
+
surface?: 'backend' | 'portal'
|
|
29
|
+
/** Button label. */
|
|
30
|
+
label?: string
|
|
31
|
+
/** Render variant. */
|
|
32
|
+
variant?: 'button' | 'link' | 'card'
|
|
33
|
+
/** Additional CSS class. */
|
|
34
|
+
className?: string
|
|
35
|
+
/** Override the navigation target base path. */
|
|
36
|
+
basePath?: string
|
|
37
|
+
/** Called after wizard is resolved (instead of navigating). */
|
|
38
|
+
onStart?: (definition: WizardDefinitionResult, params: Record<string, unknown>) => void
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function WizardTrigger({
|
|
42
|
+
wizardCode,
|
|
43
|
+
offeringCode,
|
|
44
|
+
params: wizardParams = {},
|
|
45
|
+
surface = 'backend',
|
|
46
|
+
label = 'Start Wizard',
|
|
47
|
+
variant = 'button',
|
|
48
|
+
className,
|
|
49
|
+
basePath,
|
|
50
|
+
onStart,
|
|
51
|
+
}: WizardTriggerProps) {
|
|
52
|
+
const router = useRouter()
|
|
53
|
+
const [loading, setLoading] = useState(false)
|
|
54
|
+
const [error, setError] = useState<string | null>(null)
|
|
55
|
+
|
|
56
|
+
const handleClick = useCallback(async () => {
|
|
57
|
+
setLoading(true)
|
|
58
|
+
setError(null)
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
// Resolve definition
|
|
62
|
+
let definition: WizardDefinitionResult | null = null
|
|
63
|
+
|
|
64
|
+
if (wizardCode) {
|
|
65
|
+
definition = await apiJson<WizardDefinitionResult>(
|
|
66
|
+
`/api/cpq/wizards?code=${encodeURIComponent(wizardCode)}`,
|
|
67
|
+
)
|
|
68
|
+
} else {
|
|
69
|
+
const resolveParams = new URLSearchParams({ surface })
|
|
70
|
+
if (offeringCode) resolveParams.set('offeringCode', offeringCode)
|
|
71
|
+
definition = await apiJson<WizardDefinitionResult>(
|
|
72
|
+
`/api/cpq/wizards/resolve?${resolveParams}`,
|
|
73
|
+
)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (!definition) {
|
|
77
|
+
setError('No matching wizard found')
|
|
78
|
+
return
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (onStart) {
|
|
82
|
+
onStart(definition, wizardParams)
|
|
83
|
+
} else {
|
|
84
|
+
const path = basePath ?? (surface === 'portal' ? '/wizards' : '/backend/cpq/wizards')
|
|
85
|
+
const queryParams = new URLSearchParams()
|
|
86
|
+
if (Object.keys(wizardParams).length > 0) {
|
|
87
|
+
queryParams.set('params', JSON.stringify(wizardParams))
|
|
88
|
+
}
|
|
89
|
+
const qs = queryParams.toString()
|
|
90
|
+
router.push(`${path}/${definition.code}${qs ? `?${qs}` : ''}`)
|
|
91
|
+
}
|
|
92
|
+
} catch (err) {
|
|
93
|
+
setError(err instanceof Error ? err.message : 'Failed to start wizard')
|
|
94
|
+
} finally {
|
|
95
|
+
setLoading(false)
|
|
96
|
+
}
|
|
97
|
+
}, [wizardCode, offeringCode, wizardParams, surface, basePath, onStart, router])
|
|
98
|
+
|
|
99
|
+
if (variant === 'link') {
|
|
100
|
+
return (
|
|
101
|
+
<a
|
|
102
|
+
href="#"
|
|
103
|
+
className={className ?? 'text-sm text-primary hover:underline'}
|
|
104
|
+
onClick={(e) => {
|
|
105
|
+
e.preventDefault()
|
|
106
|
+
handleClick()
|
|
107
|
+
}}
|
|
108
|
+
>
|
|
109
|
+
{loading ? 'Starting...' : label}
|
|
110
|
+
{error && <span className="ml-2 text-xs text-destructive">{error}</span>}
|
|
111
|
+
</a>
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (variant === 'card') {
|
|
116
|
+
return (
|
|
117
|
+
<div
|
|
118
|
+
className={className ?? 'rounded-lg border p-4 cursor-pointer hover:shadow-sm transition-shadow'}
|
|
119
|
+
onClick={handleClick}
|
|
120
|
+
role="button"
|
|
121
|
+
tabIndex={0}
|
|
122
|
+
onKeyDown={(e) => { if (e.key === 'Enter') handleClick() }}
|
|
123
|
+
>
|
|
124
|
+
<p className="font-semibold text-sm">{label}</p>
|
|
125
|
+
{error && <p className="mt-1 text-xs text-destructive">{error}</p>}
|
|
126
|
+
</div>
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Default: button
|
|
131
|
+
return (
|
|
132
|
+
<button
|
|
133
|
+
type="button"
|
|
134
|
+
className={className ?? 'inline-flex items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50'}
|
|
135
|
+
onClick={handleClick}
|
|
136
|
+
disabled={loading}
|
|
137
|
+
>
|
|
138
|
+
{loading ? 'Starting...' : label}
|
|
139
|
+
{error && <span className="ml-2 text-xs text-destructive/70">{error}</span>}
|
|
140
|
+
</button>
|
|
141
|
+
)
|
|
142
|
+
}
|