@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,1399 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
5
|
+
import { useParams, useRouter } from "next/navigation";
|
|
6
|
+
import { Tag } from "@open-mercato/ui/primitives/tag";
|
|
7
|
+
import { Alert } from "@open-mercato/ui/primitives/alert";
|
|
8
|
+
import { Button } from "@open-mercato/ui/primitives/button";
|
|
9
|
+
import { NumberInput } from "../../../../components/NumberInput.js";
|
|
10
|
+
import {
|
|
11
|
+
formatStatusLabel,
|
|
12
|
+
lifecycleStatusMap,
|
|
13
|
+
specificationLifecycleStatusMap
|
|
14
|
+
} from "../../../../components/statusMaps.js";
|
|
15
|
+
import { DependsOnRulesEditor } from "./DependsOnRulesEditor.js";
|
|
16
|
+
const EMPTY_SPEC = {
|
|
17
|
+
code: "",
|
|
18
|
+
name: "",
|
|
19
|
+
description: "",
|
|
20
|
+
specType: "simple",
|
|
21
|
+
isAssetizable: false,
|
|
22
|
+
lifecycleStatus: "draft",
|
|
23
|
+
version: 1,
|
|
24
|
+
effectiveFrom: null,
|
|
25
|
+
effectiveTo: null,
|
|
26
|
+
isActive: true
|
|
27
|
+
};
|
|
28
|
+
const EMPTY_SLOT = {
|
|
29
|
+
targetSpecId: "",
|
|
30
|
+
componentGroup: "",
|
|
31
|
+
name: "",
|
|
32
|
+
description: "",
|
|
33
|
+
cardinalityMin: 0,
|
|
34
|
+
cardinalityMax: null,
|
|
35
|
+
sortOrder: 0
|
|
36
|
+
};
|
|
37
|
+
const EMPTY_ATTRIBUTE = {
|
|
38
|
+
code: "",
|
|
39
|
+
name: "",
|
|
40
|
+
attributeType: "text",
|
|
41
|
+
resolutionTime: "run_time",
|
|
42
|
+
options: null,
|
|
43
|
+
constraints: null,
|
|
44
|
+
referenceEntity: null,
|
|
45
|
+
referenceFilter: null,
|
|
46
|
+
dependsOn: null,
|
|
47
|
+
defaultValue: null,
|
|
48
|
+
helpText: null,
|
|
49
|
+
sortOrder: 0,
|
|
50
|
+
isRequired: true,
|
|
51
|
+
isActive: true
|
|
52
|
+
};
|
|
53
|
+
const EMPTY_OFFERING = {
|
|
54
|
+
code: "",
|
|
55
|
+
name: "",
|
|
56
|
+
description: null,
|
|
57
|
+
offeringType: "simple",
|
|
58
|
+
designTimeValues: {},
|
|
59
|
+
lifecycleStatus: "draft",
|
|
60
|
+
isActive: true
|
|
61
|
+
};
|
|
62
|
+
const EMPTY_CHARGE = {
|
|
63
|
+
code: "",
|
|
64
|
+
name: "",
|
|
65
|
+
description: null,
|
|
66
|
+
chargeType: "mrc",
|
|
67
|
+
pricingMethod: "flat",
|
|
68
|
+
pricingTableId: null,
|
|
69
|
+
priceColumnKey: null,
|
|
70
|
+
fixedPrice: null,
|
|
71
|
+
currencyCode: null,
|
|
72
|
+
quantityAttributeCode: null,
|
|
73
|
+
applicabilityCondition: null,
|
|
74
|
+
sortOrder: 0,
|
|
75
|
+
isActive: true
|
|
76
|
+
};
|
|
77
|
+
const EMPTY_RELATIONSHIP = {
|
|
78
|
+
sourceSpecId: "",
|
|
79
|
+
targetSpecId: "",
|
|
80
|
+
relationshipType: "requires",
|
|
81
|
+
cardinalityMin: 0,
|
|
82
|
+
cardinalityMax: null,
|
|
83
|
+
condition: null,
|
|
84
|
+
isActive: true
|
|
85
|
+
};
|
|
86
|
+
function SpecificationDetailPage(props) {
|
|
87
|
+
const t = useT();
|
|
88
|
+
const router = useRouter();
|
|
89
|
+
const urlParams = useParams();
|
|
90
|
+
const specId = props.params?.id ?? urlParams?.id;
|
|
91
|
+
const isNew = specId === "new";
|
|
92
|
+
const [tab, setTab] = React.useState("general");
|
|
93
|
+
const [form, setForm] = React.useState(EMPTY_SPEC);
|
|
94
|
+
const [attributes, setAttributes] = React.useState([]);
|
|
95
|
+
const [offerings, setOfferings] = React.useState([]);
|
|
96
|
+
const [relationships, setRelationships] = React.useState([]);
|
|
97
|
+
const [bundleSlots, setBundleSlots] = React.useState([]);
|
|
98
|
+
const [allSpecs, setAllSpecs] = React.useState([]);
|
|
99
|
+
const [loading, setLoading] = React.useState(!isNew);
|
|
100
|
+
const [saving, setSaving] = React.useState(false);
|
|
101
|
+
const [error, setError] = React.useState(null);
|
|
102
|
+
const [editingAttr, setEditingAttr] = React.useState(null);
|
|
103
|
+
const [editingOffering, setEditingOffering] = React.useState(null);
|
|
104
|
+
const [editingRel, setEditingRel] = React.useState(null);
|
|
105
|
+
const [editingSlot, setEditingSlot] = React.useState(null);
|
|
106
|
+
const [editingOptions, setEditingOptions] = React.useState([]);
|
|
107
|
+
const [editingDtValues, setEditingDtValues] = React.useState({});
|
|
108
|
+
const [selectedOfferingIds, setSelectedOfferingIds] = React.useState(/* @__PURE__ */ new Set());
|
|
109
|
+
const [offeringCharges, setOfferingCharges] = React.useState({});
|
|
110
|
+
const [chargeFormOpen, setChargeFormOpen] = React.useState(false);
|
|
111
|
+
const [chargeForm, setChargeForm] = React.useState({ code: "", name: "", description: "", chargeType: "mrc", pricingMethod: "flat" });
|
|
112
|
+
const [chargePrices, setChargePrices] = React.useState({});
|
|
113
|
+
const [chargePricingTableId, setChargePricingTableId] = React.useState(null);
|
|
114
|
+
const [chargePriceColumnKey, setChargePriceColumnKey] = React.useState(null);
|
|
115
|
+
const [chargeCurrency, setChargeCurrency] = React.useState("USD");
|
|
116
|
+
const [pricingTables, setPricingTables] = React.useState([]);
|
|
117
|
+
const [conditionJson, setConditionJson] = React.useState("null");
|
|
118
|
+
const [dependsOnAttrCode, setDependsOnAttrCode] = React.useState("");
|
|
119
|
+
const [dependsOnEffect, setDependsOnEffect] = React.useState("filter_options");
|
|
120
|
+
const [dependsOnEnabled, setDependsOnEnabled] = React.useState(false);
|
|
121
|
+
const [dependsOnRules, setDependsOnRules] = React.useState([]);
|
|
122
|
+
const [generalMode, setGeneralMode] = React.useState(isNew ? "edit" : "view");
|
|
123
|
+
const [formSnapshot, setFormSnapshot] = React.useState(null);
|
|
124
|
+
React.useEffect(() => {
|
|
125
|
+
let cancelled = false;
|
|
126
|
+
async function load() {
|
|
127
|
+
try {
|
|
128
|
+
if (isNew) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const specsRes = await fetch("/api/cpq/product-specifications?pageSize=200");
|
|
132
|
+
if (specsRes.ok) {
|
|
133
|
+
const d = await specsRes.json();
|
|
134
|
+
if (!cancelled) setAllSpecs(d.items ?? []);
|
|
135
|
+
}
|
|
136
|
+
const res = await fetch(`/api/cpq/product-specifications?id=${encodeURIComponent(specId)}`);
|
|
137
|
+
if (!res.ok) {
|
|
138
|
+
if (!cancelled) setError("Failed to load specification");
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const spec = await res.json();
|
|
142
|
+
if (!cancelled) {
|
|
143
|
+
setForm({
|
|
144
|
+
code: spec.code,
|
|
145
|
+
name: spec.name,
|
|
146
|
+
description: spec.description ?? "",
|
|
147
|
+
specType: spec.specType ?? "simple",
|
|
148
|
+
isAssetizable: spec.isAssetizable ?? false,
|
|
149
|
+
lifecycleStatus: spec.lifecycleStatus,
|
|
150
|
+
version: spec.version,
|
|
151
|
+
effectiveFrom: spec.effectiveFrom,
|
|
152
|
+
effectiveTo: spec.effectiveTo,
|
|
153
|
+
isActive: spec.isActive
|
|
154
|
+
});
|
|
155
|
+
setAttributes(spec.attributes ?? []);
|
|
156
|
+
setOfferings(spec.offerings ?? []);
|
|
157
|
+
setRelationships(spec.relationships ?? []);
|
|
158
|
+
setBundleSlots(spec.slots ?? []);
|
|
159
|
+
}
|
|
160
|
+
} catch (err) {
|
|
161
|
+
console.error("Failed to load", err);
|
|
162
|
+
if (!cancelled) setError("Failed to load");
|
|
163
|
+
} finally {
|
|
164
|
+
if (!cancelled) setLoading(false);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
load();
|
|
168
|
+
return () => {
|
|
169
|
+
cancelled = true;
|
|
170
|
+
};
|
|
171
|
+
}, [specId, isNew]);
|
|
172
|
+
const saveSpec = async () => {
|
|
173
|
+
setSaving(true);
|
|
174
|
+
setError(null);
|
|
175
|
+
try {
|
|
176
|
+
const { ...formData } = form;
|
|
177
|
+
const payload = isNew ? { ...formData, description: formData.description || null } : { id: specId, ...formData, description: formData.description || null };
|
|
178
|
+
const res = await fetch("/api/cpq/product-specifications", {
|
|
179
|
+
method: isNew ? "POST" : "PUT",
|
|
180
|
+
headers: { "Content-Type": "application/json" },
|
|
181
|
+
body: JSON.stringify(payload)
|
|
182
|
+
});
|
|
183
|
+
if (!res.ok) {
|
|
184
|
+
const d = await res.json();
|
|
185
|
+
setError(d.error ?? "Failed to save");
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const saved = await res.json();
|
|
189
|
+
if (isNew) {
|
|
190
|
+
router.push(`/backend/cpq/specifications/${saved.id}`);
|
|
191
|
+
} else {
|
|
192
|
+
setForm({
|
|
193
|
+
code: saved.code,
|
|
194
|
+
name: saved.name,
|
|
195
|
+
description: saved.description ?? "",
|
|
196
|
+
specType: saved.specType ?? form.specType,
|
|
197
|
+
isAssetizable: saved.isAssetizable ?? form.isAssetizable,
|
|
198
|
+
lifecycleStatus: saved.lifecycleStatus,
|
|
199
|
+
version: saved.version,
|
|
200
|
+
effectiveFrom: saved.effectiveFrom,
|
|
201
|
+
effectiveTo: saved.effectiveTo,
|
|
202
|
+
isActive: saved.isActive
|
|
203
|
+
});
|
|
204
|
+
setFormSnapshot(null);
|
|
205
|
+
setGeneralMode("view");
|
|
206
|
+
}
|
|
207
|
+
} catch {
|
|
208
|
+
setError("Failed to save");
|
|
209
|
+
} finally {
|
|
210
|
+
setSaving(false);
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
const deleteSpec = async () => {
|
|
214
|
+
if (!confirm(t("cpq.specifications.confirmDelete", "Delete this specification and all its offerings, attributes and relationships?"))) return;
|
|
215
|
+
try {
|
|
216
|
+
const res = await fetch("/api/cpq/product-specifications", {
|
|
217
|
+
method: "DELETE",
|
|
218
|
+
headers: { "Content-Type": "application/json" },
|
|
219
|
+
body: JSON.stringify({ id: specId })
|
|
220
|
+
});
|
|
221
|
+
if (res.ok) {
|
|
222
|
+
router.push("/backend/cpq/specifications");
|
|
223
|
+
} else {
|
|
224
|
+
const d = await res.json();
|
|
225
|
+
setError(d.error ?? "Failed to delete");
|
|
226
|
+
}
|
|
227
|
+
} catch {
|
|
228
|
+
setError("Failed to delete");
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
const saveAttribute = async () => {
|
|
232
|
+
if (!editingAttr) return;
|
|
233
|
+
setSaving(true);
|
|
234
|
+
setError(null);
|
|
235
|
+
try {
|
|
236
|
+
const options = editingAttr.attributeType === "select" || editingAttr.attributeType === "multi-select" ? editingOptions.filter((o) => o.value.trim() !== "") : null;
|
|
237
|
+
const dependsOn = dependsOnEnabled && dependsOnAttrCode ? {
|
|
238
|
+
attributeCode: dependsOnAttrCode,
|
|
239
|
+
effect: dependsOnEffect,
|
|
240
|
+
rules: dependsOnRules.filter((r) => r.when.trim().length > 0)
|
|
241
|
+
} : null;
|
|
242
|
+
const isEdit = !!editingAttr.id;
|
|
243
|
+
const payload = {
|
|
244
|
+
...editingAttr,
|
|
245
|
+
options,
|
|
246
|
+
dependsOn,
|
|
247
|
+
specId
|
|
248
|
+
};
|
|
249
|
+
const res = await fetch("/api/cpq/product-attributes", {
|
|
250
|
+
method: isEdit ? "PUT" : "POST",
|
|
251
|
+
headers: { "Content-Type": "application/json" },
|
|
252
|
+
body: JSON.stringify(payload)
|
|
253
|
+
});
|
|
254
|
+
if (!res.ok) {
|
|
255
|
+
const d = await res.json();
|
|
256
|
+
setError(d.error ?? "Failed to save attribute");
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
const saved = await res.json();
|
|
260
|
+
if (isEdit) {
|
|
261
|
+
setAttributes((prev) => prev.map((a) => a.id === saved.id ? saved : a));
|
|
262
|
+
} else {
|
|
263
|
+
setAttributes((prev) => [...prev, saved]);
|
|
264
|
+
}
|
|
265
|
+
setEditingAttr(null);
|
|
266
|
+
} catch {
|
|
267
|
+
setError("Failed to save attribute");
|
|
268
|
+
} finally {
|
|
269
|
+
setSaving(false);
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
const deleteAttribute = async (attrId) => {
|
|
273
|
+
if (!confirm("Delete this attribute?")) return;
|
|
274
|
+
try {
|
|
275
|
+
const res = await fetch("/api/cpq/product-attributes", {
|
|
276
|
+
method: "DELETE",
|
|
277
|
+
headers: { "Content-Type": "application/json" },
|
|
278
|
+
body: JSON.stringify({ id: attrId })
|
|
279
|
+
});
|
|
280
|
+
if (res.ok) setAttributes((prev) => prev.filter((a) => a.id !== attrId));
|
|
281
|
+
} catch {
|
|
282
|
+
setError("Failed to delete attribute");
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
const startEditAttr = (attr) => {
|
|
286
|
+
const editing = attr ? { ...attr } : { ...EMPTY_ATTRIBUTE };
|
|
287
|
+
if (editing.attributeType === "enum") editing.attributeType = "select";
|
|
288
|
+
setEditingAttr(editing);
|
|
289
|
+
setEditingOptions(editing.options ? [...editing.options] : []);
|
|
290
|
+
const dep = editing.dependsOn;
|
|
291
|
+
setDependsOnEnabled(!!dep);
|
|
292
|
+
setDependsOnAttrCode(dep?.attributeCode ?? "");
|
|
293
|
+
setDependsOnEffect(dep?.effect ?? "filter_options");
|
|
294
|
+
setDependsOnRules(Array.isArray(dep?.rules) ? dep.rules : []);
|
|
295
|
+
};
|
|
296
|
+
const saveOffering = async () => {
|
|
297
|
+
if (!editingOffering) return;
|
|
298
|
+
setSaving(true);
|
|
299
|
+
setError(null);
|
|
300
|
+
try {
|
|
301
|
+
const isEdit = !!editingOffering.id;
|
|
302
|
+
const payload = {
|
|
303
|
+
...editingOffering,
|
|
304
|
+
designTimeValues: editingDtValues,
|
|
305
|
+
specId
|
|
306
|
+
};
|
|
307
|
+
const res = await fetch("/api/cpq/product-offerings", {
|
|
308
|
+
method: isEdit ? "PUT" : "POST",
|
|
309
|
+
headers: { "Content-Type": "application/json" },
|
|
310
|
+
body: JSON.stringify(payload)
|
|
311
|
+
});
|
|
312
|
+
if (!res.ok) {
|
|
313
|
+
const d = await res.json();
|
|
314
|
+
setError(d.error ?? "Failed to save offering");
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
const saved = await res.json();
|
|
318
|
+
if (isEdit) {
|
|
319
|
+
setOfferings((prev) => prev.map((o) => o.id === saved.id ? saved : o));
|
|
320
|
+
} else {
|
|
321
|
+
setOfferings((prev) => [...prev, saved]);
|
|
322
|
+
}
|
|
323
|
+
setEditingOffering(null);
|
|
324
|
+
} catch {
|
|
325
|
+
setError("Failed to save offering");
|
|
326
|
+
} finally {
|
|
327
|
+
setSaving(false);
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
const deleteOffering = async (offeringId) => {
|
|
331
|
+
if (!confirm("Delete this offering?")) return;
|
|
332
|
+
try {
|
|
333
|
+
const res = await fetch("/api/cpq/product-offerings", {
|
|
334
|
+
method: "DELETE",
|
|
335
|
+
headers: { "Content-Type": "application/json" },
|
|
336
|
+
body: JSON.stringify({ id: offeringId })
|
|
337
|
+
});
|
|
338
|
+
if (res.ok) setOfferings((prev) => prev.filter((o) => o.id !== offeringId));
|
|
339
|
+
} catch {
|
|
340
|
+
setError("Failed to delete offering");
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
const startEditOffering = (offering) => {
|
|
344
|
+
const editing = offering ? { ...offering } : { ...EMPTY_OFFERING };
|
|
345
|
+
setEditingOffering(editing);
|
|
346
|
+
setEditingDtValues(editing.designTimeValues ? { ...editing.designTimeValues } : {});
|
|
347
|
+
};
|
|
348
|
+
const loadAllOfferingCharges = async () => {
|
|
349
|
+
try {
|
|
350
|
+
const results = await Promise.all(
|
|
351
|
+
offerings.map((o) => fetch(`/api/cpq/product-offerings?id=${encodeURIComponent(o.id)}`).then((r) => r.ok ? r.json() : null))
|
|
352
|
+
);
|
|
353
|
+
const chargeMap = {};
|
|
354
|
+
results.forEach((data, idx) => {
|
|
355
|
+
if (data) chargeMap[offerings[idx].id] = data.charges ?? [];
|
|
356
|
+
});
|
|
357
|
+
setOfferingCharges(chargeMap);
|
|
358
|
+
} catch {
|
|
359
|
+
console.error("Failed to load charges");
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
const loadPricingTables = async () => {
|
|
363
|
+
if (pricingTables.length > 0) return;
|
|
364
|
+
const res = await fetch("/api/cpq/pricing-tables?pageSize=200");
|
|
365
|
+
if (res.ok) {
|
|
366
|
+
const data = await res.json();
|
|
367
|
+
setPricingTables(data.items ?? []);
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
const toggleOfferingSelection = (id) => {
|
|
371
|
+
setSelectedOfferingIds((prev) => {
|
|
372
|
+
const next = new Set(prev);
|
|
373
|
+
if (next.has(id)) next.delete(id);
|
|
374
|
+
else next.add(id);
|
|
375
|
+
return next;
|
|
376
|
+
});
|
|
377
|
+
};
|
|
378
|
+
const toggleAllOfferings = () => {
|
|
379
|
+
if (selectedOfferingIds.size === offerings.length) {
|
|
380
|
+
setSelectedOfferingIds(/* @__PURE__ */ new Set());
|
|
381
|
+
} else {
|
|
382
|
+
setSelectedOfferingIds(new Set(offerings.map((o) => o.id)));
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
const openChargeForm = () => {
|
|
386
|
+
setChargeForm({ code: "", name: "", description: "", chargeType: "mrc", pricingMethod: "flat" });
|
|
387
|
+
setChargePrices({});
|
|
388
|
+
setChargePricingTableId(null);
|
|
389
|
+
setChargePriceColumnKey(null);
|
|
390
|
+
setChargeCurrency("USD");
|
|
391
|
+
setChargeFormOpen(true);
|
|
392
|
+
loadPricingTables();
|
|
393
|
+
};
|
|
394
|
+
const saveChargesForSelected = async () => {
|
|
395
|
+
const targets = offerings.filter((o) => selectedOfferingIds.has(o.id));
|
|
396
|
+
if (!targets.length || !chargeForm.code || !chargeForm.name) return;
|
|
397
|
+
setSaving(true);
|
|
398
|
+
setError(null);
|
|
399
|
+
try {
|
|
400
|
+
for (const offering of targets) {
|
|
401
|
+
const chargeCode = targets.length > 1 ? `${offering.code}--${chargeForm.code}` : chargeForm.code;
|
|
402
|
+
const payload = {
|
|
403
|
+
offeringId: offering.id,
|
|
404
|
+
code: chargeCode,
|
|
405
|
+
name: chargeForm.name,
|
|
406
|
+
description: chargeForm.description || null,
|
|
407
|
+
chargeType: chargeForm.chargeType,
|
|
408
|
+
pricingMethod: chargeForm.pricingMethod === "flat" ? "flat" : chargeForm.pricingMethod,
|
|
409
|
+
isActive: true,
|
|
410
|
+
sortOrder: 0
|
|
411
|
+
};
|
|
412
|
+
if (chargeForm.pricingMethod === "flat") {
|
|
413
|
+
payload.fixedPrice = chargePrices[offering.id] || null;
|
|
414
|
+
payload.currencyCode = chargeCurrency;
|
|
415
|
+
} else {
|
|
416
|
+
payload.pricingTableId = chargePricingTableId;
|
|
417
|
+
payload.priceColumnKey = chargePriceColumnKey;
|
|
418
|
+
}
|
|
419
|
+
const res = await fetch("/api/cpq/product-charges", {
|
|
420
|
+
method: "POST",
|
|
421
|
+
headers: { "Content-Type": "application/json" },
|
|
422
|
+
body: JSON.stringify(payload)
|
|
423
|
+
});
|
|
424
|
+
if (!res.ok) {
|
|
425
|
+
const d = await res.json();
|
|
426
|
+
setError(d.error ?? `Failed to save charge for ${offering.name}`);
|
|
427
|
+
break;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
setChargeFormOpen(false);
|
|
431
|
+
await loadAllOfferingCharges();
|
|
432
|
+
} catch {
|
|
433
|
+
setError("Failed to save charges");
|
|
434
|
+
} finally {
|
|
435
|
+
setSaving(false);
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
const deleteCharge = async (offeringId, chargeId) => {
|
|
439
|
+
if (!confirm("Delete this charge?")) return;
|
|
440
|
+
try {
|
|
441
|
+
const res = await fetch("/api/cpq/product-charges", {
|
|
442
|
+
method: "DELETE",
|
|
443
|
+
headers: { "Content-Type": "application/json" },
|
|
444
|
+
body: JSON.stringify({ id: chargeId })
|
|
445
|
+
});
|
|
446
|
+
if (res.ok) {
|
|
447
|
+
setOfferingCharges((prev) => ({
|
|
448
|
+
...prev,
|
|
449
|
+
[offeringId]: (prev[offeringId] ?? []).filter((c) => c.id !== chargeId)
|
|
450
|
+
}));
|
|
451
|
+
}
|
|
452
|
+
} catch {
|
|
453
|
+
setError("Failed to delete charge");
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
const selectedPricingTableRef = chargePricingTableId ? pricingTables.find((pt) => pt.id === chargePricingTableId) : null;
|
|
457
|
+
const saveRelationship = async () => {
|
|
458
|
+
if (!editingRel) return;
|
|
459
|
+
setSaving(true);
|
|
460
|
+
setError(null);
|
|
461
|
+
try {
|
|
462
|
+
let parsedCondition = editingRel.condition;
|
|
463
|
+
try {
|
|
464
|
+
parsedCondition = conditionJson === "null" ? null : JSON.parse(conditionJson);
|
|
465
|
+
} catch {
|
|
466
|
+
}
|
|
467
|
+
const isEdit = !!editingRel.id;
|
|
468
|
+
const payload = {
|
|
469
|
+
...editingRel,
|
|
470
|
+
condition: parsedCondition,
|
|
471
|
+
sourceSpecId: editingRel.sourceSpecId || specId
|
|
472
|
+
};
|
|
473
|
+
const res = await fetch("/api/cpq/product-relationships", {
|
|
474
|
+
method: isEdit ? "PUT" : "POST",
|
|
475
|
+
headers: { "Content-Type": "application/json" },
|
|
476
|
+
body: JSON.stringify(payload)
|
|
477
|
+
});
|
|
478
|
+
if (!res.ok) {
|
|
479
|
+
const d = await res.json();
|
|
480
|
+
setError(d.error ?? "Failed to save relationship");
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
const saved = await res.json();
|
|
484
|
+
if (isEdit) {
|
|
485
|
+
setRelationships((prev) => prev.map((r) => r.id === saved.id ? saved : r));
|
|
486
|
+
} else {
|
|
487
|
+
setRelationships((prev) => [...prev, saved]);
|
|
488
|
+
}
|
|
489
|
+
setEditingRel(null);
|
|
490
|
+
} catch {
|
|
491
|
+
setError("Failed to save relationship");
|
|
492
|
+
} finally {
|
|
493
|
+
setSaving(false);
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
const deleteRelationship = async (relId) => {
|
|
497
|
+
if (!confirm("Delete this relationship?")) return;
|
|
498
|
+
try {
|
|
499
|
+
const res = await fetch("/api/cpq/product-relationships", {
|
|
500
|
+
method: "DELETE",
|
|
501
|
+
headers: { "Content-Type": "application/json" },
|
|
502
|
+
body: JSON.stringify({ id: relId })
|
|
503
|
+
});
|
|
504
|
+
if (res.ok) setRelationships((prev) => prev.filter((r) => r.id !== relId));
|
|
505
|
+
} catch {
|
|
506
|
+
setError("Failed to delete relationship");
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
const startEditRel = (rel) => {
|
|
510
|
+
const editing = rel ? { ...rel } : { ...EMPTY_RELATIONSHIP, sourceSpecId: specId };
|
|
511
|
+
setEditingRel(editing);
|
|
512
|
+
setConditionJson(editing.condition ? JSON.stringify(editing.condition, null, 2) : "null");
|
|
513
|
+
};
|
|
514
|
+
const getSpecName = (id) => allSpecs.find((s) => s.id === id)?.name ?? id.slice(0, 8);
|
|
515
|
+
if (loading) {
|
|
516
|
+
return /* @__PURE__ */ jsx("div", { className: "text-sm text-muted-foreground", children: t("common.loading", "Loading...") });
|
|
517
|
+
}
|
|
518
|
+
const designTimeAttrs = attributes.filter((a) => a.resolutionTime === "design_time");
|
|
519
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
|
|
520
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
521
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
522
|
+
/* @__PURE__ */ jsxs(
|
|
523
|
+
"button",
|
|
524
|
+
{
|
|
525
|
+
onClick: () => router.push("/backend/cpq/specifications"),
|
|
526
|
+
className: "text-sm text-muted-foreground hover:text-foreground",
|
|
527
|
+
children: [
|
|
528
|
+
"\u2190 ",
|
|
529
|
+
t("common.back", "Back")
|
|
530
|
+
]
|
|
531
|
+
}
|
|
532
|
+
),
|
|
533
|
+
/* @__PURE__ */ jsx("h1", { className: "text-2xl font-bold", children: isNew ? t("cpq.specifications.new", "New Specification") : form.name }),
|
|
534
|
+
!isNew && /* @__PURE__ */ jsx(Tag, { variant: specificationLifecycleStatusMap[form.lifecycleStatus] ?? "neutral", dot: true, children: formatStatusLabel(form.lifecycleStatus) })
|
|
535
|
+
] }),
|
|
536
|
+
!isNew && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
537
|
+
generalMode === "view" && tab === "general" && /* @__PURE__ */ jsx(
|
|
538
|
+
Button,
|
|
539
|
+
{
|
|
540
|
+
type: "button",
|
|
541
|
+
onClick: () => {
|
|
542
|
+
setFormSnapshot(form);
|
|
543
|
+
setGeneralMode("edit");
|
|
544
|
+
},
|
|
545
|
+
children: t("common.edit", "Edit")
|
|
546
|
+
}
|
|
547
|
+
),
|
|
548
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "destructive", onClick: deleteSpec, children: t("common.delete", "Delete") })
|
|
549
|
+
] })
|
|
550
|
+
] }),
|
|
551
|
+
error && /* @__PURE__ */ jsx(Alert, { variant: "destructive", children: error }),
|
|
552
|
+
!isNew && /* @__PURE__ */ jsx("div", { className: "flex gap-1 border-b", children: [
|
|
553
|
+
"general",
|
|
554
|
+
"attributes",
|
|
555
|
+
"offerings",
|
|
556
|
+
"relationships",
|
|
557
|
+
...form.specType === "bundle" ? ["slots"] : []
|
|
558
|
+
].map((t_) => /* @__PURE__ */ jsxs(
|
|
559
|
+
"button",
|
|
560
|
+
{
|
|
561
|
+
onClick: () => {
|
|
562
|
+
setTab(t_);
|
|
563
|
+
if (t_ === "offerings" && offerings.length > 0 && Object.keys(offeringCharges).length === 0) loadAllOfferingCharges();
|
|
564
|
+
},
|
|
565
|
+
className: `px-4 py-2 text-sm font-medium border-b-2 transition-colors ${tab === t_ ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground"}`,
|
|
566
|
+
children: [
|
|
567
|
+
t_ === "general" && "General",
|
|
568
|
+
t_ === "attributes" && `Attributes (${attributes.length})`,
|
|
569
|
+
t_ === "offerings" && `Offerings (${offerings.length})`,
|
|
570
|
+
t_ === "relationships" && `Relationships (${relationships.length})`,
|
|
571
|
+
t_ === "slots" && `Bundle Slots (${bundleSlots.length})`
|
|
572
|
+
]
|
|
573
|
+
},
|
|
574
|
+
t_
|
|
575
|
+
)) }),
|
|
576
|
+
(isNew || tab === "general") && (() => {
|
|
577
|
+
const isViewing = generalMode === "view" && !isNew;
|
|
578
|
+
const specTypeLocked = !isNew && (offerings.length > 0 || bundleSlots.length > 0);
|
|
579
|
+
return /* @__PURE__ */ jsxs("div", { className: "rounded-lg border bg-card p-6 space-y-4", children: [
|
|
580
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
581
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
582
|
+
/* @__PURE__ */ jsx("label", { className: "block text-sm font-medium mb-1", children: t("cpq.specifications.code", "Code") }),
|
|
583
|
+
isViewing ? /* @__PURE__ */ jsx("p", { className: "text-sm font-mono py-2", children: form.code || "\u2014" }) : /* @__PURE__ */ jsx(
|
|
584
|
+
"input",
|
|
585
|
+
{
|
|
586
|
+
type: "text",
|
|
587
|
+
value: form.code,
|
|
588
|
+
onChange: (e) => setForm({ ...form, code: e.target.value }),
|
|
589
|
+
placeholder: "e.g. gix-access-port",
|
|
590
|
+
className: "w-full rounded-md border px-3 py-2 text-sm"
|
|
591
|
+
}
|
|
592
|
+
)
|
|
593
|
+
] }),
|
|
594
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
595
|
+
/* @__PURE__ */ jsx("label", { className: "block text-sm font-medium mb-1", children: t("cpq.specifications.name", "Name") }),
|
|
596
|
+
isViewing ? /* @__PURE__ */ jsx("p", { className: "text-sm py-2", children: form.name || "\u2014" }) : /* @__PURE__ */ jsx(
|
|
597
|
+
"input",
|
|
598
|
+
{
|
|
599
|
+
type: "text",
|
|
600
|
+
value: form.name,
|
|
601
|
+
onChange: (e) => setForm({ ...form, name: e.target.value }),
|
|
602
|
+
className: "w-full rounded-md border px-3 py-2 text-sm"
|
|
603
|
+
}
|
|
604
|
+
)
|
|
605
|
+
] }),
|
|
606
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
607
|
+
/* @__PURE__ */ jsx("label", { className: "block text-sm font-medium mb-1", children: t("cpq.specifications.lifecycleStatus", "Lifecycle Status") }),
|
|
608
|
+
isViewing ? /* @__PURE__ */ jsx("div", { className: "py-2", children: /* @__PURE__ */ jsx(Tag, { variant: specificationLifecycleStatusMap[form.lifecycleStatus] ?? "neutral", dot: true, children: formatStatusLabel(form.lifecycleStatus) }) }) : /* @__PURE__ */ jsxs(
|
|
609
|
+
"select",
|
|
610
|
+
{
|
|
611
|
+
value: form.lifecycleStatus,
|
|
612
|
+
onChange: (e) => setForm({ ...form, lifecycleStatus: e.target.value }),
|
|
613
|
+
className: "w-full rounded-md border px-3 py-2 text-sm",
|
|
614
|
+
children: [
|
|
615
|
+
/* @__PURE__ */ jsx("option", { value: "draft", children: "Draft" }),
|
|
616
|
+
/* @__PURE__ */ jsx("option", { value: "active", children: "Active" }),
|
|
617
|
+
/* @__PURE__ */ jsx("option", { value: "deprecated", children: "Deprecated" })
|
|
618
|
+
]
|
|
619
|
+
}
|
|
620
|
+
)
|
|
621
|
+
] }),
|
|
622
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
623
|
+
/* @__PURE__ */ jsx("label", { className: "block text-sm font-medium mb-1", children: t("cpq.specifications.isActive", "Is Active?") }),
|
|
624
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center h-[38px]", children: isViewing ? /* @__PURE__ */ jsx(Tag, { variant: form.isActive ? "success" : "neutral", dot: true, children: form.isActive ? t("common.yes", "Yes") : t("common.no", "No") }) : /* @__PURE__ */ jsx(
|
|
625
|
+
"input",
|
|
626
|
+
{
|
|
627
|
+
type: "checkbox",
|
|
628
|
+
checked: form.isActive,
|
|
629
|
+
onChange: (e) => setForm({ ...form, isActive: e.target.checked }),
|
|
630
|
+
className: "rounded border"
|
|
631
|
+
}
|
|
632
|
+
) })
|
|
633
|
+
] }),
|
|
634
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
635
|
+
/* @__PURE__ */ jsx("label", { className: "block text-sm font-medium mb-1", children: "Spec Type" }),
|
|
636
|
+
isViewing ? /* @__PURE__ */ jsx("p", { className: "text-sm py-2", children: form.specType === "bundle" ? "Bundle" : "Simple" }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
637
|
+
/* @__PURE__ */ jsxs(
|
|
638
|
+
"select",
|
|
639
|
+
{
|
|
640
|
+
value: form.specType,
|
|
641
|
+
onChange: (e) => setForm({ ...form, specType: e.target.value }),
|
|
642
|
+
disabled: specTypeLocked,
|
|
643
|
+
className: "w-full rounded-md border px-3 py-2 text-sm disabled:opacity-50",
|
|
644
|
+
children: [
|
|
645
|
+
/* @__PURE__ */ jsx("option", { value: "simple", children: "Simple" }),
|
|
646
|
+
/* @__PURE__ */ jsx("option", { value: "bundle", children: "Bundle" })
|
|
647
|
+
]
|
|
648
|
+
}
|
|
649
|
+
),
|
|
650
|
+
specTypeLocked && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mt-1", children: "Cannot change after offerings or slots exist" })
|
|
651
|
+
] })
|
|
652
|
+
] }),
|
|
653
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
654
|
+
/* @__PURE__ */ jsx("label", { className: "block text-sm font-medium mb-1", children: "Is Assetizable?" }),
|
|
655
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center h-[38px]", children: isViewing ? /* @__PURE__ */ jsx(Tag, { variant: form.isAssetizable ? "warning" : "neutral", dot: true, children: form.isAssetizable ? t("common.yes", "Yes") : t("common.no", "No") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
656
|
+
/* @__PURE__ */ jsx(
|
|
657
|
+
"input",
|
|
658
|
+
{
|
|
659
|
+
type: "checkbox",
|
|
660
|
+
checked: form.isAssetizable,
|
|
661
|
+
onChange: (e) => setForm({ ...form, isAssetizable: e.target.checked }),
|
|
662
|
+
className: "rounded border"
|
|
663
|
+
}
|
|
664
|
+
),
|
|
665
|
+
/* @__PURE__ */ jsx("span", { className: "ml-2 text-xs text-muted-foreground", children: "Creates asset records during fulfilment" })
|
|
666
|
+
] }) })
|
|
667
|
+
] })
|
|
668
|
+
] }),
|
|
669
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
670
|
+
/* @__PURE__ */ jsx("label", { className: "block text-sm font-medium mb-1", children: t("cpq.specifications.description", "Description") }),
|
|
671
|
+
isViewing ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground py-2 whitespace-pre-wrap", children: form.description || "\u2014" }) : /* @__PURE__ */ jsx(
|
|
672
|
+
"textarea",
|
|
673
|
+
{
|
|
674
|
+
value: form.description ?? "",
|
|
675
|
+
onChange: (e) => setForm({ ...form, description: e.target.value }),
|
|
676
|
+
rows: 3,
|
|
677
|
+
className: "w-full rounded-md border px-3 py-2 text-sm"
|
|
678
|
+
}
|
|
679
|
+
)
|
|
680
|
+
] }),
|
|
681
|
+
!isNew && /* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground", children: [
|
|
682
|
+
"Version ",
|
|
683
|
+
form.version
|
|
684
|
+
] }),
|
|
685
|
+
!isViewing && /* @__PURE__ */ jsxs("div", { className: "flex gap-3", children: [
|
|
686
|
+
/* @__PURE__ */ jsx(
|
|
687
|
+
Button,
|
|
688
|
+
{
|
|
689
|
+
type: "button",
|
|
690
|
+
onClick: saveSpec,
|
|
691
|
+
disabled: saving || !form.code || !form.name,
|
|
692
|
+
children: saving ? t("common.saving", "Saving...") : t("common.save", "Save")
|
|
693
|
+
}
|
|
694
|
+
),
|
|
695
|
+
/* @__PURE__ */ jsx(
|
|
696
|
+
Button,
|
|
697
|
+
{
|
|
698
|
+
type: "button",
|
|
699
|
+
variant: "outline",
|
|
700
|
+
onClick: () => {
|
|
701
|
+
if (isNew) {
|
|
702
|
+
router.push("/backend/cpq/specifications");
|
|
703
|
+
return;
|
|
704
|
+
}
|
|
705
|
+
if (formSnapshot) setForm(formSnapshot);
|
|
706
|
+
setFormSnapshot(null);
|
|
707
|
+
setGeneralMode("view");
|
|
708
|
+
},
|
|
709
|
+
children: t("common.cancel", "Cancel")
|
|
710
|
+
}
|
|
711
|
+
)
|
|
712
|
+
] })
|
|
713
|
+
] });
|
|
714
|
+
})(),
|
|
715
|
+
tab === "attributes" && !isNew && /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
716
|
+
/* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(
|
|
717
|
+
"button",
|
|
718
|
+
{
|
|
719
|
+
onClick: () => startEditAttr(),
|
|
720
|
+
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",
|
|
721
|
+
children: t("cpq.specifications.addAttribute", "Add Attribute")
|
|
722
|
+
}
|
|
723
|
+
) }),
|
|
724
|
+
editingAttr && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border bg-card p-4 space-y-3", children: [
|
|
725
|
+
/* @__PURE__ */ jsx("h3", { className: "font-medium text-sm", children: editingAttr.id ? "Edit Attribute" : "New Attribute" }),
|
|
726
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-3 gap-3", children: [
|
|
727
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
728
|
+
/* @__PURE__ */ jsx("label", { className: "block text-xs font-medium mb-1", children: "Code" }),
|
|
729
|
+
/* @__PURE__ */ jsx("input", { type: "text", value: editingAttr.code, onChange: (e) => setEditingAttr({ ...editingAttr, code: e.target.value }), className: "w-full rounded-md border px-2 py-1.5 text-sm" })
|
|
730
|
+
] }),
|
|
731
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
732
|
+
/* @__PURE__ */ jsx("label", { className: "block text-xs font-medium mb-1", children: "Name" }),
|
|
733
|
+
/* @__PURE__ */ jsx("input", { type: "text", value: editingAttr.name, onChange: (e) => setEditingAttr({ ...editingAttr, name: e.target.value }), className: "w-full rounded-md border px-2 py-1.5 text-sm" })
|
|
734
|
+
] }),
|
|
735
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
736
|
+
/* @__PURE__ */ jsx("label", { className: "block text-xs font-medium mb-1", children: "Type" }),
|
|
737
|
+
/* @__PURE__ */ jsxs("select", { value: editingAttr.attributeType, onChange: (e) => setEditingAttr({ ...editingAttr, attributeType: e.target.value }), className: "w-full rounded-md border px-2 py-1.5 text-sm", children: [
|
|
738
|
+
/* @__PURE__ */ jsx("option", { value: "text", children: "Text" }),
|
|
739
|
+
/* @__PURE__ */ jsx("option", { value: "number", children: "Number" }),
|
|
740
|
+
/* @__PURE__ */ jsx("option", { value: "boolean", children: "Boolean" }),
|
|
741
|
+
/* @__PURE__ */ jsx("option", { value: "select", children: "Select" }),
|
|
742
|
+
/* @__PURE__ */ jsx("option", { value: "multi-select", children: "Multi-Select" }),
|
|
743
|
+
/* @__PURE__ */ jsx("option", { value: "reference", children: "Reference" })
|
|
744
|
+
] })
|
|
745
|
+
] }),
|
|
746
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
747
|
+
/* @__PURE__ */ jsx("label", { className: "block text-xs font-medium mb-1", children: "Resolution Time" }),
|
|
748
|
+
/* @__PURE__ */ jsxs("select", { value: editingAttr.resolutionTime, onChange: (e) => setEditingAttr({ ...editingAttr, resolutionTime: e.target.value }), className: "w-full rounded-md border px-2 py-1.5 text-sm", children: [
|
|
749
|
+
/* @__PURE__ */ jsx("option", { value: "run_time", children: "Run-time (quoting)" }),
|
|
750
|
+
/* @__PURE__ */ jsx("option", { value: "design_time", children: "Design-time (offering)" })
|
|
751
|
+
] })
|
|
752
|
+
] }),
|
|
753
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
754
|
+
/* @__PURE__ */ jsx("label", { className: "block text-xs font-medium mb-1", children: "Sort Order" }),
|
|
755
|
+
/* @__PURE__ */ jsx(
|
|
756
|
+
NumberInput,
|
|
757
|
+
{
|
|
758
|
+
integer: true,
|
|
759
|
+
value: editingAttr.sortOrder,
|
|
760
|
+
onChange: (n) => setEditingAttr({ ...editingAttr, sortOrder: n ?? 0 })
|
|
761
|
+
}
|
|
762
|
+
)
|
|
763
|
+
] }),
|
|
764
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
765
|
+
/* @__PURE__ */ jsx("label", { className: "block text-xs font-medium mb-1", children: "Help Text" }),
|
|
766
|
+
/* @__PURE__ */ jsx("input", { type: "text", value: editingAttr.helpText ?? "", onChange: (e) => setEditingAttr({ ...editingAttr, helpText: e.target.value || null }), className: "w-full rounded-md border px-2 py-1.5 text-sm" })
|
|
767
|
+
] }),
|
|
768
|
+
editingAttr.attributeType === "reference" && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { children: [
|
|
769
|
+
/* @__PURE__ */ jsx("label", { className: "block text-xs font-medium mb-1", children: "Reference Entity" }),
|
|
770
|
+
/* @__PURE__ */ jsx("input", { type: "text", value: editingAttr.referenceEntity ?? "", onChange: (e) => setEditingAttr({ ...editingAttr, referenceEntity: e.target.value || null }), placeholder: "e.g. CatalogProduct", className: "w-full rounded-md border px-2 py-1.5 text-sm" })
|
|
771
|
+
] }) }),
|
|
772
|
+
(editingAttr.attributeType === "select" || editingAttr.attributeType === "multi-select") && /* @__PURE__ */ jsxs("div", { className: "col-span-3 space-y-2", children: [
|
|
773
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
774
|
+
/* @__PURE__ */ jsx("label", { className: "block text-xs font-medium", children: "Options" }),
|
|
775
|
+
/* @__PURE__ */ jsx(
|
|
776
|
+
"button",
|
|
777
|
+
{
|
|
778
|
+
type: "button",
|
|
779
|
+
onClick: () => setEditingOptions([...editingOptions, { value: "", label: "" }]),
|
|
780
|
+
className: "text-xs text-primary hover:underline",
|
|
781
|
+
children: "+ Add option"
|
|
782
|
+
}
|
|
783
|
+
)
|
|
784
|
+
] }),
|
|
785
|
+
editingOptions.length === 0 ? /* @__PURE__ */ jsx("div", { className: "text-xs text-muted-foreground py-2", children: 'No options defined. Click "Add option" to start.' }) : /* @__PURE__ */ jsx("div", { className: "space-y-1.5", children: editingOptions.map((opt, idx) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
786
|
+
/* @__PURE__ */ jsx(
|
|
787
|
+
"input",
|
|
788
|
+
{
|
|
789
|
+
type: "text",
|
|
790
|
+
value: opt.value,
|
|
791
|
+
onChange: (e) => {
|
|
792
|
+
const next = [...editingOptions];
|
|
793
|
+
next[idx] = { ...next[idx], value: e.target.value };
|
|
794
|
+
setEditingOptions(next);
|
|
795
|
+
},
|
|
796
|
+
placeholder: "Value (e.g. aws)",
|
|
797
|
+
className: "flex-1 rounded-md border px-2 py-1.5 text-sm"
|
|
798
|
+
}
|
|
799
|
+
),
|
|
800
|
+
/* @__PURE__ */ jsx(
|
|
801
|
+
"input",
|
|
802
|
+
{
|
|
803
|
+
type: "text",
|
|
804
|
+
value: opt.label,
|
|
805
|
+
onChange: (e) => {
|
|
806
|
+
const next = [...editingOptions];
|
|
807
|
+
next[idx] = { ...next[idx], label: e.target.value };
|
|
808
|
+
setEditingOptions(next);
|
|
809
|
+
},
|
|
810
|
+
placeholder: "Label (e.g. Amazon Web Services)",
|
|
811
|
+
className: "flex-1 rounded-md border px-2 py-1.5 text-sm"
|
|
812
|
+
}
|
|
813
|
+
),
|
|
814
|
+
/* @__PURE__ */ jsx(
|
|
815
|
+
"button",
|
|
816
|
+
{
|
|
817
|
+
type: "button",
|
|
818
|
+
onClick: () => setEditingOptions(editingOptions.filter((_, i) => i !== idx)),
|
|
819
|
+
className: "text-destructive hover:text-destructive/80 text-sm px-1",
|
|
820
|
+
title: "Remove",
|
|
821
|
+
children: "\xD7"
|
|
822
|
+
}
|
|
823
|
+
)
|
|
824
|
+
] }, idx)) })
|
|
825
|
+
] }),
|
|
826
|
+
/* @__PURE__ */ jsxs("div", { className: "col-span-3 space-y-2", children: [
|
|
827
|
+
/* @__PURE__ */ jsxs("label", { className: "flex items-center gap-1.5 text-xs font-medium", children: [
|
|
828
|
+
/* @__PURE__ */ jsx(
|
|
829
|
+
"input",
|
|
830
|
+
{
|
|
831
|
+
type: "checkbox",
|
|
832
|
+
checked: dependsOnEnabled,
|
|
833
|
+
onChange: (e) => setDependsOnEnabled(e.target.checked),
|
|
834
|
+
className: "rounded border"
|
|
835
|
+
}
|
|
836
|
+
),
|
|
837
|
+
"Depends on another attribute"
|
|
838
|
+
] }),
|
|
839
|
+
dependsOnEnabled && (() => {
|
|
840
|
+
const parentAttr = attributes.find((a) => a.code === dependsOnAttrCode);
|
|
841
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
842
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-3", children: [
|
|
843
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
844
|
+
/* @__PURE__ */ jsx("label", { className: "block text-xs font-medium mb-1", children: "Parent Attribute Code" }),
|
|
845
|
+
/* @__PURE__ */ jsxs(
|
|
846
|
+
"select",
|
|
847
|
+
{
|
|
848
|
+
value: dependsOnAttrCode,
|
|
849
|
+
onChange: (e) => {
|
|
850
|
+
setDependsOnAttrCode(e.target.value);
|
|
851
|
+
},
|
|
852
|
+
className: "w-full rounded-md border px-2 py-1.5 text-sm",
|
|
853
|
+
children: [
|
|
854
|
+
/* @__PURE__ */ jsx("option", { value: "", children: "Select attribute..." }),
|
|
855
|
+
attributes.filter((a) => editingAttr && a.code !== editingAttr.code).map((a) => /* @__PURE__ */ jsxs("option", { value: a.code, children: [
|
|
856
|
+
a.name,
|
|
857
|
+
" (",
|
|
858
|
+
a.code,
|
|
859
|
+
")"
|
|
860
|
+
] }, a.code))
|
|
861
|
+
]
|
|
862
|
+
}
|
|
863
|
+
)
|
|
864
|
+
] }),
|
|
865
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
866
|
+
/* @__PURE__ */ jsx("label", { className: "block text-xs font-medium mb-1", children: "Effect" }),
|
|
867
|
+
/* @__PURE__ */ jsxs(
|
|
868
|
+
"select",
|
|
869
|
+
{
|
|
870
|
+
value: dependsOnEffect,
|
|
871
|
+
onChange: (e) => {
|
|
872
|
+
const next = e.target.value;
|
|
873
|
+
setDependsOnEffect(next);
|
|
874
|
+
setDependsOnRules([]);
|
|
875
|
+
},
|
|
876
|
+
className: "w-full rounded-md border px-2 py-1.5 text-sm",
|
|
877
|
+
children: [
|
|
878
|
+
/* @__PURE__ */ jsx("option", { value: "filter_options", children: "Filter options" }),
|
|
879
|
+
/* @__PURE__ */ jsx("option", { value: "set_value", children: "Set value" }),
|
|
880
|
+
/* @__PURE__ */ jsx("option", { value: "toggle_required", children: "Toggle required" })
|
|
881
|
+
]
|
|
882
|
+
}
|
|
883
|
+
)
|
|
884
|
+
] })
|
|
885
|
+
] }),
|
|
886
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
887
|
+
/* @__PURE__ */ jsx("label", { className: "block text-xs font-medium mb-2", children: "Rules" }),
|
|
888
|
+
/* @__PURE__ */ jsx(
|
|
889
|
+
DependsOnRulesEditor,
|
|
890
|
+
{
|
|
891
|
+
effect: dependsOnEffect,
|
|
892
|
+
rules: dependsOnRules,
|
|
893
|
+
onChange: setDependsOnRules,
|
|
894
|
+
parentOptions: parentAttr?.options ?? null,
|
|
895
|
+
childOptions: editingOptions.length > 0 ? editingOptions : null
|
|
896
|
+
}
|
|
897
|
+
)
|
|
898
|
+
] })
|
|
899
|
+
] });
|
|
900
|
+
})()
|
|
901
|
+
] }),
|
|
902
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-end gap-4", children: [
|
|
903
|
+
/* @__PURE__ */ jsxs("label", { className: "flex items-center gap-1.5 text-sm", children: [
|
|
904
|
+
/* @__PURE__ */ jsx("input", { type: "checkbox", checked: editingAttr.isRequired, onChange: (e) => setEditingAttr({ ...editingAttr, isRequired: e.target.checked }), className: "rounded border" }),
|
|
905
|
+
"Required"
|
|
906
|
+
] }),
|
|
907
|
+
/* @__PURE__ */ jsxs("label", { className: "flex items-center gap-1.5 text-sm", children: [
|
|
908
|
+
/* @__PURE__ */ jsx("input", { type: "checkbox", checked: editingAttr.isActive, onChange: (e) => setEditingAttr({ ...editingAttr, isActive: e.target.checked }), className: "rounded border" }),
|
|
909
|
+
"Active"
|
|
910
|
+
] })
|
|
911
|
+
] })
|
|
912
|
+
] }),
|
|
913
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
914
|
+
/* @__PURE__ */ jsx("button", { onClick: saveAttribute, disabled: saving, className: "inline-flex items-center rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50", children: saving ? "Saving..." : "Save" }),
|
|
915
|
+
/* @__PURE__ */ jsx("button", { onClick: () => setEditingAttr(null), className: "inline-flex items-center rounded-md border px-3 py-1.5 text-sm font-medium hover:bg-muted", children: "Cancel" })
|
|
916
|
+
] })
|
|
917
|
+
] }),
|
|
918
|
+
attributes.length === 0 ? /* @__PURE__ */ jsx("div", { className: "rounded-lg border bg-card p-6 text-center text-sm text-muted-foreground", children: "No attributes defined. Add design-time and run-time attributes for this specification." }) : /* @__PURE__ */ jsx("div", { className: "rounded-lg border", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-sm", children: [
|
|
919
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { className: "border-b bg-muted/50", children: [
|
|
920
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left font-medium", children: "Code" }),
|
|
921
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left font-medium", children: "Name" }),
|
|
922
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left font-medium", children: "Type" }),
|
|
923
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left font-medium", children: "Resolution" }),
|
|
924
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left font-medium", children: "Options" }),
|
|
925
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left font-medium", children: "Required" }),
|
|
926
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-right font-medium", children: "Actions" })
|
|
927
|
+
] }) }),
|
|
928
|
+
/* @__PURE__ */ jsx("tbody", { children: attributes.map((attr) => /* @__PURE__ */ jsxs("tr", { className: "border-b", children: [
|
|
929
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-3 font-mono text-xs", children: attr.code }),
|
|
930
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-3", children: attr.name }),
|
|
931
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-3", children: attr.attributeType }),
|
|
932
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-3", children: /* @__PURE__ */ jsx(Tag, { variant: attr.resolutionTime === "design_time" ? "info" : "neutral", className: "px-2 text-xs", children: attr.resolutionTime === "design_time" ? "design" : "run" }) }),
|
|
933
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-3 text-muted-foreground", children: attr.options ? `${attr.options.length} options` : "\u2014" }),
|
|
934
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-3", children: attr.isRequired ? "Yes" : "No" }),
|
|
935
|
+
/* @__PURE__ */ jsxs("td", { className: "px-4 py-3 text-right", children: [
|
|
936
|
+
/* @__PURE__ */ jsx("button", { onClick: () => startEditAttr(attr), className: "text-xs text-primary hover:underline mr-2", children: "Edit" }),
|
|
937
|
+
/* @__PURE__ */ jsx("button", { onClick: () => deleteAttribute(attr.id), className: "text-xs text-destructive hover:underline", children: "Delete" })
|
|
938
|
+
] })
|
|
939
|
+
] }, attr.id)) })
|
|
940
|
+
] }) })
|
|
941
|
+
] }),
|
|
942
|
+
tab === "offerings" && !isNew && /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
943
|
+
/* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(
|
|
944
|
+
"button",
|
|
945
|
+
{
|
|
946
|
+
onClick: () => startEditOffering(),
|
|
947
|
+
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",
|
|
948
|
+
children: t("cpq.specifications.addOffering", "Add Offering")
|
|
949
|
+
}
|
|
950
|
+
) }),
|
|
951
|
+
editingOffering && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border bg-card p-4 space-y-3", children: [
|
|
952
|
+
/* @__PURE__ */ jsx("h3", { className: "font-medium text-sm", children: editingOffering.id ? "Edit Offering" : "New Offering" }),
|
|
953
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-4 gap-3", children: [
|
|
954
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
955
|
+
/* @__PURE__ */ jsx("label", { className: "block text-xs font-medium mb-1", children: "Code" }),
|
|
956
|
+
/* @__PURE__ */ jsx("input", { type: "text", value: editingOffering.code, onChange: (e) => setEditingOffering({ ...editingOffering, code: e.target.value }), placeholder: "e.g. gix-cloud-connect-aws", className: "w-full rounded-md border px-2 py-1.5 text-sm" })
|
|
957
|
+
] }),
|
|
958
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
959
|
+
/* @__PURE__ */ jsx("label", { className: "block text-xs font-medium mb-1", children: "Name" }),
|
|
960
|
+
/* @__PURE__ */ jsx("input", { type: "text", value: editingOffering.name, onChange: (e) => setEditingOffering({ ...editingOffering, name: e.target.value }), className: "w-full rounded-md border px-2 py-1.5 text-sm" })
|
|
961
|
+
] }),
|
|
962
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
963
|
+
/* @__PURE__ */ jsx("label", { className: "block text-xs font-medium mb-1", children: "Lifecycle Status" }),
|
|
964
|
+
/* @__PURE__ */ jsxs("select", { value: editingOffering.lifecycleStatus, onChange: (e) => setEditingOffering({ ...editingOffering, lifecycleStatus: e.target.value }), className: "w-full rounded-md border px-2 py-1.5 text-sm", children: [
|
|
965
|
+
/* @__PURE__ */ jsx("option", { value: "draft", children: "Draft" }),
|
|
966
|
+
/* @__PURE__ */ jsx("option", { value: "active", children: "Active" }),
|
|
967
|
+
/* @__PURE__ */ jsx("option", { value: "deprecated", children: "Deprecated" })
|
|
968
|
+
] })
|
|
969
|
+
] }),
|
|
970
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
971
|
+
/* @__PURE__ */ jsx("label", { className: "block text-xs font-medium mb-1", children: "Is Active?" }),
|
|
972
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center h-[30px]", children: /* @__PURE__ */ jsx("input", { type: "checkbox", checked: editingOffering.isActive, onChange: (e) => setEditingOffering({ ...editingOffering, isActive: e.target.checked }), className: "rounded border" }) })
|
|
973
|
+
] })
|
|
974
|
+
] }),
|
|
975
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
976
|
+
/* @__PURE__ */ jsx("label", { className: "block text-xs font-medium mb-1", children: "Description" }),
|
|
977
|
+
/* @__PURE__ */ jsx("input", { type: "text", value: editingOffering.description ?? "", onChange: (e) => setEditingOffering({ ...editingOffering, description: e.target.value || null }), className: "w-full rounded-md border px-2 py-1.5 text-sm" })
|
|
978
|
+
] }),
|
|
979
|
+
designTimeAttrs.length > 0 ? /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
980
|
+
/* @__PURE__ */ jsx("label", { className: "block text-xs font-medium", children: "Design-Time Values" }),
|
|
981
|
+
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-3", children: designTimeAttrs.map((attr) => /* @__PURE__ */ jsxs("div", { children: [
|
|
982
|
+
/* @__PURE__ */ jsxs("label", { className: "block text-xs font-medium mb-1", children: [
|
|
983
|
+
attr.name,
|
|
984
|
+
attr.isRequired && /* @__PURE__ */ jsx("span", { className: "text-destructive ml-0.5", children: "*" })
|
|
985
|
+
] }),
|
|
986
|
+
(attr.attributeType === "select" || attr.attributeType === "enum") && attr.options ? /* @__PURE__ */ jsxs(
|
|
987
|
+
"select",
|
|
988
|
+
{
|
|
989
|
+
value: String(editingDtValues[attr.code] ?? ""),
|
|
990
|
+
onChange: (e) => setEditingDtValues({ ...editingDtValues, [attr.code]: e.target.value || null }),
|
|
991
|
+
className: "w-full rounded-md border px-2 py-1.5 text-sm",
|
|
992
|
+
children: [
|
|
993
|
+
/* @__PURE__ */ jsxs("option", { value: "", children: [
|
|
994
|
+
"Select ",
|
|
995
|
+
attr.name,
|
|
996
|
+
"..."
|
|
997
|
+
] }),
|
|
998
|
+
attr.options.map((opt) => /* @__PURE__ */ jsx("option", { value: opt.value, children: opt.label }, opt.value))
|
|
999
|
+
]
|
|
1000
|
+
}
|
|
1001
|
+
) : attr.attributeType === "number" ? /* @__PURE__ */ jsx(
|
|
1002
|
+
NumberInput,
|
|
1003
|
+
{
|
|
1004
|
+
value: typeof editingDtValues[attr.code] === "number" ? editingDtValues[attr.code] : null,
|
|
1005
|
+
onChange: (n) => setEditingDtValues({ ...editingDtValues, [attr.code]: n })
|
|
1006
|
+
}
|
|
1007
|
+
) : attr.attributeType === "boolean" ? /* @__PURE__ */ jsx("div", { className: "pt-1", children: /* @__PURE__ */ jsxs("label", { className: "flex items-center gap-1.5 text-sm", children: [
|
|
1008
|
+
/* @__PURE__ */ jsx(
|
|
1009
|
+
"input",
|
|
1010
|
+
{
|
|
1011
|
+
type: "checkbox",
|
|
1012
|
+
checked: !!editingDtValues[attr.code],
|
|
1013
|
+
onChange: (e) => setEditingDtValues({ ...editingDtValues, [attr.code]: e.target.checked }),
|
|
1014
|
+
className: "rounded border"
|
|
1015
|
+
}
|
|
1016
|
+
),
|
|
1017
|
+
attr.name
|
|
1018
|
+
] }) }) : /* @__PURE__ */ jsx(
|
|
1019
|
+
"input",
|
|
1020
|
+
{
|
|
1021
|
+
type: "text",
|
|
1022
|
+
value: String(editingDtValues[attr.code] ?? ""),
|
|
1023
|
+
onChange: (e) => setEditingDtValues({ ...editingDtValues, [attr.code]: e.target.value || null }),
|
|
1024
|
+
className: "w-full rounded-md border px-2 py-1.5 text-sm",
|
|
1025
|
+
placeholder: attr.helpText ?? void 0
|
|
1026
|
+
}
|
|
1027
|
+
),
|
|
1028
|
+
attr.helpText && /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mt-0.5", children: attr.helpText })
|
|
1029
|
+
] }, attr.code)) })
|
|
1030
|
+
] }) : /* @__PURE__ */ jsx("div", { className: "text-xs text-muted-foreground py-1", children: "No design-time attributes defined on this specification. All attributes are run-time." }),
|
|
1031
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
1032
|
+
/* @__PURE__ */ jsx("button", { onClick: saveOffering, disabled: saving, className: "inline-flex items-center rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50", children: saving ? "Saving..." : "Save" }),
|
|
1033
|
+
/* @__PURE__ */ jsx("button", { onClick: () => setEditingOffering(null), className: "inline-flex items-center rounded-md border px-3 py-1.5 text-sm font-medium hover:bg-muted", children: "Cancel" })
|
|
1034
|
+
] })
|
|
1035
|
+
] }),
|
|
1036
|
+
offerings.length === 0 ? /* @__PURE__ */ jsx("div", { className: "rounded-lg border bg-card p-6 text-center text-sm text-muted-foreground", children: "No offerings created. An offering is a sellable instance of this specification with fixed design-time values and attached charges." }) : /* @__PURE__ */ jsx("div", { className: "rounded-lg border", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-sm", children: [
|
|
1037
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { className: "border-b bg-muted/50", children: [
|
|
1038
|
+
/* @__PURE__ */ jsx("th", { className: "px-3 py-3 text-left font-medium", children: "Code" }),
|
|
1039
|
+
/* @__PURE__ */ jsx("th", { className: "px-3 py-3 text-left font-medium", children: "Name" }),
|
|
1040
|
+
/* @__PURE__ */ jsx("th", { className: "px-3 py-3 text-left font-medium", children: "Status" }),
|
|
1041
|
+
/* @__PURE__ */ jsx("th", { className: "px-3 py-3 text-left font-medium", children: "Design-Time Values" }),
|
|
1042
|
+
/* @__PURE__ */ jsx("th", { className: "px-3 py-3 text-right font-medium", children: "Actions" })
|
|
1043
|
+
] }) }),
|
|
1044
|
+
/* @__PURE__ */ jsx("tbody", { children: offerings.map((o) => /* @__PURE__ */ jsxs(
|
|
1045
|
+
"tr",
|
|
1046
|
+
{
|
|
1047
|
+
onClick: () => router.push(`/backend/cpq/offerings/${o.id}`),
|
|
1048
|
+
className: "border-b cursor-pointer hover:bg-muted/30 transition-colors",
|
|
1049
|
+
children: [
|
|
1050
|
+
/* @__PURE__ */ jsx("td", { className: "px-3 py-3 font-mono text-xs", children: o.code }),
|
|
1051
|
+
/* @__PURE__ */ jsx("td", { className: "px-3 py-3 font-medium", children: o.name }),
|
|
1052
|
+
/* @__PURE__ */ jsx("td", { className: "px-3 py-3", children: /* @__PURE__ */ jsx(Tag, { variant: lifecycleStatusMap[o.lifecycleStatus] ?? "neutral", dot: true, children: formatStatusLabel(o.lifecycleStatus) }) }),
|
|
1053
|
+
/* @__PURE__ */ jsx("td", { className: "px-3 py-3 text-muted-foreground text-xs", children: Object.keys(o.designTimeValues).length > 0 ? Object.entries(o.designTimeValues).map(([k, v]) => `${k}=${v}`).join(", ") : "\u2014" }),
|
|
1054
|
+
/* @__PURE__ */ jsxs("td", { className: "px-3 py-3 text-right", children: [
|
|
1055
|
+
/* @__PURE__ */ jsx("button", { onClick: (e) => {
|
|
1056
|
+
e.stopPropagation();
|
|
1057
|
+
startEditOffering(o);
|
|
1058
|
+
}, className: "text-xs text-primary hover:underline mr-2", children: "Edit" }),
|
|
1059
|
+
/* @__PURE__ */ jsx("button", { onClick: (e) => {
|
|
1060
|
+
e.stopPropagation();
|
|
1061
|
+
deleteOffering(o.id);
|
|
1062
|
+
}, className: "text-xs text-destructive hover:underline", children: "Delete" })
|
|
1063
|
+
] })
|
|
1064
|
+
]
|
|
1065
|
+
},
|
|
1066
|
+
o.id
|
|
1067
|
+
)) })
|
|
1068
|
+
] }) })
|
|
1069
|
+
] }),
|
|
1070
|
+
tab === "relationships" && !isNew && /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
1071
|
+
/* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(
|
|
1072
|
+
"button",
|
|
1073
|
+
{
|
|
1074
|
+
onClick: () => startEditRel(),
|
|
1075
|
+
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",
|
|
1076
|
+
children: t("cpq.specifications.addRelationship", "Add Relationship")
|
|
1077
|
+
}
|
|
1078
|
+
) }),
|
|
1079
|
+
editingRel && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border bg-card p-4 space-y-3", children: [
|
|
1080
|
+
/* @__PURE__ */ jsx("h3", { className: "font-medium text-sm", children: editingRel.id ? "Edit Relationship" : "New Relationship" }),
|
|
1081
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-3 gap-3", children: [
|
|
1082
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1083
|
+
/* @__PURE__ */ jsx("label", { className: "block text-xs font-medium mb-1", children: "Type" }),
|
|
1084
|
+
/* @__PURE__ */ jsxs("select", { value: editingRel.relationshipType, onChange: (e) => setEditingRel({ ...editingRel, relationshipType: e.target.value }), className: "w-full rounded-md border px-2 py-1.5 text-sm", children: [
|
|
1085
|
+
/* @__PURE__ */ jsx("option", { value: "parent_child", children: "Parent / Child" }),
|
|
1086
|
+
/* @__PURE__ */ jsx("option", { value: "requires", children: "Requires" }),
|
|
1087
|
+
/* @__PURE__ */ jsx("option", { value: "excludes", children: "Excludes" })
|
|
1088
|
+
] })
|
|
1089
|
+
] }),
|
|
1090
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1091
|
+
/* @__PURE__ */ jsx("label", { className: "block text-xs font-medium mb-1", children: "Target Specification" }),
|
|
1092
|
+
/* @__PURE__ */ jsxs("select", { value: editingRel.targetSpecId, onChange: (e) => setEditingRel({ ...editingRel, targetSpecId: e.target.value }), className: "w-full rounded-md border px-2 py-1.5 text-sm", children: [
|
|
1093
|
+
/* @__PURE__ */ jsx("option", { value: "", children: "Select..." }),
|
|
1094
|
+
allSpecs.filter((s) => s.id !== specId).map((s) => /* @__PURE__ */ jsxs("option", { value: s.id, children: [
|
|
1095
|
+
s.name,
|
|
1096
|
+
" (",
|
|
1097
|
+
s.code,
|
|
1098
|
+
")"
|
|
1099
|
+
] }, s.id))
|
|
1100
|
+
] })
|
|
1101
|
+
] }),
|
|
1102
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2", children: [
|
|
1103
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1104
|
+
/* @__PURE__ */ jsx("label", { className: "block text-xs font-medium mb-1", children: "Min" }),
|
|
1105
|
+
/* @__PURE__ */ jsx(
|
|
1106
|
+
NumberInput,
|
|
1107
|
+
{
|
|
1108
|
+
integer: true,
|
|
1109
|
+
min: 0,
|
|
1110
|
+
value: editingRel.cardinalityMin,
|
|
1111
|
+
onChange: (n) => setEditingRel({ ...editingRel, cardinalityMin: n ?? 0 })
|
|
1112
|
+
}
|
|
1113
|
+
)
|
|
1114
|
+
] }),
|
|
1115
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1116
|
+
/* @__PURE__ */ jsx("label", { className: "block text-xs font-medium mb-1", children: "Max" }),
|
|
1117
|
+
/* @__PURE__ */ jsx(
|
|
1118
|
+
NumberInput,
|
|
1119
|
+
{
|
|
1120
|
+
integer: true,
|
|
1121
|
+
min: 0,
|
|
1122
|
+
value: editingRel.cardinalityMax,
|
|
1123
|
+
onChange: (n) => setEditingRel({ ...editingRel, cardinalityMax: n }),
|
|
1124
|
+
placeholder: "\u221E"
|
|
1125
|
+
}
|
|
1126
|
+
)
|
|
1127
|
+
] })
|
|
1128
|
+
] })
|
|
1129
|
+
] }),
|
|
1130
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1131
|
+
/* @__PURE__ */ jsx("label", { className: "block text-xs font-medium mb-1", children: "Condition (JSON)" }),
|
|
1132
|
+
/* @__PURE__ */ jsx("textarea", { value: conditionJson, onChange: (e) => setConditionJson(e.target.value), rows: 3, className: "w-full rounded-md border px-2 py-1.5 text-sm font-mono", placeholder: 'null or {"attribute":"direction","operator":"in","value":["inbound"]}' })
|
|
1133
|
+
] }),
|
|
1134
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
1135
|
+
/* @__PURE__ */ jsx("button", { onClick: saveRelationship, disabled: saving, className: "inline-flex items-center rounded-md bg-primary px-3 py-1.5 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50", children: saving ? "Saving..." : "Save" }),
|
|
1136
|
+
/* @__PURE__ */ jsx("button", { onClick: () => setEditingRel(null), className: "inline-flex items-center rounded-md border px-3 py-1.5 text-sm font-medium hover:bg-muted", children: "Cancel" })
|
|
1137
|
+
] })
|
|
1138
|
+
] }),
|
|
1139
|
+
relationships.length === 0 ? /* @__PURE__ */ jsx("div", { className: "rounded-lg border bg-card p-6 text-center text-sm text-muted-foreground", children: "No relationships defined. Declare parent/child, requires, or excludes relationships with other specifications." }) : /* @__PURE__ */ jsx("div", { className: "rounded-lg border", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-sm", children: [
|
|
1140
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { className: "border-b bg-muted/50", children: [
|
|
1141
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left font-medium", children: "Type" }),
|
|
1142
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left font-medium", children: "Source" }),
|
|
1143
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left font-medium", children: "Target" }),
|
|
1144
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left font-medium", children: "Cardinality" }),
|
|
1145
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left font-medium", children: "Condition" }),
|
|
1146
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-right font-medium", children: "Actions" })
|
|
1147
|
+
] }) }),
|
|
1148
|
+
/* @__PURE__ */ jsx("tbody", { children: relationships.map((rel) => /* @__PURE__ */ jsxs("tr", { className: "border-b", children: [
|
|
1149
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-3", children: /* @__PURE__ */ jsx(
|
|
1150
|
+
Tag,
|
|
1151
|
+
{
|
|
1152
|
+
variant: rel.relationshipType === "parent_child" ? "brand" : rel.relationshipType === "requires" ? "info" : "error",
|
|
1153
|
+
children: rel.relationshipType
|
|
1154
|
+
}
|
|
1155
|
+
) }),
|
|
1156
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-3 text-sm", children: getSpecName(rel.sourceSpecId) }),
|
|
1157
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-3 text-sm", children: getSpecName(rel.targetSpecId) }),
|
|
1158
|
+
/* @__PURE__ */ jsxs("td", { className: "px-4 py-3 text-muted-foreground", children: [
|
|
1159
|
+
rel.cardinalityMin,
|
|
1160
|
+
"..",
|
|
1161
|
+
rel.cardinalityMax ?? "\u221E"
|
|
1162
|
+
] }),
|
|
1163
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-3 text-muted-foreground text-xs", children: rel.condition ? JSON.stringify(rel.condition) : "\u2014" }),
|
|
1164
|
+
/* @__PURE__ */ jsxs("td", { className: "px-4 py-3 text-right", children: [
|
|
1165
|
+
/* @__PURE__ */ jsx("button", { onClick: () => startEditRel(rel), className: "text-xs text-primary hover:underline mr-2", children: "Edit" }),
|
|
1166
|
+
/* @__PURE__ */ jsx("button", { onClick: () => deleteRelationship(rel.id), className: "text-xs text-destructive hover:underline", children: "Delete" })
|
|
1167
|
+
] })
|
|
1168
|
+
] }, rel.id)) })
|
|
1169
|
+
] }) })
|
|
1170
|
+
] }),
|
|
1171
|
+
tab === "slots" && !isNew && form.specType === "bundle" && /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
1172
|
+
/* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(
|
|
1173
|
+
"button",
|
|
1174
|
+
{
|
|
1175
|
+
onClick: () => setEditingSlot({ ...EMPTY_SLOT }),
|
|
1176
|
+
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",
|
|
1177
|
+
children: "+ Add Slot"
|
|
1178
|
+
}
|
|
1179
|
+
) }),
|
|
1180
|
+
editingSlot && /* @__PURE__ */ jsxs("div", { className: "rounded-lg border bg-card p-6 space-y-4", children: [
|
|
1181
|
+
/* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold", children: editingSlot.id ? "Edit Bundle Slot" : "New Bundle Slot" }),
|
|
1182
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
1183
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1184
|
+
/* @__PURE__ */ jsx("label", { className: "block text-sm font-medium mb-1", children: "Name" }),
|
|
1185
|
+
/* @__PURE__ */ jsx(
|
|
1186
|
+
"input",
|
|
1187
|
+
{
|
|
1188
|
+
type: "text",
|
|
1189
|
+
value: editingSlot.name,
|
|
1190
|
+
onChange: (e) => setEditingSlot({ ...editingSlot, name: e.target.value }),
|
|
1191
|
+
placeholder: "e.g. Internet Component",
|
|
1192
|
+
className: "w-full rounded-md border px-3 py-2 text-sm"
|
|
1193
|
+
}
|
|
1194
|
+
)
|
|
1195
|
+
] }),
|
|
1196
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1197
|
+
/* @__PURE__ */ jsx("label", { className: "block text-sm font-medium mb-1", children: "Component Group" }),
|
|
1198
|
+
/* @__PURE__ */ jsx(
|
|
1199
|
+
"input",
|
|
1200
|
+
{
|
|
1201
|
+
type: "text",
|
|
1202
|
+
value: editingSlot.componentGroup,
|
|
1203
|
+
onChange: (e) => setEditingSlot({ ...editingSlot, componentGroup: e.target.value }),
|
|
1204
|
+
placeholder: "e.g. internet, tv, phone",
|
|
1205
|
+
className: "w-full rounded-md border px-3 py-2 text-sm"
|
|
1206
|
+
}
|
|
1207
|
+
)
|
|
1208
|
+
] }),
|
|
1209
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1210
|
+
/* @__PURE__ */ jsx("label", { className: "block text-sm font-medium mb-1", children: "Target Specification" }),
|
|
1211
|
+
/* @__PURE__ */ jsxs(
|
|
1212
|
+
"select",
|
|
1213
|
+
{
|
|
1214
|
+
value: editingSlot.targetSpecId,
|
|
1215
|
+
onChange: (e) => setEditingSlot({ ...editingSlot, targetSpecId: e.target.value }),
|
|
1216
|
+
className: "w-full rounded-md border px-3 py-2 text-sm",
|
|
1217
|
+
children: [
|
|
1218
|
+
/* @__PURE__ */ jsx("option", { value: "", children: "\u2014 Select specification \u2014" }),
|
|
1219
|
+
allSpecs.filter((s) => s.id !== specId).map((s) => /* @__PURE__ */ jsxs("option", { value: s.id, children: [
|
|
1220
|
+
s.name,
|
|
1221
|
+
" (",
|
|
1222
|
+
s.code,
|
|
1223
|
+
")"
|
|
1224
|
+
] }, s.id))
|
|
1225
|
+
]
|
|
1226
|
+
}
|
|
1227
|
+
)
|
|
1228
|
+
] }),
|
|
1229
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1230
|
+
/* @__PURE__ */ jsx("label", { className: "block text-sm font-medium mb-1", children: "Sort Order" }),
|
|
1231
|
+
/* @__PURE__ */ jsx(
|
|
1232
|
+
NumberInput,
|
|
1233
|
+
{
|
|
1234
|
+
integer: true,
|
|
1235
|
+
value: editingSlot.sortOrder,
|
|
1236
|
+
onChange: (n) => setEditingSlot({ ...editingSlot, sortOrder: n ?? 0 })
|
|
1237
|
+
}
|
|
1238
|
+
)
|
|
1239
|
+
] }),
|
|
1240
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1241
|
+
/* @__PURE__ */ jsx("label", { className: "block text-sm font-medium mb-1", children: "Cardinality Min" }),
|
|
1242
|
+
/* @__PURE__ */ jsx(
|
|
1243
|
+
NumberInput,
|
|
1244
|
+
{
|
|
1245
|
+
integer: true,
|
|
1246
|
+
min: 0,
|
|
1247
|
+
value: editingSlot.cardinalityMin,
|
|
1248
|
+
onChange: (n) => setEditingSlot({ ...editingSlot, cardinalityMin: n ?? 0 })
|
|
1249
|
+
}
|
|
1250
|
+
)
|
|
1251
|
+
] }),
|
|
1252
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1253
|
+
/* @__PURE__ */ jsx("label", { className: "block text-sm font-medium mb-1", children: "Cardinality Max" }),
|
|
1254
|
+
/* @__PURE__ */ jsx(
|
|
1255
|
+
NumberInput,
|
|
1256
|
+
{
|
|
1257
|
+
integer: true,
|
|
1258
|
+
min: 0,
|
|
1259
|
+
placeholder: "\u221E (unlimited)",
|
|
1260
|
+
value: editingSlot.cardinalityMax,
|
|
1261
|
+
onChange: (n) => setEditingSlot({ ...editingSlot, cardinalityMax: n })
|
|
1262
|
+
}
|
|
1263
|
+
)
|
|
1264
|
+
] })
|
|
1265
|
+
] }),
|
|
1266
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1267
|
+
/* @__PURE__ */ jsx("label", { className: "block text-sm font-medium mb-1", children: "Description" }),
|
|
1268
|
+
/* @__PURE__ */ jsx(
|
|
1269
|
+
"textarea",
|
|
1270
|
+
{
|
|
1271
|
+
value: editingSlot.description ?? "",
|
|
1272
|
+
onChange: (e) => setEditingSlot({ ...editingSlot, description: e.target.value }),
|
|
1273
|
+
rows: 2,
|
|
1274
|
+
className: "w-full rounded-md border px-3 py-2 text-sm"
|
|
1275
|
+
}
|
|
1276
|
+
)
|
|
1277
|
+
] }),
|
|
1278
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-3", children: [
|
|
1279
|
+
/* @__PURE__ */ jsx(
|
|
1280
|
+
"button",
|
|
1281
|
+
{
|
|
1282
|
+
onClick: async () => {
|
|
1283
|
+
setSaving(true);
|
|
1284
|
+
setError(null);
|
|
1285
|
+
try {
|
|
1286
|
+
const isEdit = !!editingSlot.id;
|
|
1287
|
+
const payload = isEdit ? { id: editingSlot.id, ...editingSlot, description: editingSlot.description || null } : { specId, ...editingSlot, description: editingSlot.description || null };
|
|
1288
|
+
const res = await fetch("/api/cpq/bundle-slots", {
|
|
1289
|
+
method: isEdit ? "PUT" : "POST",
|
|
1290
|
+
headers: { "Content-Type": "application/json" },
|
|
1291
|
+
body: JSON.stringify(payload)
|
|
1292
|
+
});
|
|
1293
|
+
if (!res.ok) {
|
|
1294
|
+
const d = await res.json();
|
|
1295
|
+
setError(d.error ?? "Failed to save slot");
|
|
1296
|
+
return;
|
|
1297
|
+
}
|
|
1298
|
+
setEditingSlot(null);
|
|
1299
|
+
const slotsRes = await fetch(`/api/cpq/bundle-slots?specId=${specId}`);
|
|
1300
|
+
if (slotsRes.ok) {
|
|
1301
|
+
const d = await slotsRes.json();
|
|
1302
|
+
setBundleSlots(d.items ?? []);
|
|
1303
|
+
}
|
|
1304
|
+
} catch {
|
|
1305
|
+
setError("Failed to save slot");
|
|
1306
|
+
} finally {
|
|
1307
|
+
setSaving(false);
|
|
1308
|
+
}
|
|
1309
|
+
},
|
|
1310
|
+
disabled: saving || !editingSlot.name || !editingSlot.componentGroup || !editingSlot.targetSpecId,
|
|
1311
|
+
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",
|
|
1312
|
+
children: saving ? "Saving..." : editingSlot.id ? "Update" : "Create"
|
|
1313
|
+
}
|
|
1314
|
+
),
|
|
1315
|
+
/* @__PURE__ */ jsx(
|
|
1316
|
+
"button",
|
|
1317
|
+
{
|
|
1318
|
+
onClick: () => setEditingSlot(null),
|
|
1319
|
+
className: "inline-flex items-center justify-center rounded-md border px-4 py-2 text-sm font-medium hover:bg-muted",
|
|
1320
|
+
children: "Cancel"
|
|
1321
|
+
}
|
|
1322
|
+
)
|
|
1323
|
+
] })
|
|
1324
|
+
] }),
|
|
1325
|
+
bundleSlots.length === 0 && !editingSlot ? /* @__PURE__ */ jsx("div", { className: "rounded-lg border bg-card p-6 text-center text-sm text-muted-foreground", children: "No bundle slots defined yet. Add slots to define what component specifications can fill this bundle." }) : bundleSlots.length > 0 && /* @__PURE__ */ jsx("div", { className: "rounded-lg border overflow-hidden", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-sm", children: [
|
|
1326
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { className: "border-b bg-muted/50", children: [
|
|
1327
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left font-medium", children: "Name" }),
|
|
1328
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left font-medium", children: "Group" }),
|
|
1329
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left font-medium", children: "Target Spec" }),
|
|
1330
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left font-medium", children: "Cardinality" }),
|
|
1331
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left font-medium", children: "Order" }),
|
|
1332
|
+
/* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-right font-medium", children: "Actions" })
|
|
1333
|
+
] }) }),
|
|
1334
|
+
/* @__PURE__ */ jsx("tbody", { children: bundleSlots.map((slot) => /* @__PURE__ */ jsxs("tr", { className: "border-b", children: [
|
|
1335
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-3 font-medium", children: slot.name }),
|
|
1336
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-3", children: /* @__PURE__ */ jsx(Tag, { variant: "info", children: slot.componentGroup }) }),
|
|
1337
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-3 text-sm", children: slot.targetSpec ? /* @__PURE__ */ jsxs("span", { children: [
|
|
1338
|
+
slot.targetSpec.name,
|
|
1339
|
+
slot.targetSpec.specType === "bundle" && /* @__PURE__ */ jsx(Tag, { variant: "brand", className: "ml-1 px-1.5 text-[10px]", children: "bundle" })
|
|
1340
|
+
] }) : /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "Unknown" }) }),
|
|
1341
|
+
/* @__PURE__ */ jsxs("td", { className: "px-4 py-3 text-muted-foreground", children: [
|
|
1342
|
+
slot.cardinalityMin,
|
|
1343
|
+
"..",
|
|
1344
|
+
slot.cardinalityMax ?? "\u221E"
|
|
1345
|
+
] }),
|
|
1346
|
+
/* @__PURE__ */ jsx("td", { className: "px-4 py-3 text-muted-foreground", children: slot.sortOrder }),
|
|
1347
|
+
/* @__PURE__ */ jsxs("td", { className: "px-4 py-3 text-right", children: [
|
|
1348
|
+
/* @__PURE__ */ jsx(
|
|
1349
|
+
"button",
|
|
1350
|
+
{
|
|
1351
|
+
onClick: () => setEditingSlot({
|
|
1352
|
+
id: slot.id,
|
|
1353
|
+
targetSpecId: slot.targetSpecId,
|
|
1354
|
+
componentGroup: slot.componentGroup,
|
|
1355
|
+
name: slot.name,
|
|
1356
|
+
description: slot.description ?? "",
|
|
1357
|
+
cardinalityMin: slot.cardinalityMin,
|
|
1358
|
+
cardinalityMax: slot.cardinalityMax,
|
|
1359
|
+
sortOrder: slot.sortOrder
|
|
1360
|
+
}),
|
|
1361
|
+
className: "text-xs text-primary hover:underline mr-2",
|
|
1362
|
+
children: "Edit"
|
|
1363
|
+
}
|
|
1364
|
+
),
|
|
1365
|
+
/* @__PURE__ */ jsx(
|
|
1366
|
+
"button",
|
|
1367
|
+
{
|
|
1368
|
+
onClick: async () => {
|
|
1369
|
+
if (!confirm("Delete this bundle slot?")) return;
|
|
1370
|
+
try {
|
|
1371
|
+
const res = await fetch("/api/cpq/bundle-slots", {
|
|
1372
|
+
method: "DELETE",
|
|
1373
|
+
headers: { "Content-Type": "application/json" },
|
|
1374
|
+
body: JSON.stringify({ id: slot.id })
|
|
1375
|
+
});
|
|
1376
|
+
if (res.ok) {
|
|
1377
|
+
setBundleSlots((prev) => prev.filter((s) => s.id !== slot.id));
|
|
1378
|
+
} else {
|
|
1379
|
+
const d = await res.json();
|
|
1380
|
+
setError(d.error ?? "Failed to delete slot");
|
|
1381
|
+
}
|
|
1382
|
+
} catch {
|
|
1383
|
+
setError("Failed to delete slot");
|
|
1384
|
+
}
|
|
1385
|
+
},
|
|
1386
|
+
className: "text-xs text-destructive hover:underline",
|
|
1387
|
+
children: "Delete"
|
|
1388
|
+
}
|
|
1389
|
+
)
|
|
1390
|
+
] })
|
|
1391
|
+
] }, slot.id)) })
|
|
1392
|
+
] }) })
|
|
1393
|
+
] })
|
|
1394
|
+
] });
|
|
1395
|
+
}
|
|
1396
|
+
export {
|
|
1397
|
+
SpecificationDetailPage as default
|
|
1398
|
+
};
|
|
1399
|
+
//# sourceMappingURL=page.js.map
|