@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,737 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
import * as React from 'react'
|
|
3
|
+
import { Alert } from '@open-mercato/ui/primitives/alert'
|
|
4
|
+
import { NumberInput as BaseNumberInput } from '../../../../../components/NumberInput'
|
|
5
|
+
|
|
6
|
+
// XD-250 — ARC configurator drawer.
|
|
7
|
+
//
|
|
8
|
+
// Self-contained right-side drawer: action selection → target picker →
|
|
9
|
+
// renew/cancel config → review → submit. The host quote detail page renders
|
|
10
|
+
// it on demand and refetches when the drawer reports `onChanged`.
|
|
11
|
+
|
|
12
|
+
type ArcType = 'amend' | 'renew' | 'cancel'
|
|
13
|
+
type Step =
|
|
14
|
+
| 'pick-action'
|
|
15
|
+
| 'pick-targets'
|
|
16
|
+
| 'config-renew'
|
|
17
|
+
| 'config-cancel'
|
|
18
|
+
| 'review'
|
|
19
|
+
| 'submitting'
|
|
20
|
+
| 'done'
|
|
21
|
+
|
|
22
|
+
type EligibleSub = {
|
|
23
|
+
id: string
|
|
24
|
+
code: string
|
|
25
|
+
name: string
|
|
26
|
+
status: string
|
|
27
|
+
currencyCode: string
|
|
28
|
+
billingCycle: string
|
|
29
|
+
currentTermEnd: string | null
|
|
30
|
+
mrcAmount: number
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type AttachedTarget = {
|
|
34
|
+
id: string
|
|
35
|
+
subscriptionId: string
|
|
36
|
+
quoteType: string
|
|
37
|
+
mergeAction: string | null
|
|
38
|
+
newTermStart: string | null
|
|
39
|
+
newTermEnd: string | null
|
|
40
|
+
newTermMonths: number | null
|
|
41
|
+
subscription: {
|
|
42
|
+
code: string
|
|
43
|
+
name: string
|
|
44
|
+
currencyCode: string
|
|
45
|
+
billingCycle: string
|
|
46
|
+
mrcAmount: number
|
|
47
|
+
} | null
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface ArcQuoteConfiguratorProps {
|
|
51
|
+
quoteId: string
|
|
52
|
+
customerId: string
|
|
53
|
+
customerName: string | null
|
|
54
|
+
currencyCode: string
|
|
55
|
+
initialType: 'new' | ArcType
|
|
56
|
+
initialTargets: AttachedTarget[]
|
|
57
|
+
editable: boolean
|
|
58
|
+
onClose: () => void
|
|
59
|
+
onChanged: () => void | Promise<void>
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const REASON_CODES = [
|
|
63
|
+
{ value: 'upgrade', label: 'Upgrade' },
|
|
64
|
+
{ value: 'downgrade', label: 'Downgrade' },
|
|
65
|
+
{ value: 'config-change', label: 'Configuration change' },
|
|
66
|
+
{ value: 'price-adjustment', label: 'Price adjustment' },
|
|
67
|
+
{ value: 'term-extension', label: 'Term extension' },
|
|
68
|
+
{ value: 'term-reduction', label: 'Term reduction' },
|
|
69
|
+
{ value: 'consolidation', label: 'Consolidation' },
|
|
70
|
+
{ value: 'customer-request', label: 'Customer request' },
|
|
71
|
+
{ value: 'non-payment', label: 'Non-payment' },
|
|
72
|
+
{ value: 'contract-breach', label: 'Contract breach' },
|
|
73
|
+
{ value: 'other', label: 'Other' },
|
|
74
|
+
] as const
|
|
75
|
+
|
|
76
|
+
export default function ArcQuoteConfigurator(
|
|
77
|
+
props: ArcQuoteConfiguratorProps,
|
|
78
|
+
): React.ReactElement {
|
|
79
|
+
const {
|
|
80
|
+
quoteId,
|
|
81
|
+
customerId,
|
|
82
|
+
customerName,
|
|
83
|
+
currencyCode,
|
|
84
|
+
initialType,
|
|
85
|
+
initialTargets,
|
|
86
|
+
editable,
|
|
87
|
+
onClose,
|
|
88
|
+
onChanged,
|
|
89
|
+
} = props
|
|
90
|
+
|
|
91
|
+
const [step, setStep] = React.useState<Step>(
|
|
92
|
+
initialType === 'new' ? 'pick-action' : 'pick-targets',
|
|
93
|
+
)
|
|
94
|
+
const [type, setType] = React.useState<ArcType | null>(
|
|
95
|
+
initialType === 'new' ? null : (initialType as ArcType),
|
|
96
|
+
)
|
|
97
|
+
const [eligible, setEligible] = React.useState<EligibleSub[]>([])
|
|
98
|
+
const [eligibleLoading, setEligibleLoading] = React.useState(false)
|
|
99
|
+
const [picked, setPicked] = React.useState<Record<string, EligibleSub>>(() => {
|
|
100
|
+
const seed: Record<string, EligibleSub> = {}
|
|
101
|
+
for (const t of initialTargets) {
|
|
102
|
+
if (t.subscription) {
|
|
103
|
+
seed[t.subscriptionId] = {
|
|
104
|
+
id: t.subscriptionId,
|
|
105
|
+
code: t.subscription.code,
|
|
106
|
+
name: t.subscription.name,
|
|
107
|
+
status: 'active',
|
|
108
|
+
currencyCode: t.subscription.currencyCode,
|
|
109
|
+
billingCycle: t.subscription.billingCycle,
|
|
110
|
+
currentTermEnd: null,
|
|
111
|
+
mrcAmount: t.subscription.mrcAmount,
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return seed
|
|
116
|
+
})
|
|
117
|
+
// Renew config (per-target term for standalone, quote-level for merge).
|
|
118
|
+
const [singleTerm, setSingleTerm] = React.useState<{ start: string; end: string; months: string }>(() => ({
|
|
119
|
+
start: initialTargets[0]?.newTermStart?.slice(0, 10) ?? '',
|
|
120
|
+
end: initialTargets[0]?.newTermEnd?.slice(0, 10) ?? '',
|
|
121
|
+
months: initialTargets[0]?.newTermMonths != null ? String(initialTargets[0].newTermMonths) : '',
|
|
122
|
+
}))
|
|
123
|
+
const [mergeTerm, setMergeTerm] = React.useState({
|
|
124
|
+
start: '',
|
|
125
|
+
end: '',
|
|
126
|
+
months: '',
|
|
127
|
+
code: '',
|
|
128
|
+
name: '',
|
|
129
|
+
})
|
|
130
|
+
// Cancel config.
|
|
131
|
+
const [cancelMeta, setCancelMeta] = React.useState({
|
|
132
|
+
reasonCode: '',
|
|
133
|
+
reasonText: '',
|
|
134
|
+
etfAmount: '',
|
|
135
|
+
etfCurrency: currencyCode,
|
|
136
|
+
})
|
|
137
|
+
const [submitError, setSubmitError] = React.useState<string | null>(null)
|
|
138
|
+
|
|
139
|
+
// ESC closes the drawer.
|
|
140
|
+
React.useEffect(() => {
|
|
141
|
+
function onKey(e: KeyboardEvent) {
|
|
142
|
+
if (e.key === 'Escape') onClose()
|
|
143
|
+
}
|
|
144
|
+
window.addEventListener('keydown', onKey)
|
|
145
|
+
return () => window.removeEventListener('keydown', onKey)
|
|
146
|
+
}, [onClose])
|
|
147
|
+
|
|
148
|
+
// Fetch eligible subscriptions when step requires it.
|
|
149
|
+
React.useEffect(() => {
|
|
150
|
+
if (step !== 'pick-targets') return
|
|
151
|
+
setEligibleLoading(true)
|
|
152
|
+
fetch(`/api/cpq/inventory/subscriptions?customerId=${customerId}&pageSize=100`)
|
|
153
|
+
.then((r) => r.json())
|
|
154
|
+
.then((data) => {
|
|
155
|
+
const items: EligibleSub[] = (data.items ?? []).map((s: EligibleSub) => ({
|
|
156
|
+
...s,
|
|
157
|
+
mrcAmount: Number(s.mrcAmount ?? 0),
|
|
158
|
+
}))
|
|
159
|
+
setEligible(items)
|
|
160
|
+
})
|
|
161
|
+
.catch(() => setEligible([]))
|
|
162
|
+
.finally(() => setEligibleLoading(false))
|
|
163
|
+
}, [step, customerId])
|
|
164
|
+
|
|
165
|
+
const pickedList = Object.values(picked)
|
|
166
|
+
const isMergeRenew = type === 'renew' && pickedList.length >= 2
|
|
167
|
+
const billingCycles = new Set(pickedList.map((s) => s.billingCycle))
|
|
168
|
+
const cyclesMatch = billingCycles.size <= 1
|
|
169
|
+
const currenciesMatch = pickedList.every((s) => s.currencyCode === currencyCode)
|
|
170
|
+
|
|
171
|
+
// Validation gates.
|
|
172
|
+
const canProceedFromTargets = pickedList.length > 0 && currenciesMatch
|
|
173
|
+
const canProceedFromRenew =
|
|
174
|
+
isMergeRenew
|
|
175
|
+
? !!mergeTerm.start && !!mergeTerm.end && mergeTerm.start < mergeTerm.end && cyclesMatch
|
|
176
|
+
: !!singleTerm.start && !!singleTerm.end && singleTerm.start < singleTerm.end
|
|
177
|
+
const canProceedFromCancel = !!cancelMeta.reasonCode
|
|
178
|
+
|
|
179
|
+
const submit = React.useCallback(async () => {
|
|
180
|
+
setStep('submitting')
|
|
181
|
+
setSubmitError(null)
|
|
182
|
+
try {
|
|
183
|
+
// Step 1 — set quote type when transitioning from 'new'.
|
|
184
|
+
if (initialType === 'new' && type) {
|
|
185
|
+
const r = await fetch(`/api/cpq/quotes/${quoteId}`, {
|
|
186
|
+
method: 'PATCH',
|
|
187
|
+
headers: { 'content-type': 'application/json' },
|
|
188
|
+
body: JSON.stringify({ quoteType: type }),
|
|
189
|
+
})
|
|
190
|
+
if (!r.ok) {
|
|
191
|
+
const body = await r.json().catch(() => ({}))
|
|
192
|
+
throw new Error(body.error ?? `PATCH /quotes/${quoteId} failed`)
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Step 2 — detach removed targets.
|
|
197
|
+
const initialTargetIds = new Set(initialTargets.map((t) => t.subscriptionId))
|
|
198
|
+
const pickedIds = new Set(pickedList.map((s) => s.id))
|
|
199
|
+
for (const t of initialTargets) {
|
|
200
|
+
if (!pickedIds.has(t.subscriptionId)) {
|
|
201
|
+
await fetch(`/api/cpq/quotes/${quoteId}/target-subscriptions/${t.id}`, { method: 'DELETE' })
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Step 3 — attach new targets.
|
|
206
|
+
for (const s of pickedList) {
|
|
207
|
+
if (!initialTargetIds.has(s.id) && type) {
|
|
208
|
+
const body: Record<string, unknown> = {
|
|
209
|
+
subscriptionId: s.id,
|
|
210
|
+
quoteType: type,
|
|
211
|
+
}
|
|
212
|
+
if (type === 'renew' && !isMergeRenew) {
|
|
213
|
+
body.mergeAction = 'standalone'
|
|
214
|
+
body.newTermStart = singleTerm.start
|
|
215
|
+
body.newTermEnd = singleTerm.end
|
|
216
|
+
if (singleTerm.months) body.newTermMonths = Number(singleTerm.months)
|
|
217
|
+
} else if (type === 'renew' && isMergeRenew) {
|
|
218
|
+
body.mergeAction = 'absorb'
|
|
219
|
+
}
|
|
220
|
+
const r = await fetch(`/api/cpq/quotes/${quoteId}/target-subscriptions`, {
|
|
221
|
+
method: 'POST',
|
|
222
|
+
headers: { 'content-type': 'application/json' },
|
|
223
|
+
body: JSON.stringify(body),
|
|
224
|
+
})
|
|
225
|
+
if (!r.ok) {
|
|
226
|
+
const errBody = await r.json().catch(() => ({}))
|
|
227
|
+
throw new Error(errBody.error ?? `POST /target-subscriptions failed`)
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// Step 4 — for merge renew, stamp quote-level merge meta.
|
|
233
|
+
if (type === 'renew' && isMergeRenew) {
|
|
234
|
+
const body: Record<string, unknown> = {
|
|
235
|
+
newTermStart: mergeTerm.start,
|
|
236
|
+
newTermEnd: mergeTerm.end,
|
|
237
|
+
}
|
|
238
|
+
if (mergeTerm.months) body.newTermMonths = Number(mergeTerm.months)
|
|
239
|
+
if (mergeTerm.code) body.newSubCode = mergeTerm.code
|
|
240
|
+
if (mergeTerm.name) body.newSubName = mergeTerm.name
|
|
241
|
+
const r = await fetch(`/api/cpq/quotes/${quoteId}/merge-meta`, {
|
|
242
|
+
method: 'POST',
|
|
243
|
+
headers: { 'content-type': 'application/json' },
|
|
244
|
+
body: JSON.stringify(body),
|
|
245
|
+
})
|
|
246
|
+
if (!r.ok) {
|
|
247
|
+
const errBody = await r.json().catch(() => ({}))
|
|
248
|
+
throw new Error(errBody.error ?? `POST /merge-meta failed`)
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// Step 5 — for cancel, stamp meta.
|
|
253
|
+
if (type === 'cancel') {
|
|
254
|
+
const body: Record<string, unknown> = { reasonCode: cancelMeta.reasonCode }
|
|
255
|
+
if (cancelMeta.reasonText) body.reasonText = cancelMeta.reasonText
|
|
256
|
+
if (cancelMeta.etfAmount) body.etfAmount = cancelMeta.etfAmount
|
|
257
|
+
if (cancelMeta.etfCurrency) body.etfCurrency = cancelMeta.etfCurrency
|
|
258
|
+
const r = await fetch(`/api/cpq/quotes/${quoteId}/cancel-meta`, {
|
|
259
|
+
method: 'POST',
|
|
260
|
+
headers: { 'content-type': 'application/json' },
|
|
261
|
+
body: JSON.stringify(body),
|
|
262
|
+
})
|
|
263
|
+
if (!r.ok) {
|
|
264
|
+
const errBody = await r.json().catch(() => ({}))
|
|
265
|
+
throw new Error(errBody.error ?? `POST /cancel-meta failed`)
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
await onChanged()
|
|
270
|
+
setStep('done')
|
|
271
|
+
} catch (err) {
|
|
272
|
+
setSubmitError(err instanceof Error ? err.message : String(err))
|
|
273
|
+
setStep('review')
|
|
274
|
+
}
|
|
275
|
+
}, [
|
|
276
|
+
quoteId,
|
|
277
|
+
type,
|
|
278
|
+
initialType,
|
|
279
|
+
initialTargets,
|
|
280
|
+
pickedList,
|
|
281
|
+
isMergeRenew,
|
|
282
|
+
singleTerm,
|
|
283
|
+
mergeTerm,
|
|
284
|
+
cancelMeta,
|
|
285
|
+
onChanged,
|
|
286
|
+
])
|
|
287
|
+
|
|
288
|
+
return (
|
|
289
|
+
<div className="fixed inset-0 z-50 flex" role="dialog" aria-modal="true">
|
|
290
|
+
{/* Overlay */}
|
|
291
|
+
<button
|
|
292
|
+
aria-label="Close drawer"
|
|
293
|
+
className="absolute inset-0 bg-black/40"
|
|
294
|
+
onClick={onClose}
|
|
295
|
+
/>
|
|
296
|
+
{/* Drawer */}
|
|
297
|
+
<div className="ml-auto h-full w-full max-w-2xl bg-card shadow-xl border-l overflow-y-auto relative flex flex-col">
|
|
298
|
+
<header className="border-b px-5 py-4 flex items-start justify-between">
|
|
299
|
+
<div>
|
|
300
|
+
<h2 className="text-lg font-semibold">Modify subscription</h2>
|
|
301
|
+
<p className="text-xs text-muted-foreground mt-0.5">
|
|
302
|
+
{customerName ?? customerId.slice(0, 12) + '…'} • {currencyCode}
|
|
303
|
+
</p>
|
|
304
|
+
</div>
|
|
305
|
+
<button
|
|
306
|
+
onClick={onClose}
|
|
307
|
+
className="text-sm text-muted-foreground hover:text-foreground"
|
|
308
|
+
>
|
|
309
|
+
✕
|
|
310
|
+
</button>
|
|
311
|
+
</header>
|
|
312
|
+
|
|
313
|
+
<div className="flex-1 px-5 py-4 space-y-4">
|
|
314
|
+
{/* Step indicator */}
|
|
315
|
+
<p className="text-xs text-muted-foreground">
|
|
316
|
+
Step: <span className="font-mono">{step}</span>
|
|
317
|
+
{type && <span> • {type}</span>}
|
|
318
|
+
{pickedList.length > 0 && <span> • {pickedList.length} target(s)</span>}
|
|
319
|
+
</p>
|
|
320
|
+
|
|
321
|
+
{step === 'pick-action' && (
|
|
322
|
+
<div className="space-y-3">
|
|
323
|
+
<p className="text-sm">Pick the kind of change you want to make:</p>
|
|
324
|
+
{(['amend', 'renew', 'cancel'] as const).map((opt) => (
|
|
325
|
+
<button
|
|
326
|
+
key={opt}
|
|
327
|
+
onClick={() => {
|
|
328
|
+
setType(opt)
|
|
329
|
+
setStep('pick-targets')
|
|
330
|
+
}}
|
|
331
|
+
className="block w-full text-left rounded-md border border-input px-4 py-3 hover:bg-muted"
|
|
332
|
+
>
|
|
333
|
+
<span className="font-medium capitalize">{opt}</span>
|
|
334
|
+
<span className="block text-xs text-muted-foreground mt-0.5">
|
|
335
|
+
{opt === 'amend' && 'Add or remove items on existing subscriptions. Term untouched.'}
|
|
336
|
+
{opt === 'renew' && 'Extend term. With 2+ targets, merges them into a new contract.'}
|
|
337
|
+
{opt === 'cancel' && 'Terminate one or more subscriptions.'}
|
|
338
|
+
</span>
|
|
339
|
+
</button>
|
|
340
|
+
))}
|
|
341
|
+
</div>
|
|
342
|
+
)}
|
|
343
|
+
|
|
344
|
+
{step === 'pick-targets' && type && (
|
|
345
|
+
<div className="space-y-3">
|
|
346
|
+
{eligibleLoading ? (
|
|
347
|
+
<div className="text-sm text-muted-foreground">Loading subscriptions…</div>
|
|
348
|
+
) : eligible.length === 0 ? (
|
|
349
|
+
<div className="text-sm text-muted-foreground">No subscriptions for this customer.</div>
|
|
350
|
+
) : (
|
|
351
|
+
<div className="space-y-1">
|
|
352
|
+
{eligible.map((s) => {
|
|
353
|
+
const currencyMismatch = s.currencyCode !== currencyCode
|
|
354
|
+
const isPicked = !!picked[s.id]
|
|
355
|
+
return (
|
|
356
|
+
<label
|
|
357
|
+
key={s.id}
|
|
358
|
+
className={`flex items-start gap-2 rounded-md border px-3 py-2 ${
|
|
359
|
+
currencyMismatch
|
|
360
|
+
? 'opacity-50 border-dashed'
|
|
361
|
+
: isPicked
|
|
362
|
+
? 'border-primary bg-primary/5'
|
|
363
|
+
: 'border-input hover:bg-muted'
|
|
364
|
+
}`}
|
|
365
|
+
>
|
|
366
|
+
<input
|
|
367
|
+
type="checkbox"
|
|
368
|
+
disabled={currencyMismatch}
|
|
369
|
+
checked={isPicked}
|
|
370
|
+
onChange={(e) => {
|
|
371
|
+
setPicked((prev) => {
|
|
372
|
+
const next = { ...prev }
|
|
373
|
+
if (e.target.checked) next[s.id] = s
|
|
374
|
+
else delete next[s.id]
|
|
375
|
+
return next
|
|
376
|
+
})
|
|
377
|
+
}}
|
|
378
|
+
/>
|
|
379
|
+
<div className="flex-1 min-w-0">
|
|
380
|
+
<div className="text-sm font-medium">
|
|
381
|
+
{s.name}{' '}
|
|
382
|
+
<span className="text-xs font-mono text-muted-foreground">{s.code}</span>
|
|
383
|
+
</div>
|
|
384
|
+
<div className="text-xs text-muted-foreground">
|
|
385
|
+
{s.status} • {s.billingCycle} • MRC {s.mrcAmount.toFixed(2)} {s.currencyCode}
|
|
386
|
+
{s.currentTermEnd
|
|
387
|
+
? ` • Term ends ${new Date(s.currentTermEnd).toLocaleDateString()}`
|
|
388
|
+
: ''}
|
|
389
|
+
</div>
|
|
390
|
+
{currencyMismatch && (
|
|
391
|
+
<div className="text-xs text-status-warning-text mt-1">
|
|
392
|
+
Currency mismatch ({s.currencyCode} vs {currencyCode}) — cannot include
|
|
393
|
+
</div>
|
|
394
|
+
)}
|
|
395
|
+
</div>
|
|
396
|
+
</label>
|
|
397
|
+
)
|
|
398
|
+
})}
|
|
399
|
+
</div>
|
|
400
|
+
)}
|
|
401
|
+
{!cyclesMatch && (
|
|
402
|
+
<Alert variant="warning" className="text-xs">
|
|
403
|
+
Picked targets have different billing cycles — merge requires matching cycles.
|
|
404
|
+
</Alert>
|
|
405
|
+
)}
|
|
406
|
+
{isMergeRenew && (
|
|
407
|
+
<Alert variant="warning" className="text-xs">
|
|
408
|
+
Merging {pickedList.length} contracts into a new one — sources will be marked Merged at activation.
|
|
409
|
+
</Alert>
|
|
410
|
+
)}
|
|
411
|
+
</div>
|
|
412
|
+
)}
|
|
413
|
+
|
|
414
|
+
{step === 'config-renew' && type === 'renew' && !isMergeRenew && (
|
|
415
|
+
<div className="space-y-3">
|
|
416
|
+
<p className="text-sm">New contract term for {pickedList[0]?.name}:</p>
|
|
417
|
+
<p className="text-xs text-muted-foreground">
|
|
418
|
+
Pre-filled with same length as the current term, starting at the
|
|
419
|
+
current term end. Type a new value in <span className="font-medium">Months</span> to
|
|
420
|
+
auto-shift the end date, or edit start/end directly.
|
|
421
|
+
</p>
|
|
422
|
+
<div className="grid grid-cols-3 gap-3">
|
|
423
|
+
<DateInput
|
|
424
|
+
label="Start"
|
|
425
|
+
value={singleTerm.start}
|
|
426
|
+
onChange={(v) => {
|
|
427
|
+
// If months is set, slide end too so the contract length stays.
|
|
428
|
+
const months = singleTerm.months ? Number(singleTerm.months) : null
|
|
429
|
+
const end = months && v ? addMonthsToIso(v, months) : singleTerm.end
|
|
430
|
+
setSingleTerm({ ...singleTerm, start: v, end })
|
|
431
|
+
}}
|
|
432
|
+
/>
|
|
433
|
+
<DateInput
|
|
434
|
+
label="End"
|
|
435
|
+
value={singleTerm.end}
|
|
436
|
+
onChange={(v) => setSingleTerm({ ...singleTerm, end: v })}
|
|
437
|
+
/>
|
|
438
|
+
<NumberInput
|
|
439
|
+
label="Months"
|
|
440
|
+
value={singleTerm.months}
|
|
441
|
+
onChange={(v) => {
|
|
442
|
+
// Recompute end = start + months when both are present.
|
|
443
|
+
const months = v ? Number(v) : null
|
|
444
|
+
const end = months && singleTerm.start
|
|
445
|
+
? addMonthsToIso(singleTerm.start, months)
|
|
446
|
+
: singleTerm.end
|
|
447
|
+
setSingleTerm({ ...singleTerm, months: v, end })
|
|
448
|
+
}}
|
|
449
|
+
/>
|
|
450
|
+
</div>
|
|
451
|
+
</div>
|
|
452
|
+
)}
|
|
453
|
+
|
|
454
|
+
{step === 'config-renew' && type === 'renew' && isMergeRenew && (
|
|
455
|
+
<div className="space-y-3">
|
|
456
|
+
<p className="text-sm">
|
|
457
|
+
New contract details (merge of {pickedList.length} subscriptions):
|
|
458
|
+
</p>
|
|
459
|
+
<p className="text-xs text-muted-foreground">
|
|
460
|
+
Type a value into <span className="font-medium">Months</span> to
|
|
461
|
+
auto-fill both dates — start defaults to today, end is start + months.
|
|
462
|
+
</p>
|
|
463
|
+
<div className="grid grid-cols-3 gap-3">
|
|
464
|
+
<DateInput
|
|
465
|
+
label="Start"
|
|
466
|
+
value={mergeTerm.start}
|
|
467
|
+
onChange={(v) => {
|
|
468
|
+
const months = mergeTerm.months ? Number(mergeTerm.months) : null
|
|
469
|
+
const end = months && v ? addMonthsToIso(v, months) : mergeTerm.end
|
|
470
|
+
setMergeTerm({ ...mergeTerm, start: v, end })
|
|
471
|
+
}}
|
|
472
|
+
/>
|
|
473
|
+
<DateInput
|
|
474
|
+
label="End"
|
|
475
|
+
value={mergeTerm.end}
|
|
476
|
+
onChange={(v) => setMergeTerm({ ...mergeTerm, end: v })}
|
|
477
|
+
/>
|
|
478
|
+
<NumberInput
|
|
479
|
+
label="Months"
|
|
480
|
+
value={mergeTerm.months}
|
|
481
|
+
onChange={(v) => {
|
|
482
|
+
const months = v ? Number(v) : null
|
|
483
|
+
const start = mergeTerm.start || todayIso()
|
|
484
|
+
const end = months ? addMonthsToIso(start, months) : mergeTerm.end
|
|
485
|
+
setMergeTerm({ ...mergeTerm, months: v, start, end })
|
|
486
|
+
}}
|
|
487
|
+
/>
|
|
488
|
+
</div>
|
|
489
|
+
<div className="grid grid-cols-2 gap-3">
|
|
490
|
+
<TextInput
|
|
491
|
+
label="New contract code (optional — auto-generated if blank)"
|
|
492
|
+
value={mergeTerm.code}
|
|
493
|
+
onChange={(v) => setMergeTerm({ ...mergeTerm, code: v })}
|
|
494
|
+
/>
|
|
495
|
+
<TextInput
|
|
496
|
+
label="New contract name (optional)"
|
|
497
|
+
value={mergeTerm.name}
|
|
498
|
+
onChange={(v) => setMergeTerm({ ...mergeTerm, name: v })}
|
|
499
|
+
/>
|
|
500
|
+
</div>
|
|
501
|
+
</div>
|
|
502
|
+
)}
|
|
503
|
+
|
|
504
|
+
{step === 'config-cancel' && type === 'cancel' && (
|
|
505
|
+
<div className="space-y-3">
|
|
506
|
+
<p className="text-sm">Reason for cancellation:</p>
|
|
507
|
+
<div className="space-y-2">
|
|
508
|
+
<label className="block text-xs text-muted-foreground">Reason code</label>
|
|
509
|
+
<select
|
|
510
|
+
value={cancelMeta.reasonCode}
|
|
511
|
+
onChange={(e) => setCancelMeta({ ...cancelMeta, reasonCode: e.target.value })}
|
|
512
|
+
className="w-full rounded-md border border-input bg-background px-2 py-1.5 text-sm"
|
|
513
|
+
>
|
|
514
|
+
<option value="">— pick one —</option>
|
|
515
|
+
{REASON_CODES.map((r) => (
|
|
516
|
+
<option key={r.value} value={r.value}>
|
|
517
|
+
{r.label}
|
|
518
|
+
</option>
|
|
519
|
+
))}
|
|
520
|
+
</select>
|
|
521
|
+
</div>
|
|
522
|
+
<TextInput
|
|
523
|
+
label="Free text (optional)"
|
|
524
|
+
value={cancelMeta.reasonText}
|
|
525
|
+
onChange={(v) => setCancelMeta({ ...cancelMeta, reasonText: v })}
|
|
526
|
+
/>
|
|
527
|
+
<div className="grid grid-cols-2 gap-3">
|
|
528
|
+
<TextInput
|
|
529
|
+
label="ETF amount (optional)"
|
|
530
|
+
value={cancelMeta.etfAmount}
|
|
531
|
+
onChange={(v) => setCancelMeta({ ...cancelMeta, etfAmount: v })}
|
|
532
|
+
/>
|
|
533
|
+
<TextInput
|
|
534
|
+
label="ETF currency"
|
|
535
|
+
value={cancelMeta.etfCurrency}
|
|
536
|
+
onChange={(v) => setCancelMeta({ ...cancelMeta, etfCurrency: v })}
|
|
537
|
+
/>
|
|
538
|
+
</div>
|
|
539
|
+
</div>
|
|
540
|
+
)}
|
|
541
|
+
|
|
542
|
+
{step === 'review' && (
|
|
543
|
+
<div className="space-y-3">
|
|
544
|
+
<p className="text-sm">Review and submit:</p>
|
|
545
|
+
<ul className="text-sm space-y-1 list-disc pl-5">
|
|
546
|
+
<li>Action: {type}</li>
|
|
547
|
+
<li>Targets: {pickedList.length}</li>
|
|
548
|
+
{pickedList.map((s) => (
|
|
549
|
+
<li key={s.id} className="text-muted-foreground">
|
|
550
|
+
{s.code} — {s.name}
|
|
551
|
+
</li>
|
|
552
|
+
))}
|
|
553
|
+
{type === 'renew' && !isMergeRenew && (
|
|
554
|
+
<li>
|
|
555
|
+
Term: {singleTerm.start} → {singleTerm.end}
|
|
556
|
+
{singleTerm.months ? ` (${singleTerm.months}m)` : ''}
|
|
557
|
+
</li>
|
|
558
|
+
)}
|
|
559
|
+
{type === 'renew' && isMergeRenew && (
|
|
560
|
+
<li>
|
|
561
|
+
Merge term: {mergeTerm.start} → {mergeTerm.end}
|
|
562
|
+
{mergeTerm.code ? ` • code=${mergeTerm.code}` : ''}
|
|
563
|
+
{mergeTerm.name ? ` • name=${mergeTerm.name}` : ''}
|
|
564
|
+
</li>
|
|
565
|
+
)}
|
|
566
|
+
{type === 'cancel' && (
|
|
567
|
+
<li>
|
|
568
|
+
Reason: {cancelMeta.reasonCode}
|
|
569
|
+
{cancelMeta.etfAmount
|
|
570
|
+
? ` • ETF ${cancelMeta.etfAmount} ${cancelMeta.etfCurrency}`
|
|
571
|
+
: ''}
|
|
572
|
+
</li>
|
|
573
|
+
)}
|
|
574
|
+
</ul>
|
|
575
|
+
<Alert variant="warning" className="text-xs">
|
|
576
|
+
Submitting locks the quote type. Lines will be edited on the host page after this completes.
|
|
577
|
+
</Alert>
|
|
578
|
+
{submitError && (
|
|
579
|
+
<Alert variant="destructive" className="text-xs">{submitError}</Alert>
|
|
580
|
+
)}
|
|
581
|
+
</div>
|
|
582
|
+
)}
|
|
583
|
+
|
|
584
|
+
{step === 'submitting' && (
|
|
585
|
+
<div className="text-sm text-muted-foreground">Submitting…</div>
|
|
586
|
+
)}
|
|
587
|
+
|
|
588
|
+
{step === 'done' && (
|
|
589
|
+
<div className="text-sm text-status-success-text">
|
|
590
|
+
Done — close to return to the quote.
|
|
591
|
+
</div>
|
|
592
|
+
)}
|
|
593
|
+
</div>
|
|
594
|
+
|
|
595
|
+
<footer className="border-t px-5 pt-3 pb-20 flex items-center justify-between">
|
|
596
|
+
<button
|
|
597
|
+
onClick={() => {
|
|
598
|
+
if (step === 'pick-action') return
|
|
599
|
+
if (step === 'pick-targets') {
|
|
600
|
+
setStep(initialType === 'new' ? 'pick-action' : 'pick-targets')
|
|
601
|
+
} else if (step === 'config-renew' || step === 'config-cancel') {
|
|
602
|
+
setStep('pick-targets')
|
|
603
|
+
} else if (step === 'review') {
|
|
604
|
+
if (type === 'renew') setStep('config-renew')
|
|
605
|
+
else if (type === 'cancel') setStep('config-cancel')
|
|
606
|
+
else setStep('pick-targets')
|
|
607
|
+
}
|
|
608
|
+
}}
|
|
609
|
+
disabled={
|
|
610
|
+
step === 'pick-action' ||
|
|
611
|
+
step === 'submitting' ||
|
|
612
|
+
step === 'done' ||
|
|
613
|
+
(step === 'pick-targets' && initialType !== 'new')
|
|
614
|
+
}
|
|
615
|
+
className="text-sm text-muted-foreground hover:text-foreground disabled:opacity-30"
|
|
616
|
+
>
|
|
617
|
+
← Back
|
|
618
|
+
</button>
|
|
619
|
+
<div className="flex gap-2">
|
|
620
|
+
<button
|
|
621
|
+
onClick={onClose}
|
|
622
|
+
className="rounded-md border border-input px-3 py-1.5 text-sm hover:bg-muted"
|
|
623
|
+
>
|
|
624
|
+
Cancel
|
|
625
|
+
</button>
|
|
626
|
+
{step === 'pick-targets' && (
|
|
627
|
+
<button
|
|
628
|
+
disabled={!canProceedFromTargets || !editable}
|
|
629
|
+
onClick={() => {
|
|
630
|
+
if (type === 'renew') setStep('config-renew')
|
|
631
|
+
else if (type === 'cancel') setStep('config-cancel')
|
|
632
|
+
else setStep('review')
|
|
633
|
+
}}
|
|
634
|
+
className="rounded-md bg-primary px-3 py-1.5 text-sm text-primary-foreground hover:bg-primary/90 disabled:opacity-50"
|
|
635
|
+
>
|
|
636
|
+
Next
|
|
637
|
+
</button>
|
|
638
|
+
)}
|
|
639
|
+
{(step === 'config-renew' || step === 'config-cancel') && (
|
|
640
|
+
<button
|
|
641
|
+
disabled={
|
|
642
|
+
(step === 'config-renew' && !canProceedFromRenew) ||
|
|
643
|
+
(step === 'config-cancel' && !canProceedFromCancel)
|
|
644
|
+
}
|
|
645
|
+
onClick={() => setStep('review')}
|
|
646
|
+
className="rounded-md bg-primary px-3 py-1.5 text-sm text-primary-foreground hover:bg-primary/90 disabled:opacity-50"
|
|
647
|
+
>
|
|
648
|
+
Next
|
|
649
|
+
</button>
|
|
650
|
+
)}
|
|
651
|
+
{step === 'review' && (
|
|
652
|
+
<button
|
|
653
|
+
disabled={!editable}
|
|
654
|
+
onClick={submit}
|
|
655
|
+
className="rounded-md bg-primary px-3 py-1.5 text-sm text-primary-foreground hover:bg-primary/90 disabled:opacity-50"
|
|
656
|
+
>
|
|
657
|
+
Submit
|
|
658
|
+
</button>
|
|
659
|
+
)}
|
|
660
|
+
{step === 'done' && (
|
|
661
|
+
<button
|
|
662
|
+
onClick={onClose}
|
|
663
|
+
className="rounded-md bg-primary px-3 py-1.5 text-sm text-primary-foreground hover:bg-primary/90"
|
|
664
|
+
>
|
|
665
|
+
Close
|
|
666
|
+
</button>
|
|
667
|
+
)}
|
|
668
|
+
</div>
|
|
669
|
+
</footer>
|
|
670
|
+
</div>
|
|
671
|
+
</div>
|
|
672
|
+
)
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
function DateInput(props: { label: string; value: string; onChange: (v: string) => void }) {
|
|
676
|
+
return (
|
|
677
|
+
<div>
|
|
678
|
+
<label className="block text-xs text-muted-foreground mb-1">{props.label}</label>
|
|
679
|
+
<input
|
|
680
|
+
type="date"
|
|
681
|
+
value={props.value}
|
|
682
|
+
onChange={(e) => props.onChange(e.target.value)}
|
|
683
|
+
className="w-full rounded-md border border-input bg-background px-2 py-1.5 text-sm"
|
|
684
|
+
/>
|
|
685
|
+
</div>
|
|
686
|
+
)
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
// Local "labelled number" wrapper kept as a string-in/string-out facade so
|
|
690
|
+
// the surrounding code (which threads `value` through `mergeTerm.months` as
|
|
691
|
+
// a string) doesn't have to change. The actual input behaviour comes from
|
|
692
|
+
// the shared `NumberInput` component (select-on-focus + internal string
|
|
693
|
+
// state — see components/NumberInput.tsx for the rationale).
|
|
694
|
+
function NumberInput(props: { label: string; value: string; onChange: (v: string) => void }) {
|
|
695
|
+
return (
|
|
696
|
+
<div>
|
|
697
|
+
<label className="block text-xs text-muted-foreground mb-1">{props.label}</label>
|
|
698
|
+
<BaseNumberInput
|
|
699
|
+
integer
|
|
700
|
+
min={1}
|
|
701
|
+
value={props.value === '' ? null : Number(props.value)}
|
|
702
|
+
onChange={(n) => props.onChange(n == null ? '' : String(n))}
|
|
703
|
+
/>
|
|
704
|
+
</div>
|
|
705
|
+
)
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
function TextInput(props: { label: string; value: string; onChange: (v: string) => void }) {
|
|
709
|
+
return (
|
|
710
|
+
<div>
|
|
711
|
+
<label className="block text-xs text-muted-foreground mb-1">{props.label}</label>
|
|
712
|
+
<input
|
|
713
|
+
type="text"
|
|
714
|
+
value={props.value}
|
|
715
|
+
onChange={(e) => props.onChange(e.target.value)}
|
|
716
|
+
className="w-full rounded-md border border-input bg-background px-2 py-1.5 text-sm"
|
|
717
|
+
/>
|
|
718
|
+
</div>
|
|
719
|
+
)
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
// Add `months` whole calendar months to an ISO date string (YYYY-MM-DD) and
|
|
723
|
+
// return the result in the same format. Used by the renew config step so the
|
|
724
|
+
// operator can edit just the months field and have the end date auto-update.
|
|
725
|
+
function addMonthsToIso(iso: string, months: number): string {
|
|
726
|
+
if (!iso) return iso
|
|
727
|
+
const d = new Date(iso)
|
|
728
|
+
if (Number.isNaN(d.getTime())) return iso
|
|
729
|
+
d.setMonth(d.getMonth() + months)
|
|
730
|
+
return d.toISOString().split('T')[0]
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
// Today as YYYY-MM-DD — used as the default `Start` when the operator types
|
|
734
|
+
// a `Months` value first on a brand-new merge contract.
|
|
735
|
+
function todayIso(): string {
|
|
736
|
+
return new Date().toISOString().split('T')[0]
|
|
737
|
+
}
|