@endora-commerce/mod-catalog 0.107.0 → 0.109.0
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/dist/admin/components/AttachmentScopesDialog.d.ts +22 -0
- package/dist/admin/components/AttachmentScopesDialog.d.ts.map +1 -0
- package/dist/admin/components/AttachmentScopesDialog.js +70 -0
- package/dist/admin/components/AttachmentScopesDialog.js.map +1 -0
- package/dist/admin/components/PackagingUnitsEditor.d.ts +10 -1
- package/dist/admin/components/PackagingUnitsEditor.d.ts.map +1 -1
- package/dist/admin/components/PackagingUnitsEditor.js +127 -10
- package/dist/admin/components/PackagingUnitsEditor.js.map +1 -1
- package/dist/admin/components/ProductAttachmentsSection.d.ts +5 -0
- package/dist/admin/components/ProductAttachmentsSection.d.ts.map +1 -0
- package/dist/admin/components/ProductAttachmentsSection.js +137 -0
- package/dist/admin/components/ProductAttachmentsSection.js.map +1 -0
- package/dist/admin/components/ProductGallerySection.d.ts +14 -0
- package/dist/admin/components/ProductGallerySection.d.ts.map +1 -0
- package/dist/admin/components/ProductGallerySection.js +385 -0
- package/dist/admin/components/ProductGallerySection.js.map +1 -0
- package/dist/admin/components/ProductOrderRulesCard.d.ts +19 -0
- package/dist/admin/components/ProductOrderRulesCard.d.ts.map +1 -0
- package/dist/admin/components/ProductOrderRulesCard.js +275 -0
- package/dist/admin/components/ProductOrderRulesCard.js.map +1 -0
- package/dist/admin/components/ProductScopeControls.d.ts +31 -0
- package/dist/admin/components/ProductScopeControls.d.ts.map +1 -0
- package/dist/admin/components/ProductScopeControls.js +243 -0
- package/dist/admin/components/ProductScopeControls.js.map +1 -0
- package/dist/admin/components/ProductScopeEditor.d.ts +12 -18
- package/dist/admin/components/ProductScopeEditor.d.ts.map +1 -1
- package/dist/admin/components/ProductScopeEditor.js +5 -4
- package/dist/admin/components/ProductScopeEditor.js.map +1 -1
- package/dist/admin/components/ProductScopeOverview.d.ts +26 -0
- package/dist/admin/components/ProductScopeOverview.d.ts.map +1 -0
- package/dist/admin/components/ProductScopeOverview.js +207 -0
- package/dist/admin/components/ProductScopeOverview.js.map +1 -0
- package/dist/admin/components/ProductStatusPills.d.ts +17 -0
- package/dist/admin/components/ProductStatusPills.d.ts.map +1 -0
- package/dist/admin/components/ProductStatusPills.js +23 -0
- package/dist/admin/components/ProductStatusPills.js.map +1 -0
- package/dist/admin/components/ProductUrlKeysPanel.d.ts +17 -0
- package/dist/admin/components/ProductUrlKeysPanel.d.ts.map +1 -0
- package/dist/admin/components/ProductUrlKeysPanel.js +215 -0
- package/dist/admin/components/ProductUrlKeysPanel.js.map +1 -0
- package/dist/admin/components/ProductsBulkEditDialog.d.ts +30 -0
- package/dist/admin/components/ProductsBulkEditDialog.d.ts.map +1 -1
- package/dist/admin/components/ProductsBulkEditDialog.js +308 -125
- package/dist/admin/components/ProductsBulkEditDialog.js.map +1 -1
- package/dist/admin/components/ScopedDialogParts.d.ts +23 -0
- package/dist/admin/components/ScopedDialogParts.d.ts.map +1 -0
- package/dist/admin/components/ScopedDialogParts.js +16 -0
- package/dist/admin/components/ScopedDialogParts.js.map +1 -0
- package/dist/admin/index.d.ts +2 -2
- package/dist/admin/index.d.ts.map +1 -1
- package/dist/admin/index.js +9 -0
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/lib/attribute-scope.d.ts +20 -0
- package/dist/admin/lib/attribute-scope.d.ts.map +1 -0
- package/dist/admin/lib/attribute-scope.js +18 -0
- package/dist/admin/lib/attribute-scope.js.map +1 -0
- package/dist/admin/lib/bulk-operation-log-text.d.ts +9 -0
- package/dist/admin/lib/bulk-operation-log-text.d.ts.map +1 -0
- package/dist/admin/lib/bulk-operation-log-text.js +13 -0
- package/dist/admin/lib/bulk-operation-log-text.js.map +1 -0
- package/dist/admin/lib/media-scopes.d.ts +41 -0
- package/dist/admin/lib/media-scopes.d.ts.map +1 -0
- package/dist/admin/lib/media-scopes.js +66 -0
- package/dist/admin/lib/media-scopes.js.map +1 -0
- package/dist/admin/lib/product-labels.d.ts +14 -0
- package/dist/admin/lib/product-labels.d.ts.map +1 -0
- package/dist/admin/lib/product-labels.js +27 -0
- package/dist/admin/lib/product-labels.js.map +1 -0
- package/dist/admin/lib/product-scope-drafts.d.ts +77 -0
- package/dist/admin/lib/product-scope-drafts.d.ts.map +1 -0
- package/dist/admin/lib/product-scope-drafts.js +133 -0
- package/dist/admin/lib/product-scope-drafts.js.map +1 -0
- package/dist/admin/lib/product-scopes-api.d.ts +40 -0
- package/dist/admin/lib/product-scopes-api.d.ts.map +1 -0
- package/dist/admin/lib/product-scopes-api.js +101 -0
- package/dist/admin/lib/product-scopes-api.js.map +1 -0
- package/dist/admin/lib/product-url-keys-api.d.ts +46 -0
- package/dist/admin/lib/product-url-keys-api.d.ts.map +1 -0
- package/dist/admin/lib/product-url-keys-api.js +110 -0
- package/dist/admin/lib/product-url-keys-api.js.map +1 -0
- package/dist/admin/lib/resolve-product-selection.d.ts +29 -1
- package/dist/admin/lib/resolve-product-selection.d.ts.map +1 -1
- package/dist/admin/lib/resolve-product-selection.js +42 -6
- package/dist/admin/lib/resolve-product-selection.js.map +1 -1
- package/dist/admin/lib/scope-overview.d.ts +74 -0
- package/dist/admin/lib/scope-overview.d.ts.map +1 -0
- package/dist/admin/lib/scope-overview.js +173 -0
- package/dist/admin/lib/scope-overview.js.map +1 -0
- package/dist/admin/pages/AttributesManager.d.ts.map +1 -1
- package/dist/admin/pages/AttributesManager.js +84 -7
- package/dist/admin/pages/AttributesManager.js.map +1 -1
- package/dist/admin/pages/BulkOperationDetailPage.d.ts.map +1 -1
- package/dist/admin/pages/BulkOperationDetailPage.js +4 -19
- package/dist/admin/pages/BulkOperationDetailPage.js.map +1 -1
- package/dist/admin/pages/ProductEditor.d.ts +0 -4
- package/dist/admin/pages/ProductEditor.d.ts.map +1 -1
- package/dist/admin/pages/ProductEditor.js +221 -374
- package/dist/admin/pages/ProductEditor.js.map +1 -1
- package/dist/admin/pages/ProductsList.d.ts +12 -0
- package/dist/admin/pages/ProductsList.d.ts.map +1 -1
- package/dist/admin/pages/ProductsList.js +105 -38
- package/dist/admin/pages/ProductsList.js.map +1 -1
- package/dist/backend/admin-search-provider.d.ts +1 -1
- package/dist/backend/admin-search-provider.d.ts.map +1 -1
- package/dist/backend/admin-search-provider.js +1 -2
- package/dist/backend/admin-search-provider.js.map +1 -1
- package/dist/backend/demo/reset.d.ts +1 -1
- package/dist/backend/demo/rows.d.ts +14 -3
- package/dist/backend/demo/rows.d.ts.map +1 -1
- package/dist/backend/demo/rows.js +24 -17
- package/dist/backend/demo/rows.js.map +1 -1
- package/dist/backend/demo/seed.d.ts.map +1 -1
- package/dist/backend/demo/seed.js +3 -6
- package/dist/backend/demo/seed.js.map +1 -1
- package/dist/backend/entities/bulk-operation.entity.d.ts +10 -0
- package/dist/backend/entities/bulk-operation.entity.d.ts.map +1 -1
- package/dist/backend/entities/bulk-operation.entity.js.map +1 -1
- package/dist/backend/entities/gallery-item-channel-hidden.entity.d.ts +14 -0
- package/dist/backend/entities/gallery-item-channel-hidden.entity.d.ts.map +1 -0
- package/dist/backend/entities/gallery-item-channel-hidden.entity.js +42 -0
- package/dist/backend/entities/gallery-item-channel-hidden.entity.js.map +1 -0
- package/dist/backend/entities/gallery-item-channel-label.entity.d.ts +18 -0
- package/dist/backend/entities/gallery-item-channel-label.entity.d.ts.map +1 -0
- package/dist/backend/entities/gallery-item-channel-label.entity.js +49 -0
- package/dist/backend/entities/gallery-item-channel-label.entity.js.map +1 -0
- package/dist/backend/entities/gallery-item.entity.d.ts +8 -1
- package/dist/backend/entities/gallery-item.entity.d.ts.map +1 -1
- package/dist/backend/entities/gallery-item.entity.js +11 -0
- package/dist/backend/entities/gallery-item.entity.js.map +1 -1
- package/dist/backend/entities/product-attachment-channel-hidden.entity.d.ts +13 -0
- package/dist/backend/entities/product-attachment-channel-hidden.entity.d.ts.map +1 -0
- package/dist/backend/entities/product-attachment-channel-hidden.entity.js +41 -0
- package/dist/backend/entities/product-attachment-channel-hidden.entity.js.map +1 -0
- package/dist/backend/entities/product-attachment.entity.d.ts +8 -1
- package/dist/backend/entities/product-attachment.entity.d.ts.map +1 -1
- package/dist/backend/entities/product-attachment.entity.js +15 -0
- package/dist/backend/entities/product-attachment.entity.js.map +1 -1
- package/dist/backend/entities/product-channel-language-scope.entity.d.ts +23 -0
- package/dist/backend/entities/product-channel-language-scope.entity.d.ts.map +1 -0
- package/dist/backend/entities/product-channel-language-scope.entity.js +61 -0
- package/dist/backend/entities/product-channel-language-scope.entity.js.map +1 -0
- package/dist/backend/entities/product-channel-scope.entity.d.ts +42 -0
- package/dist/backend/entities/product-channel-scope.entity.d.ts.map +1 -0
- package/dist/backend/entities/product-channel-scope.entity.js +104 -0
- package/dist/backend/entities/product-channel-scope.entity.js.map +1 -0
- package/dist/backend/entities/product-packaging-unit.entity.d.ts +13 -1
- package/dist/backend/entities/product-packaging-unit.entity.d.ts.map +1 -1
- package/dist/backend/entities/product-packaging-unit.entity.js +20 -0
- package/dist/backend/entities/product-packaging-unit.entity.js.map +1 -1
- package/dist/backend/entities/product-url-key.entity.d.ts +32 -0
- package/dist/backend/entities/product-url-key.entity.d.ts.map +1 -0
- package/dist/backend/entities/product-url-key.entity.js +75 -0
- package/dist/backend/entities/product-url-key.entity.js.map +1 -0
- package/dist/backend/entities/product-url-redirect.entity.d.ts +23 -0
- package/dist/backend/entities/product-url-redirect.entity.d.ts.map +1 -0
- package/dist/backend/entities/product-url-redirect.entity.js +58 -0
- package/dist/backend/entities/product-url-redirect.entity.js.map +1 -0
- package/dist/backend/entities/product-variant.entity.d.ts +1 -2
- package/dist/backend/entities/product-variant.entity.d.ts.map +1 -1
- package/dist/backend/entities/product-variant.entity.js +0 -5
- package/dist/backend/entities/product-variant.entity.js.map +1 -1
- package/dist/backend/entities/product.entity.d.ts +41 -2
- package/dist/backend/entities/product.entity.d.ts.map +1 -1
- package/dist/backend/entities/product.entity.js +84 -1
- package/dist/backend/entities/product.entity.js.map +1 -1
- package/dist/backend/index.d.ts +27 -6
- package/dist/backend/index.d.ts.map +1 -1
- package/dist/backend/index.js +209 -15
- package/dist/backend/index.js.map +1 -1
- package/dist/backend/plugin.d.ts +45 -4
- package/dist/backend/plugin.d.ts.map +1 -1
- package/dist/backend/plugin.js +67 -9
- package/dist/backend/plugin.js.map +1 -1
- package/dist/backend/prompt-tools.d.ts +10 -0
- package/dist/backend/prompt-tools.d.ts.map +1 -1
- package/dist/backend/prompt-tools.js +108 -4
- package/dist/backend/prompt-tools.js.map +1 -1
- package/dist/backend/routes.admin.d.ts +29 -0
- package/dist/backend/routes.admin.d.ts.map +1 -1
- package/dist/backend/routes.admin.js +161 -55
- package/dist/backend/routes.admin.js.map +1 -1
- package/dist/backend/routes.admin.url-keys.d.ts +23 -0
- package/dist/backend/routes.admin.url-keys.d.ts.map +1 -0
- package/dist/backend/routes.admin.url-keys.js +14 -0
- package/dist/backend/routes.admin.url-keys.js.map +1 -0
- package/dist/backend/routes.api-key.d.ts.map +1 -1
- package/dist/backend/routes.api-key.js +14 -1
- package/dist/backend/routes.api-key.js.map +1 -1
- package/dist/backend/routes.external.d.ts.map +1 -1
- package/dist/backend/routes.external.js +6 -1
- package/dist/backend/routes.external.js.map +1 -1
- package/dist/backend/routes.public.d.ts +24 -7
- package/dist/backend/routes.public.d.ts.map +1 -1
- package/dist/backend/routes.public.js +58 -29
- package/dist/backend/routes.public.js.map +1 -1
- package/dist/backend/routes.public.url-keys.d.ts +26 -0
- package/dist/backend/routes.public.url-keys.d.ts.map +1 -0
- package/dist/backend/routes.public.url-keys.js +17 -0
- package/dist/backend/routes.public.url-keys.js.map +1 -0
- package/dist/backend/services/asset-references.js +43 -30
- package/dist/backend/services/asset-references.js.map +1 -1
- package/dist/backend/services/attachment-packaging-scopes.d.ts +43 -0
- package/dist/backend/services/attachment-packaging-scopes.d.ts.map +1 -0
- package/dist/backend/services/attachment-packaging-scopes.js +115 -0
- package/dist/backend/services/attachment-packaging-scopes.js.map +1 -0
- package/dist/backend/services/attachment.service.d.ts +12 -1
- package/dist/backend/services/attachment.service.d.ts.map +1 -1
- package/dist/backend/services/attachment.service.js +119 -21
- package/dist/backend/services/attachment.service.js.map +1 -1
- package/dist/backend/services/attribute-scope-preview.d.ts +38 -0
- package/dist/backend/services/attribute-scope-preview.d.ts.map +1 -0
- package/dist/backend/services/attribute-scope-preview.js +66 -0
- package/dist/backend/services/attribute-scope-preview.js.map +1 -0
- package/dist/backend/services/bulk-operation.service.d.ts +36 -0
- package/dist/backend/services/bulk-operation.service.d.ts.map +1 -1
- package/dist/backend/services/bulk-operation.service.js +203 -36
- package/dist/backend/services/bulk-operation.service.js.map +1 -1
- package/dist/backend/services/bundle.service.d.ts +9 -1
- package/dist/backend/services/bundle.service.d.ts.map +1 -1
- package/dist/backend/services/bundle.service.js +12 -2
- package/dist/backend/services/bundle.service.js.map +1 -1
- package/dist/backend/services/catalog-admin-search.service.d.ts +1 -1
- package/dist/backend/services/catalog-admin-search.service.js +1 -1
- package/dist/backend/services/catalog-admin.service.d.ts +125 -18
- package/dist/backend/services/catalog-admin.service.d.ts.map +1 -1
- package/dist/backend/services/catalog-admin.service.js +367 -164
- package/dist/backend/services/catalog-admin.service.js.map +1 -1
- package/dist/backend/services/catalog-bulk-import.service.d.ts +24 -2
- package/dist/backend/services/catalog-bulk-import.service.d.ts.map +1 -1
- package/dist/backend/services/catalog-bulk-import.service.js +132 -6
- package/dist/backend/services/catalog-bulk-import.service.js.map +1 -1
- package/dist/backend/services/catalog-bulk-update.service.d.ts +32 -4
- package/dist/backend/services/catalog-bulk-update.service.d.ts.map +1 -1
- package/dist/backend/services/catalog-bulk-update.service.js +115 -12
- package/dist/backend/services/catalog-bulk-update.service.js.map +1 -1
- package/dist/backend/services/catalog-org-price-decorator.d.ts +18 -27
- package/dist/backend/services/catalog-org-price-decorator.d.ts.map +1 -1
- package/dist/backend/services/catalog-org-price-decorator.js +77 -33
- package/dist/backend/services/catalog-org-price-decorator.js.map +1 -1
- package/dist/backend/services/catalog-product-filter.service.d.ts +16 -2
- package/dist/backend/services/catalog-product-filter.service.d.ts.map +1 -1
- package/dist/backend/services/catalog-product-filter.service.js +80 -3
- package/dist/backend/services/catalog-product-filter.service.js.map +1 -1
- package/dist/backend/services/catalog-product-read.service.d.ts +45 -3
- package/dist/backend/services/catalog-product-read.service.d.ts.map +1 -1
- package/dist/backend/services/catalog-product-read.service.js +130 -3
- package/dist/backend/services/catalog-product-read.service.js.map +1 -1
- package/dist/backend/services/catalog-query.service.d.ts +145 -40
- package/dist/backend/services/catalog-query.service.d.ts.map +1 -1
- package/dist/backend/services/catalog-query.service.js +1048 -391
- package/dist/backend/services/catalog-query.service.js.map +1 -1
- package/dist/backend/services/catalog-quick-search.service.d.ts +18 -2
- package/dist/backend/services/catalog-quick-search.service.d.ts.map +1 -1
- package/dist/backend/services/catalog-quick-search.service.js +52 -20
- package/dist/backend/services/catalog-quick-search.service.js.map +1 -1
- package/dist/backend/services/catalog-write-ports.d.ts +18 -1
- package/dist/backend/services/catalog-write-ports.d.ts.map +1 -1
- package/dist/backend/services/catalog-write-ports.js +77 -0
- package/dist/backend/services/catalog-write-ports.js.map +1 -1
- package/dist/backend/services/category-admin.service.d.ts +12 -1
- package/dist/backend/services/category-admin.service.d.ts.map +1 -1
- package/dist/backend/services/category-admin.service.js +23 -2
- package/dist/backend/services/category-admin.service.js.map +1 -1
- package/dist/backend/services/channel-url-facts.d.ts +17 -0
- package/dist/backend/services/channel-url-facts.d.ts.map +1 -0
- package/dist/backend/services/channel-url-facts.js +20 -0
- package/dist/backend/services/channel-url-facts.js.map +1 -0
- package/dist/backend/services/effective-value.sql.d.ts +56 -0
- package/dist/backend/services/effective-value.sql.d.ts.map +1 -0
- package/dist/backend/services/effective-value.sql.js +111 -0
- package/dist/backend/services/effective-value.sql.js.map +1 -0
- package/dist/backend/services/gallery-scopes.d.ts +40 -0
- package/dist/backend/services/gallery-scopes.d.ts.map +1 -0
- package/dist/backend/services/gallery-scopes.js +151 -0
- package/dist/backend/services/gallery-scopes.js.map +1 -0
- package/dist/backend/services/gallery.service.d.ts +46 -4
- package/dist/backend/services/gallery.service.d.ts.map +1 -1
- package/dist/backend/services/gallery.service.js +308 -46
- package/dist/backend/services/gallery.service.js.map +1 -1
- package/dist/backend/services/linkable-asset.d.ts +21 -0
- package/dist/backend/services/linkable-asset.d.ts.map +1 -0
- package/dist/backend/services/linkable-asset.js +31 -0
- package/dist/backend/services/linkable-asset.js.map +1 -0
- package/dist/backend/services/packaging-unit.service.d.ts.map +1 -1
- package/dist/backend/services/packaging-unit.service.js +95 -29
- package/dist/backend/services/packaging-unit.service.js.map +1 -1
- package/dist/backend/services/primary-asset-url.d.ts +7 -1
- package/dist/backend/services/primary-asset-url.d.ts.map +1 -1
- package/dist/backend/services/primary-asset-url.js +45 -14
- package/dist/backend/services/primary-asset-url.js.map +1 -1
- package/dist/backend/services/product-availability.service.d.ts +79 -0
- package/dist/backend/services/product-availability.service.d.ts.map +1 -0
- package/dist/backend/services/product-availability.service.js +223 -0
- package/dist/backend/services/product-availability.service.js.map +1 -0
- package/dist/backend/services/product-availability.sql.d.ts +71 -0
- package/dist/backend/services/product-availability.sql.d.ts.map +1 -0
- package/dist/backend/services/product-availability.sql.js +77 -0
- package/dist/backend/services/product-availability.sql.js.map +1 -0
- package/dist/backend/services/product-link.service.d.ts +10 -9
- package/dist/backend/services/product-link.service.d.ts.map +1 -1
- package/dist/backend/services/product-link.service.js +48 -23
- package/dist/backend/services/product-link.service.js.map +1 -1
- package/dist/backend/services/product-overrides.service.d.ts +9 -2
- package/dist/backend/services/product-overrides.service.d.ts.map +1 -1
- package/dist/backend/services/product-overrides.service.js +13 -6
- package/dist/backend/services/product-overrides.service.js.map +1 -1
- package/dist/backend/services/product-page-revalidation.d.ts +51 -0
- package/dist/backend/services/product-page-revalidation.d.ts.map +1 -0
- package/dist/backend/services/product-page-revalidation.js +146 -0
- package/dist/backend/services/product-page-revalidation.js.map +1 -0
- package/dist/backend/services/product-scope-context.service.d.ts.map +1 -1
- package/dist/backend/services/product-scope-context.service.js +3 -2
- package/dist/backend/services/product-scope-context.service.js.map +1 -1
- package/dist/backend/services/product-scopes.service.d.ts +212 -0
- package/dist/backend/services/product-scopes.service.d.ts.map +1 -0
- package/dist/backend/services/product-scopes.service.js +638 -0
- package/dist/backend/services/product-scopes.service.js.map +1 -0
- package/dist/backend/services/product-summary-text.d.ts +8 -0
- package/dist/backend/services/product-summary-text.d.ts.map +1 -0
- package/dist/backend/services/product-summary-text.js +8 -0
- package/dist/backend/services/product-summary-text.js.map +1 -0
- package/dist/backend/services/product-value-resolver.service.d.ts +11 -1
- package/dist/backend/services/product-value-resolver.service.d.ts.map +1 -1
- package/dist/backend/services/product-value-resolver.service.js +29 -9
- package/dist/backend/services/product-value-resolver.service.js.map +1 -1
- package/dist/backend/services/publication-window-sweep.d.ts +77 -0
- package/dist/backend/services/publication-window-sweep.d.ts.map +1 -0
- package/dist/backend/services/publication-window-sweep.js +117 -0
- package/dist/backend/services/publication-window-sweep.js.map +1 -0
- package/dist/backend/services/scope-completeness.d.ts +107 -0
- package/dist/backend/services/scope-completeness.d.ts.map +1 -0
- package/dist/backend/services/scope-completeness.js +180 -0
- package/dist/backend/services/scope-completeness.js.map +1 -0
- package/dist/backend/services/scope-overview.service.d.ts +112 -0
- package/dist/backend/services/scope-overview.service.d.ts.map +1 -0
- package/dist/backend/services/scope-overview.service.js +372 -0
- package/dist/backend/services/scope-overview.service.js.map +1 -0
- package/dist/backend/services/sql-id-arrays.d.ts +16 -0
- package/dist/backend/services/sql-id-arrays.d.ts.map +1 -0
- package/dist/backend/services/sql-id-arrays.js +24 -0
- package/dist/backend/services/sql-id-arrays.js.map +1 -0
- package/dist/backend/services/storefront-value-overrides.d.ts +31 -0
- package/dist/backend/services/storefront-value-overrides.d.ts.map +1 -0
- package/dist/backend/services/storefront-value-overrides.js +48 -0
- package/dist/backend/services/storefront-value-overrides.js.map +1 -0
- package/dist/backend/services/url-key-resolution.service.d.ts +76 -0
- package/dist/backend/services/url-key-resolution.service.d.ts.map +1 -0
- package/dist/backend/services/url-key-resolution.service.js +179 -0
- package/dist/backend/services/url-key-resolution.service.js.map +1 -0
- package/dist/backend/services/url-key.service.d.ts +171 -0
- package/dist/backend/services/url-key.service.d.ts.map +1 -0
- package/dist/backend/services/url-key.service.js +738 -0
- package/dist/backend/services/url-key.service.js.map +1 -0
- package/dist/manifest.d.ts +3 -1
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +188 -13
- package/dist/manifest.js.map +1 -1
- package/dist/migrations/20261016T082008_catalog_order_rules.d.ts +22 -0
- package/dist/migrations/20261016T082008_catalog_order_rules.d.ts.map +1 -0
- package/dist/migrations/20261016T082008_catalog_order_rules.js +48 -0
- package/dist/migrations/20261016T082008_catalog_order_rules.js.map +1 -0
- package/dist/migrations/20261022T035133_catalog_product_scopes.d.ts +28 -0
- package/dist/migrations/20261022T035133_catalog_product_scopes.d.ts.map +1 -0
- package/dist/migrations/20261022T035133_catalog_product_scopes.js +92 -0
- package/dist/migrations/20261022T035133_catalog_product_scopes.js.map +1 -0
- package/dist/migrations/20261022T054223_catalog_product_url_keys.d.ts +32 -0
- package/dist/migrations/20261022T054223_catalog_product_url_keys.d.ts.map +1 -0
- package/dist/migrations/20261022T054223_catalog_product_url_keys.js +81 -0
- package/dist/migrations/20261022T054223_catalog_product_url_keys.js.map +1 -0
- package/dist/migrations/20261022T111811_catalog_price_fields_removed.d.ts +26 -0
- package/dist/migrations/20261022T111811_catalog_price_fields_removed.d.ts.map +1 -0
- package/dist/migrations/20261022T111811_catalog_price_fields_removed.js +32 -0
- package/dist/migrations/20261022T111811_catalog_price_fields_removed.js.map +1 -0
- package/dist/migrations/20261022T182523_catalog_admin_name_keys.d.ts +38 -0
- package/dist/migrations/20261022T182523_catalog_admin_name_keys.d.ts.map +1 -0
- package/dist/migrations/20261022T182523_catalog_admin_name_keys.js +89 -0
- package/dist/migrations/20261022T182523_catalog_admin_name_keys.js.map +1 -0
- package/dist/migrations/20261025T222634_catalog_product_status_drop_draft.d.ts +34 -0
- package/dist/migrations/20261025T222634_catalog_product_status_drop_draft.d.ts.map +1 -0
- package/dist/migrations/20261025T222634_catalog_product_status_drop_draft.js +57 -0
- package/dist/migrations/20261025T222634_catalog_product_status_drop_draft.js.map +1 -0
- package/dist/migrations/20261026T033453_catalog_product_media_scopes.d.ts +26 -0
- package/dist/migrations/20261026T033453_catalog_product_media_scopes.d.ts.map +1 -0
- package/dist/migrations/20261026T033453_catalog_product_media_scopes.js +54 -0
- package/dist/migrations/20261026T033453_catalog_product_media_scopes.js.map +1 -0
- package/dist/migrations/20261026T084533_catalog_attachment_packaging_translations.d.ts +27 -0
- package/dist/migrations/20261026T084533_catalog_attachment_packaging_translations.d.ts.map +1 -0
- package/dist/migrations/20261026T084533_catalog_attachment_packaging_translations.js +45 -0
- package/dist/migrations/20261026T084533_catalog_attachment_packaging_translations.js.map +1 -0
- package/dist/migrations/index.d.ts +9 -1
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +17 -1
- package/dist/migrations/index.js.map +1 -1
- package/docs/catalog/attachments.md +46 -4
- package/docs/catalog/attributes.md +11 -6
- package/docs/catalog/gallery-and-labels.md +63 -4
- package/docs/catalog/packaging-units.md +82 -8
- package/docs/catalog/per-channel-per-language-overrides.md +195 -10
- package/docs/catalog/url-keys-and-redirects.md +142 -0
- package/docs/catalog.md +326 -17
- package/i18n/en.json +931 -53
- package/i18n/pl.json +930 -52
- package/package.json +10 -10
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { useNavigate, useParams } from 'react-router-dom';
|
|
4
|
-
import { Trash2, ChevronLeft, Copy, Eye, FileText as FileTextIcon, Globe,
|
|
5
|
-
import { ApiError, apiClient,
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState, } from 'react';
|
|
3
|
+
import { useNavigate, useParams, useSearchParams } from 'react-router-dom';
|
|
4
|
+
import { Archive, ArchiveRestore, Trash2, ChevronLeft, Copy, Eye, FileText as FileTextIcon, Globe, Image as ImageIcon, CircleDollarSign, Layers, LayoutGrid, Link as LinkIcon, Paperclip, Save, SlidersHorizontal, Store as StoreIcon, Warehouse as WarehouseIcon, } from 'lucide-react';
|
|
5
|
+
import { ApiError, apiClient, useAuth, useUnsavedChangesPrompt, cn } from '@endora-commerce/admin-kit/lib';
|
|
6
6
|
import { Alert, AlertDescription, Button, Card, CardContent, CardHeader, CardTitle, Input, Label, Select, Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@endora-commerce/admin-kit/ui';
|
|
7
|
-
import {
|
|
7
|
+
import { ModalDialog, StickyFormActions, CategoryTreePicker, ProductPicker } from '@endora-commerce/admin-kit/components';
|
|
8
8
|
import { useTranslation } from '@endora-commerce/admin-kit/i18n';
|
|
9
9
|
import { AdminZone, useAdminZone } from '@endora-commerce/admin-kit/zones';
|
|
10
10
|
import { ProductInventoryTab } from '../components/ProductInventoryTab.js';
|
|
11
11
|
import { PackagingUnitsEditor } from '../components/PackagingUnitsEditor.js';
|
|
12
|
+
import { ProductOrderRulesCard } from '../components/ProductOrderRulesCard.js';
|
|
12
13
|
import { ProductAttributesTab } from '../components/ProductAttributesTab.js';
|
|
14
|
+
import { ProductScopeOverview } from '../components/ProductScopeOverview.js';
|
|
15
|
+
import { ProductUrlKeysPanel } from '../components/ProductUrlKeysPanel.js';
|
|
16
|
+
import { GallerySection } from '../components/ProductGallerySection.js';
|
|
17
|
+
import { AttachmentsSection } from '../components/ProductAttachmentsSection.js';
|
|
18
|
+
import { ArchivedPill, ProductStatusPill } from '../components/ProductStatusPills.js';
|
|
13
19
|
import { ProductScopeEditor, } from '../components/ProductScopeEditor.js';
|
|
20
|
+
import { checkWindowInputs, isoToLocalInput } from '../lib/product-scope-drafts.js';
|
|
21
|
+
import { describeIncompletePair, getProductScopes, isScopeIncomplete, loadChannelNamer, scopeSaveErrorMessage, } from '../lib/product-scopes-api.js';
|
|
14
22
|
const LOCALES = ['en-US', 'pl-PL'];
|
|
15
23
|
const PRODUCT_TYPES = [
|
|
16
24
|
'simple',
|
|
@@ -20,7 +28,23 @@ const PRODUCT_TYPES = [
|
|
|
20
28
|
'virtual',
|
|
21
29
|
];
|
|
22
30
|
const VISIBILITIES = ['public', 'logged_in_only', 'organization_restricted'];
|
|
23
|
-
const STATUSES = ['
|
|
31
|
+
const STATUSES = ['active', 'inactive'];
|
|
32
|
+
/**
|
|
33
|
+
* The tabs `?tab=` may open (review D3: the bulk scoped-status result links to
|
|
34
|
+
* `?tab=scopes`) — those every saved product shows. A type-dependent or zone-counted
|
|
35
|
+
* tab, or an unknown value, opens Details.
|
|
36
|
+
*/
|
|
37
|
+
const LINKABLE_TABS = new Set([
|
|
38
|
+
'details',
|
|
39
|
+
'attributes',
|
|
40
|
+
'pricing',
|
|
41
|
+
'media',
|
|
42
|
+
'inventory',
|
|
43
|
+
'attachments',
|
|
44
|
+
'links',
|
|
45
|
+
'scopes',
|
|
46
|
+
'seo',
|
|
47
|
+
]);
|
|
24
48
|
/**
|
|
25
49
|
* Order-insensitive JSON snapshot of the editable form fields, used to detect
|
|
26
50
|
* unsaved changes (object keys + array members are sorted so re-ordering alone
|
|
@@ -48,27 +72,49 @@ export function ProductEditor() {
|
|
|
48
72
|
const channelContributions = useAdminZone('product.editor.channels', {
|
|
49
73
|
productId: id ?? '',
|
|
50
74
|
});
|
|
75
|
+
// Archive / Restore write the catalogue (FR-019): an operator without
|
|
76
|
+
// `catalog:write` is not offered either.
|
|
77
|
+
const { hasPermission } = useAuth();
|
|
78
|
+
const canWrite = hasPermission('catalog:write');
|
|
51
79
|
const [loading, setLoading] = useState(!isNew);
|
|
52
80
|
const [error, setError] = useState(null);
|
|
53
81
|
const [info, setInfo] = useState(null);
|
|
82
|
+
// Feature 163 (US6, G-2) — what the completeness check reported on the last Save.
|
|
83
|
+
const [gateWarning, setGateWarning] = useState(null);
|
|
84
|
+
// The product's archived state, read with the product and
|
|
85
|
+
// moved only by the Archive / Restore actions below, never by Save.
|
|
86
|
+
const [archivedAt, setArchivedAt] = useState(null);
|
|
87
|
+
const [archiveDialog, setArchiveDialog] = useState(null);
|
|
88
|
+
const [archiving, setArchiving] = useState(false);
|
|
89
|
+
const [archiveError, setArchiveError] = useState(null);
|
|
54
90
|
const [categories, setCategories] = useState([]);
|
|
55
91
|
const [sku, setSku] = useState('');
|
|
56
92
|
const [type, setType] = useState('simple');
|
|
57
|
-
const [status, setStatus] = useState('
|
|
93
|
+
const [status, setStatus] = useState('inactive');
|
|
58
94
|
const [visibility, setVisibility] = useState('public');
|
|
59
95
|
const [name, setName] = useState({ 'en-US': '', 'pl-PL': '' });
|
|
60
96
|
const [description, setDescription] = useState({
|
|
61
97
|
'en-US': '',
|
|
62
98
|
'pl-PL': '',
|
|
63
99
|
});
|
|
64
|
-
const [defaultPrice, setDefaultPrice] = useState('');
|
|
65
100
|
const [categoryIds, setCategoryIds] = useState([]);
|
|
66
|
-
const [
|
|
101
|
+
const [searchParams] = useSearchParams();
|
|
102
|
+
const [activeTab, setActiveTab] = useState(() => {
|
|
103
|
+
const linked = searchParams.get('tab');
|
|
104
|
+
return !isNew && linked !== null && LINKABLE_TABS.has(linked) ? linked : 'details';
|
|
105
|
+
});
|
|
67
106
|
// Feature 002 (T034) — Attribute Set selector
|
|
68
107
|
const [attributeSets, setAttributeSets] = useState([]);
|
|
69
108
|
const [attributeSetId, setAttributeSetId] = useState('');
|
|
70
109
|
// Editable attribute values keyed by attribute `key` (Attributes tab).
|
|
71
110
|
const [attrValues, setAttrValues] = useState({});
|
|
111
|
+
// Feature 163 (FR-023) — the global publication window, as `datetime-local`
|
|
112
|
+
// values in the operator's zone. `loadedWindow` is what the server holds, so
|
|
113
|
+
// the page PATCH carries the window only when it changed.
|
|
114
|
+
const [publishFrom, setPublishFrom] = useState('');
|
|
115
|
+
const [publishUntil, setPublishUntil] = useState('');
|
|
116
|
+
const [loadedWindow, setLoadedWindow] = useState({ from: '', until: '' });
|
|
117
|
+
const [windowError, setWindowError] = useState(null);
|
|
72
118
|
// Feature 023 — imperative handle on the scope-editor so the page Save
|
|
73
119
|
// can flush every pending channel-scoped override in a single PATCH.
|
|
74
120
|
const scopeEditorRef = useRef(null);
|
|
@@ -86,15 +132,27 @@ export function ProductEditor() {
|
|
|
86
132
|
visibility,
|
|
87
133
|
name,
|
|
88
134
|
description,
|
|
89
|
-
defaultPrice,
|
|
90
135
|
categoryIds,
|
|
91
136
|
attributeSetId,
|
|
92
137
|
attrValues,
|
|
138
|
+
publishFrom,
|
|
139
|
+
publishUntil,
|
|
93
140
|
});
|
|
141
|
+
// Review D4 — the gallery's staged edits are unsaved changes too. The gallery stays
|
|
142
|
+
// mounted once its tab is opened (hidden on the other tabs), so its staging survives a
|
|
143
|
+
// tab switch and the page Save still writes it.
|
|
144
|
+
const [galleryDirty, setGalleryDirty] = useState(false);
|
|
145
|
+
const [galleryOpened, setGalleryOpened] = useState(false);
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
if (activeTab === 'media')
|
|
148
|
+
setGalleryOpened(true);
|
|
149
|
+
}, [activeTab]);
|
|
94
150
|
const dirty = !loading &&
|
|
95
|
-
initialSnapshotRef.current !== '' &&
|
|
96
|
-
currentSnapshot !== initialSnapshotRef.current;
|
|
151
|
+
((initialSnapshotRef.current !== '' && currentSnapshot !== initialSnapshotRef.current) || galleryDirty);
|
|
97
152
|
useUnsavedChangesPrompt(dirty);
|
|
153
|
+
// Read through a ref so a language switch does not re-load the product (and drop edits).
|
|
154
|
+
const tRef = useRef(t);
|
|
155
|
+
tRef.current = t;
|
|
98
156
|
const refresh = useCallback(async () => {
|
|
99
157
|
setLoading(true);
|
|
100
158
|
setError(null);
|
|
@@ -114,14 +172,15 @@ export function ProductEditor() {
|
|
|
114
172
|
initialSnapshotRef.current = stableSnapshot({
|
|
115
173
|
sku: '',
|
|
116
174
|
type: 'simple',
|
|
117
|
-
status: '
|
|
175
|
+
status: 'inactive',
|
|
118
176
|
visibility: 'public',
|
|
119
177
|
name: { 'en-US': '', 'pl-PL': '' },
|
|
120
178
|
description: { 'en-US': '', 'pl-PL': '' },
|
|
121
|
-
defaultPrice: '',
|
|
122
179
|
categoryIds: [],
|
|
123
180
|
attributeSetId: defaultSet?.id ?? '',
|
|
124
181
|
attrValues: {},
|
|
182
|
+
publishFrom: '',
|
|
183
|
+
publishUntil: '',
|
|
125
184
|
});
|
|
126
185
|
}
|
|
127
186
|
if (id) {
|
|
@@ -130,6 +189,7 @@ export function ProductEditor() {
|
|
|
130
189
|
setSku(p.sku);
|
|
131
190
|
setType(p.type);
|
|
132
191
|
setStatus(p.status);
|
|
192
|
+
setArchivedAt(p.archivedAt ?? null);
|
|
133
193
|
setVisibility(p.visibility);
|
|
134
194
|
const loadedName = {
|
|
135
195
|
'en-US': p.name['en-US'] ?? '',
|
|
@@ -141,12 +201,26 @@ export function ProductEditor() {
|
|
|
141
201
|
'pl-PL': p.description['pl-PL'] ?? '',
|
|
142
202
|
};
|
|
143
203
|
setDescription(loadedDescription);
|
|
144
|
-
const price = p.attributeValues['defaultPrice'] ?? null;
|
|
145
|
-
const loadedPrice = price != null ? String(price) : '';
|
|
146
|
-
setDefaultPrice(loadedPrice);
|
|
147
204
|
setAttrValues(p.attributeValues ?? {});
|
|
148
205
|
setAttributeSetId(p.attributeSetId);
|
|
149
206
|
setCategoryIds(p.categoryIds ?? []);
|
|
207
|
+
// Feature 163 — the global window is read from the scopes answer (the
|
|
208
|
+
// product answer does not carry it). A failed read leaves the fields
|
|
209
|
+
// empty and unchanged, so nothing is sent for them on save.
|
|
210
|
+
let loadedFrom = '';
|
|
211
|
+
let loadedUntil = '';
|
|
212
|
+
try {
|
|
213
|
+
const scopes = await getProductScopes(id);
|
|
214
|
+
loadedFrom = isoToLocalInput(scopes?.global?.publishFrom ?? null);
|
|
215
|
+
loadedUntil = isoToLocalInput(scopes?.global?.publishUntil ?? null);
|
|
216
|
+
}
|
|
217
|
+
catch {
|
|
218
|
+
// Best effort — the rest of the editor stays usable.
|
|
219
|
+
}
|
|
220
|
+
setPublishFrom(loadedFrom);
|
|
221
|
+
setPublishUntil(loadedUntil);
|
|
222
|
+
setLoadedWindow({ from: loadedFrom, until: loadedUntil });
|
|
223
|
+
setWindowError(null);
|
|
150
224
|
// Capture the loaded state as the clean baseline for dirty-tracking.
|
|
151
225
|
initialSnapshotRef.current = stableSnapshot({
|
|
152
226
|
sku: p.sku,
|
|
@@ -155,15 +229,16 @@ export function ProductEditor() {
|
|
|
155
229
|
visibility: p.visibility,
|
|
156
230
|
name: loadedName,
|
|
157
231
|
description: loadedDescription,
|
|
158
|
-
defaultPrice: loadedPrice,
|
|
159
232
|
categoryIds: p.categoryIds ?? [],
|
|
160
233
|
attributeSetId: p.attributeSetId,
|
|
161
234
|
attrValues: p.attributeValues ?? {},
|
|
235
|
+
publishFrom: loadedFrom,
|
|
236
|
+
publishUntil: loadedUntil,
|
|
162
237
|
});
|
|
163
238
|
}
|
|
164
239
|
}
|
|
165
240
|
catch (err) {
|
|
166
|
-
setError(err instanceof ApiError ? err.envelope.error.message : '
|
|
241
|
+
setError(err instanceof ApiError ? err.envelope.error.message : tRef.current('productEditor.error.load'));
|
|
167
242
|
}
|
|
168
243
|
finally {
|
|
169
244
|
setLoading(false);
|
|
@@ -176,6 +251,7 @@ export function ProductEditor() {
|
|
|
176
251
|
e.preventDefault();
|
|
177
252
|
setError(null);
|
|
178
253
|
setInfo(null);
|
|
254
|
+
setGateWarning(null);
|
|
179
255
|
const trimmedName = {};
|
|
180
256
|
const trimmedDescription = {};
|
|
181
257
|
for (const l of LOCALES) {
|
|
@@ -185,26 +261,33 @@ export function ProductEditor() {
|
|
|
185
261
|
trimmedDescription[l] = description[l];
|
|
186
262
|
}
|
|
187
263
|
if (Object.keys(trimmedName).length === 0) {
|
|
188
|
-
setError('
|
|
264
|
+
setError(t('productEditor.error.nameRequired'));
|
|
189
265
|
return;
|
|
190
266
|
}
|
|
191
|
-
//
|
|
192
|
-
//
|
|
267
|
+
// The Attributes-tab edits. A product has no price of its own: prices
|
|
268
|
+
// are set in price books (feature 160), so nothing else is added here.
|
|
193
269
|
const attributeValues = { ...attrValues };
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
270
|
+
// Feature 163 (FR-023) — the window travels only when it changed, and
|
|
271
|
+
// a window that does not start before it ends is refused here, beside
|
|
272
|
+
// its fields, without a request.
|
|
273
|
+
let windowPatch = null;
|
|
274
|
+
if (publishFrom !== loadedWindow.from || publishUntil !== loadedWindow.until) {
|
|
275
|
+
const check = checkWindowInputs(publishFrom, publishUntil);
|
|
276
|
+
if (!check.ok) {
|
|
277
|
+
setWindowError(check.reason);
|
|
199
278
|
return;
|
|
200
279
|
}
|
|
201
|
-
|
|
280
|
+
windowPatch = { publishFrom: check.from, publishUntil: check.until };
|
|
202
281
|
}
|
|
282
|
+
setWindowError(null);
|
|
203
283
|
try {
|
|
204
284
|
if (isNew) {
|
|
205
285
|
const res = await apiClient.post('/api/v1/admin/catalog/products', {
|
|
206
286
|
sku,
|
|
207
287
|
type,
|
|
288
|
+
// A new product is `inactive` unless the operator chose otherwise
|
|
289
|
+
// (FR-010, Q1-d); the selector's value is sent, not assumed.
|
|
290
|
+
status,
|
|
208
291
|
name: trimmedName,
|
|
209
292
|
description: trimmedDescription,
|
|
210
293
|
categoryIds,
|
|
@@ -215,40 +298,64 @@ export function ProductEditor() {
|
|
|
215
298
|
navigate(`/catalog/products/${res.data.id}`);
|
|
216
299
|
}
|
|
217
300
|
else if (id) {
|
|
218
|
-
// Feature 023 — page-Save commits
|
|
219
|
-
//
|
|
220
|
-
//
|
|
221
|
-
//
|
|
222
|
-
//
|
|
301
|
+
// Feature 023 — page-Save commits the per-language baseline (the product
|
|
302
|
+
// PATCH) and the drafts staged in the ProductScopeEditor panel and the
|
|
303
|
+
// gallery. Feature 163 (US6 #3): the PATCH goes first and alone — when the
|
|
304
|
+
// completeness gate refuses it (`422 SCOPE_INCOMPLETE`) nothing else is
|
|
305
|
+
// written, so "not saved, still in the form" is true of the whole change.
|
|
306
|
+
const saved = await apiClient.patch(`/api/v1/admin/catalog/products/${id}`, {
|
|
307
|
+
sku: sku.trim(),
|
|
308
|
+
status,
|
|
309
|
+
name: trimmedName,
|
|
310
|
+
description: trimmedDescription,
|
|
311
|
+
categoryIds,
|
|
312
|
+
attributeValues,
|
|
313
|
+
visibility,
|
|
314
|
+
...(attributeSetId ? { attributeSetId } : {}),
|
|
315
|
+
...(windowPatch ?? {}),
|
|
316
|
+
});
|
|
223
317
|
await Promise.all([
|
|
224
|
-
apiClient.patch(`/api/v1/admin/catalog/products/${id}`, {
|
|
225
|
-
sku: sku.trim(),
|
|
226
|
-
status,
|
|
227
|
-
name: trimmedName,
|
|
228
|
-
description: trimmedDescription,
|
|
229
|
-
categoryIds,
|
|
230
|
-
attributeValues,
|
|
231
|
-
visibility,
|
|
232
|
-
...(attributeSetId ? { attributeSetId } : {}),
|
|
233
|
-
}),
|
|
234
318
|
scopeEditorRef.current?.flushOverrides() ?? Promise.resolve(),
|
|
235
319
|
galleryRef.current?.flushGallery() ?? Promise.resolve(),
|
|
236
320
|
]);
|
|
237
|
-
|
|
321
|
+
// The status change was saved; where it switched the product on with values
|
|
322
|
+
// missing (`warn` mode) the page says what, by channel and language — instead
|
|
323
|
+
// of "Saved.", which would read as "nothing left to do".
|
|
324
|
+
const completeness = (saved.warnings ?? []).filter((w) => w.kind === 'completeness');
|
|
325
|
+
if (completeness.length > 0) {
|
|
326
|
+
const channelName = await loadChannelNamer(id);
|
|
327
|
+
setGateWarning(t('productEditor.scopeControls.warning.incomplete', {
|
|
328
|
+
details: completeness.map((w) => describeIncompletePair(w, channelName, t)).join('; '),
|
|
329
|
+
}));
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
setInfo(t('productEditor.saved'));
|
|
333
|
+
}
|
|
238
334
|
await refresh();
|
|
239
335
|
}
|
|
240
336
|
}
|
|
241
337
|
catch (err) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
338
|
+
if (id && isScopeIncomplete(err)) {
|
|
339
|
+
// `refuse` mode: nothing in this request was saved; the edits stay in the form.
|
|
340
|
+
const channelName = await loadChannelNamer(id);
|
|
341
|
+
setError(scopeSaveErrorMessage(err, channelName, t, 'productEditor.scopeControls.error.generic', 'productEditor.statusGate.refused'));
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
const windowRefused = err instanceof ApiError &&
|
|
345
|
+
err.envelope.error.details?.field === 'window';
|
|
346
|
+
setError(windowRefused
|
|
347
|
+
? t('productEditor.error.publishWindow')
|
|
348
|
+
: err instanceof ApiError
|
|
349
|
+
? err.envelope.error.message
|
|
350
|
+
: t('productEditor.error.save'));
|
|
351
|
+
}
|
|
352
|
+
}, [isNew, id, sku, status, type, name, description, categoryIds, attrValues, attributeSetId, visibility, navigate, refresh, publishFrom, publishUntil, loadedWindow, t]);
|
|
245
353
|
const handleAttrChange = useCallback((key, value) => {
|
|
246
354
|
setAttrValues((prev) => ({ ...prev, [key]: value }));
|
|
247
355
|
}, []);
|
|
248
356
|
// Swapping the Attribute Set drops the values whose keys are not in the
|
|
249
357
|
// newly-selected set, so the save payload doesn't carry orphan keys left
|
|
250
|
-
// over from the previous set.
|
|
251
|
-
// owned by the Details tab (not bound to any set) and are always kept.
|
|
358
|
+
// over from the previous set.
|
|
252
359
|
const handleAttributeSetChange = useCallback(async (newSetId) => {
|
|
253
360
|
setAttributeSetId(newSetId);
|
|
254
361
|
if (!newSetId)
|
|
@@ -259,7 +366,7 @@ export function ProductEditor() {
|
|
|
259
366
|
setAttrValues((prev) => {
|
|
260
367
|
const next = {};
|
|
261
368
|
for (const [k, v] of Object.entries(prev)) {
|
|
262
|
-
if (allowed.has(k)
|
|
369
|
+
if (allowed.has(k)) {
|
|
263
370
|
next[k] = v;
|
|
264
371
|
}
|
|
265
372
|
}
|
|
@@ -281,14 +388,14 @@ export function ProductEditor() {
|
|
|
281
388
|
navigate('/catalog/products');
|
|
282
389
|
}
|
|
283
390
|
catch (err) {
|
|
284
|
-
setError(err instanceof ApiError ? err.envelope.error.message : '
|
|
391
|
+
setError(err instanceof ApiError ? err.envelope.error.message : t('productEditor.error.delete'));
|
|
285
392
|
}
|
|
286
393
|
}, [id, navigate, t]);
|
|
287
394
|
const [duplicating, setDuplicating] = useState(false);
|
|
288
395
|
const handleDuplicate = useCallback(async () => {
|
|
289
396
|
if (!id || duplicating)
|
|
290
397
|
return;
|
|
291
|
-
if (!confirm('
|
|
398
|
+
if (!confirm(t('productEditor.duplicateConfirm')))
|
|
292
399
|
return;
|
|
293
400
|
setDuplicating(true);
|
|
294
401
|
setError(null);
|
|
@@ -297,18 +404,42 @@ export function ProductEditor() {
|
|
|
297
404
|
navigate(`/catalog/products/${res.data.id}`);
|
|
298
405
|
}
|
|
299
406
|
catch (err) {
|
|
300
|
-
setError(err instanceof ApiError ? err.envelope.error.message : '
|
|
407
|
+
setError(err instanceof ApiError ? err.envelope.error.message : t('productEditor.error.duplicate'));
|
|
301
408
|
}
|
|
302
409
|
finally {
|
|
303
410
|
setDuplicating(false);
|
|
304
411
|
}
|
|
305
|
-
}, [id, duplicating, navigate]);
|
|
412
|
+
}, [id, duplicating, navigate, t]);
|
|
413
|
+
// Archive / Restore take effect at once, through their own
|
|
414
|
+
// routes; they touch `archivedAt` only, so the form's unsaved edits (status
|
|
415
|
+
// included) are neither sent nor lost.
|
|
416
|
+
const handleArchiveAction = useCallback(async () => {
|
|
417
|
+
if (!id || archiveDialog === null || archiving)
|
|
418
|
+
return;
|
|
419
|
+
setArchiving(true);
|
|
420
|
+
setArchiveError(null);
|
|
421
|
+
try {
|
|
422
|
+
const res = await apiClient.post(`/api/v1/admin/catalog/products/${id}/${archiveDialog}`, {});
|
|
423
|
+
setArchivedAt(res.data.archivedAt ?? null);
|
|
424
|
+
setInfo(t(archiveDialog === 'archive' ? 'productEditor.archive.done' : 'productEditor.restore.done'));
|
|
425
|
+
setError(null);
|
|
426
|
+
setArchiveDialog(null);
|
|
427
|
+
}
|
|
428
|
+
catch (err) {
|
|
429
|
+
setArchiveError(err instanceof ApiError
|
|
430
|
+
? err.envelope.error.message
|
|
431
|
+
: t(archiveDialog === 'archive' ? 'productEditor.archive.failed' : 'productEditor.restore.failed'));
|
|
432
|
+
}
|
|
433
|
+
finally {
|
|
434
|
+
setArchiving(false);
|
|
435
|
+
}
|
|
436
|
+
}, [id, archiveDialog, archiving, t]);
|
|
306
437
|
if (loading)
|
|
307
438
|
return (_jsx("div", { className: "b2b-page b2b-page--wide", children: _jsx("div", { style: { padding: 32, color: 'var(--fg-muted)', fontSize: 13 }, children: t('productEditor.loading') }) }));
|
|
308
439
|
const tabs = [
|
|
309
440
|
{ id: 'details', label: 'Details', icon: _jsx(FileTextIcon, { size: 14 }), show: true },
|
|
310
441
|
{ id: 'attributes', label: 'Attributes', icon: _jsx(SlidersHorizontal, { size: 14 }), show: !isNew },
|
|
311
|
-
{ id: 'pricing', label: '
|
|
442
|
+
{ id: 'pricing', label: t('productEditor.tab.pricing'), icon: _jsx(CircleDollarSign, { size: 14 }), show: !isNew },
|
|
312
443
|
{
|
|
313
444
|
id: 'variants',
|
|
314
445
|
label: 'Variants',
|
|
@@ -337,35 +468,46 @@ export function ProductEditor() {
|
|
|
337
468
|
icon: _jsx(StoreIcon, { size: 14 }),
|
|
338
469
|
show: !isNew && channelContributions.length > 0,
|
|
339
470
|
},
|
|
471
|
+
// Feature 163 (US4) — channels × languages for this product, beside the channels it is in.
|
|
472
|
+
{ id: 'scopes', label: t('productEditor.tab.scopes'), icon: _jsx(LayoutGrid, { size: 14 }), show: !isNew },
|
|
340
473
|
{ id: 'seo', label: 'SEO', icon: _jsx(Globe, { size: 14 }), show: !isNew },
|
|
341
474
|
];
|
|
342
475
|
const visibleTabs = tabs.filter((t) => t.show);
|
|
343
|
-
return (_jsxs("div", { className: "b2b-page b2b-page--wide", children: [_jsxs("div", { className: "b2b-page-head", children: [_jsxs("div", { className: "b2b-grow", children: [_jsxs("button", { type: "button", className: "b2b-page-head__back", onClick: () => { navigate('/catalog/products'); }, children: [_jsx(ChevronLeft, { size: 14 }), " Products"] }), _jsxs("div", { className: "b2b-page-head__title", children: [_jsx("span", { children: isNew ? 'New product' : pickName(name) || sku }), !isNew ? _jsx(
|
|
476
|
+
return (_jsxs("div", { className: "b2b-page b2b-page--wide", children: [_jsxs("div", { className: "b2b-page-head", children: [_jsxs("div", { className: "b2b-grow", children: [_jsxs("button", { type: "button", className: "b2b-page-head__back", onClick: () => { navigate('/catalog/products'); }, children: [_jsx(ChevronLeft, { size: 14 }), " Products"] }), _jsxs("div", { className: "b2b-page-head__title", children: [_jsx("span", { children: isNew ? 'New product' : pickName(name) || sku }), !isNew ? _jsx(ProductStatusPill, { status: status, archived: Boolean(archivedAt) }) : null, !isNew && archivedAt ? _jsx(ArchivedPill, {}) : null] }), !isNew ? (_jsxs("div", { className: "b2b-page-head__sub", children: [_jsx("span", { className: "b2b-mono", children: sku }), " \u00B7 ", _jsx("span", { style: { textTransform: 'capitalize' }, children: type })] })) : null] }), _jsxs(StickyFormActions, { className: "b2b-page-head__actions", children: [!isNew ? (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: "b2b-btn b2b-btn--default b2b-btn--sm", children: [_jsx(Eye, { size: 13 }), " Preview"] }), _jsxs("button", { type: "button", className: "b2b-btn b2b-btn--default b2b-btn--sm", onClick: () => void handleDuplicate(), disabled: duplicating, children: [_jsx(Copy, { size: 13 }), " ", duplicating ? 'Duplicating…' : 'Duplicate'] }), canWrite && !archivedAt ? (_jsxs("button", { type: "button", className: "b2b-btn b2b-btn--default b2b-btn--sm", onClick: () => {
|
|
477
|
+
setArchiveError(null);
|
|
478
|
+
setArchiveDialog('archive');
|
|
479
|
+
}, children: [_jsx(Archive, { size: 13, "aria-hidden": "true" }), " ", t('productEditor.action.archive')] })) : null, _jsxs("button", { type: "button", className: "b2b-btn b2b-btn--danger b2b-btn--sm", onClick: () => void handleDeleteProduct(), children: [_jsx(Trash2, { size: 13 }), " ", t('productEditor.action.delete')] })] })) : null, _jsxs("button", { type: "button", className: "b2b-btn b2b-btn--primary", onClick: (e) => {
|
|
344
480
|
void handleSave(e);
|
|
345
|
-
}, children: [_jsx(Save, { size: 14 }), " Save"] })] })] }), error ? (_jsx(Alert, { variant: "destructive", className: "mb-4", children: _jsx(AlertDescription, { children: error }) })) : null, info ? (_jsx(Alert, { variant: "success", className: "mb-4", children: _jsx(AlertDescription, { children: info }) })) : null,
|
|
481
|
+
}, children: [_jsx(Save, { size: 14 }), " Save"] })] })] }), error ? (_jsx(Alert, { variant: "destructive", className: "mb-4", children: _jsx(AlertDescription, { children: error }) })) : null, info ? (_jsx(Alert, { variant: "success", className: "mb-4", children: _jsx(AlertDescription, { children: info }) })) : null, _jsx("div", { role: "status", children: gateWarning ? (_jsx(Alert, { variant: "warning", role: "none", className: "mb-4", "data-testid": "product-gate-warning", children: _jsx(AlertDescription, { children: gateWarning }) })) : null }), !isNew && archivedAt ? (_jsx(Alert, { variant: "warning", role: "status", className: "mb-4", "data-testid": "product-archived-notice", children: _jsx(AlertDescription, { children: _jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [_jsxs("span", { className: "flex-1", children: [_jsx("strong", { children: t('productEditor.archived.title') }), ' ', t('productEditor.archived.body')] }), canWrite ? (_jsxs(Button, { type: "button", variant: "outline", size: "sm", onClick: () => {
|
|
482
|
+
setArchiveError(null);
|
|
483
|
+
setArchiveDialog('restore');
|
|
484
|
+
}, children: [_jsx(ArchiveRestore, { size: 13, "aria-hidden": "true" }), " ", t('productEditor.action.restore')] })) : null] }) }) })) : null, archiveDialog !== null ? (_jsxs(ModalDialog, { title: t(archiveDialog === 'archive' ? 'productEditor.archive.confirmTitle' : 'productEditor.restore.confirmTitle'), onClose: () => setArchiveDialog(null), busy: archiving, "aria-describedby": "product-archive-confirm-body", footer: _jsxs(_Fragment, { children: [_jsx(Button, { type: "button", variant: "outline", disabled: archiving, onClick: () => setArchiveDialog(null), children: t('productEditor.archive.cancel') }), _jsx(Button, { type: "button", disabled: archiving, "aria-busy": archiving || undefined, onClick: () => {
|
|
485
|
+
void handleArchiveAction();
|
|
486
|
+
}, children: t(archiveDialog === 'archive' ? 'productEditor.archive.confirm' : 'productEditor.restore.confirm') })] }), children: [_jsx("p", { id: "product-archive-confirm-body", className: "text-sm", children: t(archiveDialog === 'archive' ? 'productEditor.archive.confirmBody' : 'productEditor.restore.confirmBody') }), archiveError ? (_jsx("p", { role: "alert", className: "mt-3 text-sm text-destructive", children: archiveError })) : null] })) : null, _jsxs("div", { className: "b2b-card", children: [_jsx("div", { style: { padding: '4px 4px 0', overflow: 'hidden' }, children: _jsx("div", { className: "b2b-tabs-scroll", children: _jsx("div", { className: "b2b-tabs", role: "tablist", children: visibleTabs.map((t) => (_jsxs("button", { type: "button", role: "tab", "aria-selected": activeTab === t.id, className: cn('b2b-tab', activeTab === t.id && 'is-active'), onClick: () => setActiveTab(t.id), children: [t.icon, t.label] }, t.id))) }) }) }), _jsxs("div", { className: "b2b-card__body", children: [activeTab === 'details' ? (_jsx("form", { id: "product-details-form", onSubmit: handleSave, children: _jsxs("div", { className: "b2b-col", style: { gap: 18 }, children: [id ? (_jsx(AdminZone, { name: "product.editor.details.before", props: { productId: id } })) : null, id ? (_jsxs("div", { className: "flex flex-wrap gap-x-4 gap-y-1", children: [_jsx(AdminZone, { name: "product.editor.field.after", props: { productId: id, fieldPath: 'name', languageCodes: LOCALES } }), _jsx(AdminZone, { name: "product.editor.field.after", props: { productId: id, fieldPath: 'description', languageCodes: LOCALES } })] })) : null, id ? (_jsx(ProductScopeEditor, { ref: scopeEditorRef, productId: id, baselineName: name, baselineDescription: description, globalStatus: status, onBaselineNameChange: (next) => setName({
|
|
346
487
|
'en-US': next['en-US'] ?? '',
|
|
347
488
|
'pl-PL': next['pl-PL'] ?? '',
|
|
348
489
|
}), onBaselineDescriptionChange: (next) => setDescription({
|
|
349
490
|
'en-US': next['en-US'] ?? '',
|
|
350
491
|
'pl-PL': next['pl-PL'] ?? '',
|
|
351
|
-
}) })) : null, _jsxs("div", { children: [_jsx("div", { className: "b2b-label", children: t('productEditor.section.identity') }), _jsxs("div", { style: { display: 'grid', gridTemplateColumns: '1fr 1fr 1fr', gap: 12 }, children: [_jsxs("div", { children: [_jsx(Label, { htmlFor: "sku", children: t('productEditor.field.sku') }), _jsx(Input, { id: "sku", value: sku, onChange: (e) => setSku(e.target.value), required: true })] }), _jsxs("div", { children: [_jsx(Label, { htmlFor: "ptype", children: t('productEditor.field.type') }), _jsx(Select, { id: "ptype", value: type, onChange: (e) => setType(e.target.value), disabled: !isNew, children: PRODUCT_TYPES.map((pt) => (_jsx("option", { value: pt, children: pt }, pt))) })] }), _jsxs("div", { children: [_jsx(Label, { htmlFor: "pvis", children: t('productEditor.field.visibility') }), _jsx(Select, { id: "pvis", value: visibility, onChange: (e) => setVisibility(e.target.value), children: VISIBILITIES.map((v) => (_jsx("option", { value: v, children: v }, v))) })] }), _jsxs("div", { children: [_jsx(Label, { htmlFor: "pattrset", children: t('productEditor.field.attributeSet') }), _jsx(Select, { id: "pattrset", value: attributeSetId, onChange: (e) => void handleAttributeSetChange(e.target.value), children: attributeSets.length === 0 ? (_jsx("option", { value: "", children: t('productEditor.attributeSet.loading') })) : (attributeSets.map((s) => (_jsxs("option", { value: s.id, children: [s.code, s.isSystem ? t('productEditor.attributeSet.systemSuffix') : ''] }, s.id)))) })] }), _jsxs("div", { children: [_jsx(Label, { htmlFor: "pstatus", children: t('productEditor.field.status') }), _jsx(Select, { id: "pstatus", value: status, onChange: (e) => setStatus(e.target.value), children: STATUSES.map((s) => (_jsx("option", { value: s, children: s }, s))) }), _jsx("p", { className: "b2b-help", children: t('productEditor.field.status.help') })
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
492
|
+
}) })) : null, _jsxs("div", { children: [_jsx("div", { className: "b2b-label", children: t('productEditor.section.identity') }), _jsxs("div", { style: { display: 'grid', gridTemplateColumns: '1fr 1fr 1fr', gap: 12 }, children: [_jsxs("div", { children: [_jsx(Label, { htmlFor: "sku", children: t('productEditor.field.sku') }), _jsx(Input, { id: "sku", value: sku, onChange: (e) => setSku(e.target.value), required: true })] }), _jsxs("div", { children: [_jsx(Label, { htmlFor: "ptype", children: t('productEditor.field.type') }), _jsx(Select, { id: "ptype", value: type, onChange: (e) => setType(e.target.value), disabled: !isNew, children: PRODUCT_TYPES.map((pt) => (_jsx("option", { value: pt, children: pt }, pt))) })] }), _jsxs("div", { children: [_jsx(Label, { htmlFor: "pvis", children: t('productEditor.field.visibility') }), _jsx(Select, { id: "pvis", value: visibility, onChange: (e) => setVisibility(e.target.value), children: VISIBILITIES.map((v) => (_jsx("option", { value: v, children: v }, v))) })] }), _jsxs("div", { children: [_jsx(Label, { htmlFor: "pattrset", children: t('productEditor.field.attributeSet') }), _jsx(Select, { id: "pattrset", value: attributeSetId, onChange: (e) => void handleAttributeSetChange(e.target.value), children: attributeSets.length === 0 ? (_jsx("option", { value: "", children: t('productEditor.attributeSet.loading') })) : (attributeSets.map((s) => (_jsxs("option", { value: s.id, children: [s.code, s.isSystem ? t('productEditor.attributeSet.systemSuffix') : ''] }, s.id)))) })] }), _jsxs("div", { children: [_jsx(Label, { htmlFor: "pstatus", children: t('productEditor.field.status') }), _jsx(Select, { id: "pstatus", value: status, "aria-describedby": !isNew && archivedAt ? 'pstatus-help pstatus-archived' : 'pstatus-help', onChange: (e) => setStatus(e.target.value), children: STATUSES.map((s) => (_jsx("option", { value: s, children: t(`productEditor.statusValue.${s}`) }, s))) }), _jsx("p", { id: "pstatus-help", className: "b2b-help", children: t('productEditor.field.status.help') }), !isNew && archivedAt ? (_jsx("p", { id: "pstatus-archived", className: "b2b-help", children: t('productEditor.field.status.archivedNote') })) : null] })] })] }), id ? (_jsxs("div", { children: [_jsx("div", { className: "b2b-label", children: t('productEditor.field.publishWindow') }), _jsxs("div", { className: "b2b-row", style: { gap: 12, flexWrap: 'wrap' }, children: [_jsxs("div", { children: [_jsx(Label, { htmlFor: "ppublish-from", children: t('productEditor.field.publishFrom') }), _jsx(Input, { id: "ppublish-from", type: "datetime-local", value: publishFrom, "aria-describedby": windowError ? 'ppublish-help ppublish-error' : 'ppublish-help', "aria-invalid": windowError === 'invalidDate' ? true : undefined, onKeyDown: (e) => {
|
|
493
|
+
if (e.key === 'Enter')
|
|
494
|
+
e.preventDefault();
|
|
495
|
+
}, onChange: (e) => {
|
|
496
|
+
setPublishFrom(e.target.value);
|
|
497
|
+
setWindowError(null);
|
|
498
|
+
} })] }), _jsxs("div", { children: [_jsx(Label, { htmlFor: "ppublish-until", children: t('productEditor.field.publishUntil') }), _jsx(Input, { id: "ppublish-until", type: "datetime-local", value: publishUntil, "aria-describedby": windowError ? 'ppublish-help ppublish-error' : 'ppublish-help', "aria-invalid": windowError ? true : undefined, onKeyDown: (e) => {
|
|
499
|
+
if (e.key === 'Enter')
|
|
500
|
+
e.preventDefault();
|
|
501
|
+
}, onChange: (e) => {
|
|
502
|
+
setPublishUntil(e.target.value);
|
|
503
|
+
setWindowError(null);
|
|
504
|
+
} })] })] }), _jsx("p", { id: "ppublish-help", className: "b2b-help", children: t('productEditor.field.publishWindow.help') }), windowError ? (_jsx("p", { id: "ppublish-error", role: "alert", className: "text-sm text-destructive", style: { margin: 0 }, children: windowError === 'order'
|
|
505
|
+
? t('productEditor.scopeControls.window.invalidOrder')
|
|
506
|
+
: t('productEditor.scopeControls.window.invalidDate') })) : null] })) : null, isNew ? (_jsxs(_Fragment, { children: [_jsx("hr", { className: "b2b-hr" }), _jsxs("div", { children: [_jsx("div", { className: "b2b-label", children: t('productEditor.section.localizedContent') }), _jsx("p", { className: "b2b-help", style: { marginTop: 0, marginBottom: 12 }, children: t('productEditor.section.localizedContent.help') }), _jsx("div", { className: "b2b-col", style: { gap: 18 }, children: LOCALES.map((l) => (_jsxs("div", { className: "b2b-col", style: { gap: 8 }, children: [_jsxs("div", { children: [_jsx(Label, { htmlFor: `name-${l}`, children: t('productEditor.field.localizedName', { locale: l }) }), _jsx(Input, { id: `name-${l}`, value: name[l], onChange: (e) => setName((prev) => ({ ...prev, [l]: e.target.value })) })] }), _jsxs("div", { children: [_jsx(Label, { htmlFor: `desc-${l}`, children: t('productEditor.field.localizedDescription', { locale: l }) }), _jsx("textarea", { id: `desc-${l}`, rows: 3, className: "b2b-field", value: description[l], onChange: (e) => setDescription((prev) => ({ ...prev, [l]: e.target.value })) })] })] }, l))) })] })] })) : null, _jsx("hr", { className: "b2b-hr" }), _jsxs("div", { children: [_jsxs("div", { className: "b2b-label", children: [t('productEditor.section.categories'), id ? (_jsx(AdminZone, { name: "product.editor.field.after", props: { productId: id, fieldPath: 'categories', languageCodes: null } })) : null] }), _jsx(CategoryTreePicker, { categories: categories, selectedIds: categoryIds, onChange: setCategoryIds, loading: loading }), _jsx("p", { className: "b2b-help", children: t('productEditor.section.categories.help') })] })] }) })) : null, activeTab === 'attributes' && id ? (_jsx(ProductAttributesTab, { productId: id, attributeSetId: attributeSetId, values: attrValues, onChange: handleAttrChange })) : null, activeTab === 'pricing' && id ? (_jsxs("div", { className: "b2b-col", style: { gap: 16 }, children: [_jsx(AdminZone, { name: "product.editor.pricing.before", props: { productId: id } }), _jsx(AdminZone, { name: "product.editor.pricing.after", props: { productId: id } })] })) : null, activeTab === 'variants' && id ? _jsx(VariantsSection, { productId: id }) : null, activeTab === 'composite' && id ? (type === 'grouped' ? (_jsx(GroupedItemsSection, { productId: id })) : (_jsx(BundleSlotsSection, { productId: id }))) : null, activeTab === 'media' && id ? (_jsx(AdminZone, { name: "product.editor.field.after", props: { productId: id, fieldPath: 'gallery', languageCodes: null } })) : null, (activeTab === 'media' || galleryOpened) && id ? (_jsx("div", { hidden: activeTab !== 'media', children: _jsx(GallerySection, { ref: galleryRef, productId: id, onDirtyChange: setGalleryDirty }) })) : null, activeTab === 'inventory' && id ? (_jsxs("div", { className: "b2b-col", style: { gap: 16 }, children: [_jsx(ProductInventoryTab, { productId: id }), _jsx(ProductOrderRulesCard, { productId: id, productType: type }), type === 'simple' || type === 'configurable' ? (_jsx(PackagingUnitsEditor, { productId: id, canWrite: canWrite })) : null] })) : null, activeTab === 'attachments' && id ? (_jsxs(_Fragment, { children: [_jsx(AdminZone, { name: "product.editor.field.after", props: { productId: id, fieldPath: 'attachments', languageCodes: null } }), _jsx(AttachmentsSection, { productId: id })] })) : null, activeTab === 'links' && id ? _jsx(ProductLinksSection, { productId: id }) : null, activeTab === 'channels' && id ? (_jsx(AdminZone, { name: "product.editor.channels", props: { productId: id } })) : null, activeTab === 'scopes' && id ? _jsx(ProductScopeOverview, { productId: id }) : null, activeTab === 'seo' && id ? _jsx(ProductUrlKeysPanel, { productId: id }) : null, activeTab === 'seo' && id ? (_jsx(AdminZone, { name: "product.editor.seo.after", props: { productId: id } })) : null] })] })] }));
|
|
361
507
|
}
|
|
362
508
|
function pickName(name) {
|
|
363
509
|
return name['en-US'] ?? Object.values(name)[0] ?? '';
|
|
364
510
|
}
|
|
365
|
-
function SeoStub({ name }) {
|
|
366
|
-
const t = useTranslation('catalog');
|
|
367
|
-
return (_jsxs("div", { className: "b2b-col", style: { gap: 12 }, children: [_jsx("div", { className: "b2b-label", children: t('productEditor.seo.title') }), _jsx("div", { className: "b2b-help", style: { marginTop: 0 }, children: t('productEditor.seo.description') }), _jsxs("div", { children: [_jsx(Label, { htmlFor: "seo-title", children: t('productEditor.seo.pageTitlePreview') }), _jsx(Input, { id: "seo-title", defaultValue: pickName(name) })] })] }));
|
|
368
|
-
}
|
|
369
511
|
function VariantsSection({ productId }) {
|
|
370
512
|
const t = useTranslation('catalog');
|
|
371
513
|
const [variants, setVariants] = useState([]);
|
|
@@ -409,9 +551,6 @@ function VariantsSection({ productId }) {
|
|
|
409
551
|
sku: input.sku,
|
|
410
552
|
variantAttributeValues,
|
|
411
553
|
};
|
|
412
|
-
if (input.priceOverride.trim()) {
|
|
413
|
-
payload['priceOverride'] = Number(input.priceOverride);
|
|
414
|
-
}
|
|
415
554
|
if (input.stockLevel.trim()) {
|
|
416
555
|
payload['stockLevel'] = Number(input.stockLevel);
|
|
417
556
|
}
|
|
@@ -435,318 +574,24 @@ function VariantsSection({ productId }) {
|
|
|
435
574
|
setError(err instanceof ApiError ? err.envelope.error.message : t('productEditor.variants.error.delete'));
|
|
436
575
|
}
|
|
437
576
|
}, [productId, refresh, t]);
|
|
438
|
-
return (_jsxs(Card, { className: "mt-4", children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: t('productEditor.variants.title') }) }), _jsxs(CardContent, { className: "space-y-4", children: [error ? (_jsx(Alert, { variant: "destructive", children: _jsx(AlertDescription, { children: error }) })) : null, info ? (_jsx(Alert, { children: _jsx(AlertDescription, { children: info }) })) : null, loading ? (_jsx("p", { className: "text-sm text-muted-foreground", children: t('productEditor.loading') })) : variants.length === 0 ? (_jsx("p", { className: "text-sm text-muted-foreground", children: t('productEditor.variants.empty') })) : (_jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: t('productEditor.variants.column.sku') }), _jsx(TableHead, { children: t('productEditor.variants.column.attributes') }), _jsx(TableHead, { children: t('productEditor.variants.column.
|
|
577
|
+
return (_jsxs(Card, { className: "mt-4", children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: t('productEditor.variants.title') }) }), _jsxs(CardContent, { className: "space-y-4", children: [error ? (_jsx(Alert, { variant: "destructive", children: _jsx(AlertDescription, { children: error }) })) : null, info ? (_jsx(Alert, { children: _jsx(AlertDescription, { children: info }) })) : null, loading ? (_jsx("p", { className: "text-sm text-muted-foreground", children: t('productEditor.loading') })) : variants.length === 0 ? (_jsx("p", { className: "text-sm text-muted-foreground", children: t('productEditor.variants.empty') })) : (_jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: t('productEditor.variants.column.sku') }), _jsx(TableHead, { children: t('productEditor.variants.column.attributes') }), _jsx(TableHead, { children: t('productEditor.variants.column.stock') }), _jsx(TableHead, { className: "w-[1%] whitespace-nowrap", children: t('productEditor.variants.column.actions') })] }) }), _jsx(TableBody, { children: variants.map((v) => (_jsxs(TableRow, { children: [_jsx(TableCell, { className: "font-mono", children: v.sku }), _jsx(TableCell, { children: Object.entries(v.variantAttributeValues)
|
|
439
578
|
.map(([k, val]) => `${k}=${String(val)}`)
|
|
440
|
-
.join(', ') || '—' }), _jsx(TableCell, { children: v.
|
|
579
|
+
.join(', ') || '—' }), _jsx(TableCell, { children: v.stockLevel ?? '—' }), _jsx(TableCell, { children: _jsx(Button, { type: "button", variant: "destructive", size: "sm", onClick: () => void handleDelete(v.id, v.sku), children: t('productEditor.variants.action.delete') }) })] }, v.id))) })] })), _jsx(CreateVariantInline, { onCreate: handleCreate })] })] }));
|
|
441
580
|
}
|
|
442
581
|
function CreateVariantInline({ onCreate, }) {
|
|
443
582
|
const t = useTranslation('catalog');
|
|
444
583
|
const [sku, setSku] = useState('');
|
|
445
584
|
const [attrs, setAttrs] = useState('');
|
|
446
|
-
const [priceOverride, setPriceOverride] = useState('');
|
|
447
585
|
const [stockLevel, setStockLevel] = useState('');
|
|
448
|
-
return (_jsxs("div", { className: "grid gap-3 md:grid-cols-
|
|
449
|
-
void onCreate({ sku, attrs,
|
|
586
|
+
return (_jsxs("div", { className: "grid gap-3 md:grid-cols-4 border-t pt-4", role: "group", "aria-label": t('productEditor.variants.createTitle'), children: [_jsxs("div", { className: "space-y-1", children: [_jsx(Label, { htmlFor: "vsku", children: t('productEditor.variants.field.sku') }), _jsx(Input, { id: "vsku", value: sku, onChange: (e) => setSku(e.target.value), required: true })] }), _jsxs("div", { className: "space-y-1 md:col-span-2", children: [_jsx(Label, { htmlFor: "vattrs", children: t('productEditor.variants.field.attributes') }), _jsx(Input, { id: "vattrs", value: attrs, onChange: (e) => setAttrs(e.target.value), placeholder: t('productEditor.variants.field.attributesPlaceholder') })] }), _jsxs("div", { className: "space-y-1", children: [_jsx(Label, { htmlFor: "vstock", children: t('productEditor.variants.field.stock') }), _jsx(Input, { id: "vstock", type: "number", min: "0", value: stockLevel, onChange: (e) => setStockLevel(e.target.value) })] }), _jsx("div", { className: "md:col-span-4", children: _jsx(Button, { type: "button", onClick: () => {
|
|
587
|
+
void onCreate({ sku, attrs, stockLevel }).then(() => {
|
|
450
588
|
setSku('');
|
|
451
589
|
setAttrs('');
|
|
452
|
-
setPriceOverride('');
|
|
453
590
|
setStockLevel('');
|
|
454
591
|
});
|
|
455
592
|
}, children: t('productEditor.variants.action.add') }) })] }));
|
|
456
593
|
}
|
|
457
594
|
// ---------------------------------------------------------------------------
|
|
458
|
-
// Gallery section (T085) — admin CRUD for the Product's gallery items.
|
|
459
|
-
// Foundation lacks an admin Asset upload endpoint, so for now the form
|
|
460
|
-
// accepts an existing assetId; future work adds drag-and-drop on top of
|
|
461
|
-
// an Assets module admin upload route.
|
|
462
|
-
// ---------------------------------------------------------------------------
|
|
463
|
-
const GALLERY_LABELS = ['base_image', 'small_image', 'thumbnail'];
|
|
464
|
-
/** Immutable array move used by drag-and-drop / arrow reordering. */
|
|
465
|
-
function moveGalleryItem(items, from, to) {
|
|
466
|
-
if (to < 0 || to >= items.length || from === to)
|
|
467
|
-
return items;
|
|
468
|
-
const next = items.slice();
|
|
469
|
-
const [moved] = next.splice(from, 1);
|
|
470
|
-
if (moved === undefined)
|
|
471
|
-
return items;
|
|
472
|
-
next.splice(to, 0, moved);
|
|
473
|
-
return next;
|
|
474
|
-
}
|
|
475
|
-
const GallerySection = forwardRef(function GallerySection({ productId }, ref) {
|
|
476
|
-
const t = useTranslation('catalog');
|
|
477
|
-
const [items, setItems] = useState([]);
|
|
478
|
-
const [images, setImages] = useState([]);
|
|
479
|
-
const [loading, setLoading] = useState(true);
|
|
480
|
-
const [busy, setBusy] = useState(false);
|
|
481
|
-
const [error, setError] = useState(null);
|
|
482
|
-
const [info, setInfo] = useState(null);
|
|
483
|
-
const [previewUrl, setPreviewUrl] = useState(null);
|
|
484
|
-
const dragIdRef = useRef(null);
|
|
485
|
-
// Server-truth snapshot (id order + labels) used to diff the staged edits
|
|
486
|
-
// that the page-Save button flushes.
|
|
487
|
-
const baselineRef = useRef('');
|
|
488
|
-
const snapshot = (list) => JSON.stringify(list.map((g) => ({ id: g.id, labels: [...g.labels].sort() })));
|
|
489
|
-
const refresh = useCallback(async () => {
|
|
490
|
-
setLoading(true);
|
|
491
|
-
setError(null);
|
|
492
|
-
try {
|
|
493
|
-
// Public PDP carries the resolved gallery (with asset urls) so
|
|
494
|
-
// admins see the same shape customers do; the admin GET returns
|
|
495
|
-
// bare ids without urls. The PDP also carries the product's flat
|
|
496
|
-
// `assets` (legacy product_assets) — the storefront renders those
|
|
497
|
-
// when the label-aware gallery is empty, so we surface them here
|
|
498
|
-
// too, otherwise a product whose images live on product_assets
|
|
499
|
-
// looks empty in the admin while showing fine on the storefront.
|
|
500
|
-
const res = await apiClient.get(`/api/v1/catalog/products/${productId}`);
|
|
501
|
-
const gallery = res.data.gallery ?? [];
|
|
502
|
-
const mapped = gallery
|
|
503
|
-
.slice()
|
|
504
|
-
.sort((a, b) => a.position - b.position)
|
|
505
|
-
.map((g) => ({
|
|
506
|
-
id: g.id,
|
|
507
|
-
productId,
|
|
508
|
-
assetId: g.asset.id,
|
|
509
|
-
position: g.position,
|
|
510
|
-
labels: g.labels,
|
|
511
|
-
asset: { url: g.asset.url, kind: g.asset.kind },
|
|
512
|
-
}));
|
|
513
|
-
setItems(mapped);
|
|
514
|
-
baselineRef.current = snapshot(mapped);
|
|
515
|
-
const assets = res.data.assets ?? [];
|
|
516
|
-
setImages(assets
|
|
517
|
-
.filter((a) => a.kind === 'image' || a.kind === 'video')
|
|
518
|
-
.map((a) => ({
|
|
519
|
-
id: a.id,
|
|
520
|
-
kind: a.kind,
|
|
521
|
-
url: a.url,
|
|
522
|
-
altText: a.altText ?? null,
|
|
523
|
-
})));
|
|
524
|
-
}
|
|
525
|
-
catch (err) {
|
|
526
|
-
setError(err instanceof ApiError ? err.envelope.error.message : t('productEditor.gallery.error.load'));
|
|
527
|
-
}
|
|
528
|
-
finally {
|
|
529
|
-
setLoading(false);
|
|
530
|
-
}
|
|
531
|
-
}, [productId, t]);
|
|
532
|
-
useEffect(() => {
|
|
533
|
-
void refresh();
|
|
534
|
-
}, [refresh]);
|
|
535
|
-
// --- Staged label edits: each label lives on at most one item; assigning it
|
|
536
|
-
// to one item strips it from every other (radio semantics). Persisted on
|
|
537
|
-
// page Save, so no per-row Save button and no "already taken" error. ---
|
|
538
|
-
const assignLabel = useCallback((label, itemId) => {
|
|
539
|
-
setInfo(null);
|
|
540
|
-
setItems((prev) => prev.map((it) => {
|
|
541
|
-
const without = it.labels.filter((l) => l !== label);
|
|
542
|
-
return { ...it, labels: it.id === itemId ? [...without, label] : without };
|
|
543
|
-
}));
|
|
544
|
-
}, []);
|
|
545
|
-
const clearLabel = useCallback((label) => {
|
|
546
|
-
setInfo(null);
|
|
547
|
-
setItems((prev) => prev.map((it) => ({ ...it, labels: it.labels.filter((l) => l !== label) })));
|
|
548
|
-
}, []);
|
|
549
|
-
// --- Staged reorder (array order === display order). ---
|
|
550
|
-
const moveItem = useCallback((from, to) => {
|
|
551
|
-
setInfo(null);
|
|
552
|
-
setItems((prev) => moveGalleryItem(prev, from, to));
|
|
553
|
-
}, []);
|
|
554
|
-
const handleDrop = useCallback((index) => {
|
|
555
|
-
const draggedId = dragIdRef.current;
|
|
556
|
-
if (!draggedId)
|
|
557
|
-
return;
|
|
558
|
-
setItems((prev) => {
|
|
559
|
-
const from = prev.findIndex((it) => it.id === draggedId);
|
|
560
|
-
return from < 0 || from === index ? prev : moveGalleryItem(prev, from, index);
|
|
561
|
-
});
|
|
562
|
-
}, []);
|
|
563
|
-
// --- Immediate CRUD (add / remove) — these hit the server directly and
|
|
564
|
-
// re-load, which also resets the staged baseline. ---
|
|
565
|
-
const handleCreate = useCallback(async (assetId) => {
|
|
566
|
-
setBusy(true);
|
|
567
|
-
try {
|
|
568
|
-
await apiClient.post(`/api/v1/admin/catalog/products/${productId}/gallery`, {
|
|
569
|
-
assetId,
|
|
570
|
-
labels: [],
|
|
571
|
-
});
|
|
572
|
-
setInfo(t('productEditor.gallery.success.add'));
|
|
573
|
-
await refresh();
|
|
574
|
-
}
|
|
575
|
-
catch (err) {
|
|
576
|
-
setError(err instanceof ApiError ? err.envelope.error.message : t('productEditor.gallery.error.add'));
|
|
577
|
-
}
|
|
578
|
-
finally {
|
|
579
|
-
setBusy(false);
|
|
580
|
-
}
|
|
581
|
-
}, [productId, refresh, t]);
|
|
582
|
-
const handleDelete = useCallback(async (itemId) => {
|
|
583
|
-
if (!confirm(t('productEditor.gallery.removeConfirm')))
|
|
584
|
-
return;
|
|
585
|
-
setBusy(true);
|
|
586
|
-
try {
|
|
587
|
-
await apiClient.delete(`/api/v1/admin/catalog/products/${productId}/gallery/${itemId}`);
|
|
588
|
-
setInfo(t('productEditor.gallery.success.remove'));
|
|
589
|
-
await refresh();
|
|
590
|
-
}
|
|
591
|
-
catch (err) {
|
|
592
|
-
setError(err instanceof ApiError ? err.envelope.error.message : t('productEditor.gallery.error.delete'));
|
|
593
|
-
}
|
|
594
|
-
finally {
|
|
595
|
-
setBusy(false);
|
|
596
|
-
}
|
|
597
|
-
}, [productId, refresh, t]);
|
|
598
|
-
// --- Page-Save hook: flush staged label + order edits. Labels are patched
|
|
599
|
-
// with `replace=true` so reassigning a label moves it atomically. ---
|
|
600
|
-
const flushGallery = useCallback(async () => {
|
|
601
|
-
const baseline = JSON.parse(baselineRef.current || '[]');
|
|
602
|
-
const baseLabels = new Map(baseline.map((b) => [b.id, [...b.labels].sort().join(',')]));
|
|
603
|
-
const changed = items.filter((it) => baseLabels.get(it.id) !== [...it.labels].sort().join(','));
|
|
604
|
-
for (const it of changed) {
|
|
605
|
-
await apiClient.patch(`/api/v1/admin/catalog/products/${productId}/gallery/${it.id}?replace=true`, { labels: it.labels });
|
|
606
|
-
}
|
|
607
|
-
const baseOrder = baseline.map((b) => b.id).join(',');
|
|
608
|
-
const curOrder = items.map((it) => it.id).join(',');
|
|
609
|
-
if (items.length > 0 && curOrder !== baseOrder) {
|
|
610
|
-
await apiClient.put(`/api/v1/admin/catalog/products/${productId}/gallery/order`, {
|
|
611
|
-
orderedGalleryItemIds: items.map((it) => it.id),
|
|
612
|
-
});
|
|
613
|
-
}
|
|
614
|
-
if (changed.length > 0 || curOrder !== baseOrder) {
|
|
615
|
-
await refresh();
|
|
616
|
-
}
|
|
617
|
-
}, [items, productId, refresh]);
|
|
618
|
-
useImperativeHandle(ref, () => ({ flushGallery }), [flushGallery]);
|
|
619
|
-
const disabled = busy || loading;
|
|
620
|
-
return (_jsxs(Card, { className: "mt-4", children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: t('productEditor.gallery.title') }) }), _jsxs(CardContent, { className: "space-y-4", children: [error ? (_jsx(Alert, { variant: "destructive", children: _jsx(AlertDescription, { children: error }) })) : null, info ? (_jsx(Alert, { children: _jsx(AlertDescription, { children: info }) })) : null, !loading && images.length > 0 ? (_jsxs("div", { className: "space-y-2", children: [_jsx("p", { className: "text-sm font-medium", children: t('productEditor.gallery.productImages.title') }), _jsx("p", { className: "text-xs text-muted-foreground", children: t('productEditor.gallery.productImages.hint') }), _jsx("div", { className: "flex flex-wrap gap-2", children: images.map((img) => img.kind === 'video' ? (_jsx("video", { src: toAbsoluteAssetUrl(img.url), className: "h-20 w-20 rounded border object-cover", muted: true }, img.id)) : (_jsx("img", { src: toAbsoluteAssetUrl(img.url), alt: img.altText ?? '', className: "h-20 w-20 rounded border object-cover" }, img.id))) })] })) : null, loading ? (_jsx("p", { className: "text-sm text-muted-foreground", children: t('productEditor.loading') })) : items.length === 0 ? (_jsx("p", { className: "text-sm text-muted-foreground", children: t('productEditor.gallery.empty') })) : (_jsxs(_Fragment, { children: [_jsx("p", { className: "text-xs text-muted-foreground", children: t('productEditor.gallery.dragHint') }), _jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { className: "w-8" }), _jsx(TableHead, { children: t('productEditor.gallery.column.preview') }), GALLERY_LABELS.map((label) => (_jsx(TableHead, { className: "text-center", children: t(`productEditor.gallery.label.${label}`) }, label))), _jsx(TableHead, { children: t('productEditor.gallery.column.assetId') }), _jsx(TableHead, { className: "w-[1%] whitespace-nowrap text-right", children: t('productEditor.gallery.column.actions') })] }) }), _jsx(TableBody, { children: items.map((item, index) => (_jsx(GalleryRow, { item: item, index: index, total: items.length, disabled: disabled, onAssignLabel: assignLabel, onClearLabel: clearLabel, onMove: moveItem, onDragStart: (id) => {
|
|
621
|
-
dragIdRef.current = id;
|
|
622
|
-
}, onDragOver: (e) => e.preventDefault(), onDrop: handleDrop, onDragEnd: () => {
|
|
623
|
-
dragIdRef.current = null;
|
|
624
|
-
}, onPreview: setPreviewUrl, onDelete: handleDelete }, item.id))) })] })] })), _jsx(CreateGalleryItemInline, { disabled: disabled, onCreate: handleCreate })] }), previewUrl ? (_jsxs("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-6", role: "dialog", "aria-modal": "true", "aria-label": t('productEditor.gallery.preview.title'), onClick: () => setPreviewUrl(null), children: [_jsx("img", { src: previewUrl, alt: t('productEditor.gallery.preview.title'), className: "max-h-full max-w-full rounded shadow-lg", onClick: (e) => e.stopPropagation() }), _jsx("button", { type: "button", className: "b2b-btn b2b-btn--sm", style: { position: 'fixed', top: 16, right: 16 }, onClick: () => setPreviewUrl(null), children: t('productEditor.gallery.preview.close') })] })) : null] }));
|
|
625
|
-
});
|
|
626
|
-
function GalleryRow({ item, index, total, disabled, onAssignLabel, onClearLabel, onMove, onDragStart, onDragOver, onDrop, onDragEnd, onPreview, onDelete, }) {
|
|
627
|
-
const t = useTranslation('catalog');
|
|
628
|
-
const url = item.asset?.url ? toAbsoluteAssetUrl(item.asset.url) : null;
|
|
629
|
-
return (_jsxs(TableRow, { draggable: !disabled, onDragStart: () => onDragStart(item.id), onDragOver: onDragOver, onDrop: () => onDrop(index), onDragEnd: onDragEnd, children: [_jsx(TableCell, { className: "w-8", children: _jsx("span", { className: "inline-flex cursor-grab items-center text-muted-foreground", title: t('productEditor.gallery.dragHint'), "aria-hidden": true, children: _jsx(GripVertical, { className: "h-4 w-4" }) }) }), _jsx(TableCell, { children: url ? (item.asset?.kind === 'video' ? (_jsx("video", { src: url, className: "h-12 w-12 rounded border object-cover", muted: true })) : (_jsx("button", { type: "button", className: "block rounded border p-0", title: t('productEditor.gallery.preview.open'), onClick: () => onPreview(url), children: _jsx("img", { src: url, alt: "", className: "h-12 w-12 rounded object-cover" }) }))) : (_jsx("span", { className: "text-muted-foreground text-xs", children: "\u2014" })) }), GALLERY_LABELS.map((label) => {
|
|
630
|
-
const checked = item.labels.includes(label);
|
|
631
|
-
return (_jsx(TableCell, { className: "text-center", children: _jsx("input", { type: "radio", name: `gallery-label-${label}`, checked: checked, disabled: disabled, "aria-label": t(`productEditor.gallery.label.${label}`), onChange: () => { }, onClick: () => checked ? onClearLabel(label) : onAssignLabel(label, item.id) }) }, label));
|
|
632
|
-
}), _jsxs(TableCell, { className: "font-mono text-xs", children: [item.assetId.slice(0, 8), "\u2026"] }), _jsxs(TableCell, { className: "space-x-2 whitespace-nowrap text-right", children: [_jsx(TouchReorderButtons, { disabled: disabled, onMoveUp: () => onMove(index, index - 1), onMoveDown: () => onMove(index, index + 1), disableUp: index === 0, disableDown: index === total - 1 }), _jsx(Button, { type: "button", size: "sm", variant: "destructive", disabled: disabled, onClick: () => void onDelete(item.id), children: t('productEditor.gallery.action.remove') })] })] }));
|
|
633
|
-
}
|
|
634
|
-
function CreateGalleryItemInline({ disabled, onCreate, }) {
|
|
635
|
-
const t = useTranslation('catalog');
|
|
636
|
-
const [assetId, setAssetId] = useState('');
|
|
637
|
-
const [pickerOpen, setPickerOpen] = useState(false);
|
|
638
|
-
const [pickedFilename, setPickedFilename] = useState(null);
|
|
639
|
-
const onPick = (a) => {
|
|
640
|
-
setAssetId(a.id);
|
|
641
|
-
setPickedFilename(a.filename);
|
|
642
|
-
setPickerOpen(false);
|
|
643
|
-
};
|
|
644
|
-
return (_jsxs("div", { className: "space-y-3 border-t pt-4", role: "group", "aria-label": t('productEditor.gallery.addTitle'), children: [pickerOpen ? (_jsx(AssetPicker, { acceptMimePrefix: "image/", allowUpload: true, onSelect: onPick, onClose: () => setPickerOpen(false) })) : null, _jsxs("div", { className: "grid gap-3 md:grid-cols-4", children: [_jsxs("div", { className: "space-y-1 md:col-span-3", children: [_jsx(Label, { htmlFor: "gasset", children: t('productEditor.gallery.field.asset') }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Input, { id: "gasset", value: pickedFilename ?? assetId, readOnly: true, placeholder: t('productEditor.gallery.field.noAsset') }), _jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: () => setPickerOpen(true), children: t('productEditor.gallery.action.pickOrUpload') })] })] }), _jsx("div", { className: "flex items-end", children: _jsx(Button, { type: "button", disabled: disabled || !assetId, onClick: () => {
|
|
645
|
-
if (!assetId)
|
|
646
|
-
return;
|
|
647
|
-
void onCreate(assetId).then(() => {
|
|
648
|
-
setAssetId('');
|
|
649
|
-
setPickedFilename(null);
|
|
650
|
-
});
|
|
651
|
-
}, children: t('productEditor.gallery.action.add') }) })] })] }));
|
|
652
|
-
}
|
|
653
|
-
function AttachmentsSection({ productId }) {
|
|
654
|
-
const t = useTranslation('catalog');
|
|
655
|
-
const [attachments, setAttachments] = useState([]);
|
|
656
|
-
const [types, setTypes] = useState([]);
|
|
657
|
-
const [loading, setLoading] = useState(true);
|
|
658
|
-
const [error, setError] = useState(null);
|
|
659
|
-
const [info, setInfo] = useState(null);
|
|
660
|
-
const refresh = useCallback(async () => {
|
|
661
|
-
setLoading(true);
|
|
662
|
-
setError(null);
|
|
663
|
-
try {
|
|
664
|
-
const [detail, typesRes] = await Promise.all([
|
|
665
|
-
apiClient.get(`/api/v1/catalog/products/${productId}`),
|
|
666
|
-
apiClient.get('/api/v1/admin/catalog/attachment-types'),
|
|
667
|
-
]);
|
|
668
|
-
const detailAttachments = detail.data.attachments ?? [];
|
|
669
|
-
setAttachments(detailAttachments.map((a) => ({
|
|
670
|
-
id: a.id,
|
|
671
|
-
productId,
|
|
672
|
-
assetId: a.asset.id,
|
|
673
|
-
attachmentTypeId: a.type.id,
|
|
674
|
-
name: a.name,
|
|
675
|
-
description: a.description,
|
|
676
|
-
position: a.position,
|
|
677
|
-
asset: {
|
|
678
|
-
url: a.asset.url,
|
|
679
|
-
filename: a.asset.filename,
|
|
680
|
-
mimeType: a.asset.mimeType,
|
|
681
|
-
},
|
|
682
|
-
type: { code: a.type.code, name: a.type.name },
|
|
683
|
-
})));
|
|
684
|
-
setTypes(typesRes.data);
|
|
685
|
-
}
|
|
686
|
-
catch (err) {
|
|
687
|
-
setError(err instanceof ApiError ? err.envelope.error.message : t('productEditor.attachments.error.load'));
|
|
688
|
-
}
|
|
689
|
-
finally {
|
|
690
|
-
setLoading(false);
|
|
691
|
-
}
|
|
692
|
-
}, [productId, t]);
|
|
693
|
-
useEffect(() => {
|
|
694
|
-
void refresh();
|
|
695
|
-
}, [refresh]);
|
|
696
|
-
const handleCreate = useCallback(async (input) => {
|
|
697
|
-
try {
|
|
698
|
-
await apiClient.post(`/api/v1/admin/catalog/products/${productId}/attachments`, {
|
|
699
|
-
assetId: input.assetId,
|
|
700
|
-
attachmentTypeId: input.attachmentTypeId,
|
|
701
|
-
name: input.name,
|
|
702
|
-
...(input.description ? { description: input.description } : {}),
|
|
703
|
-
});
|
|
704
|
-
setInfo(t('productEditor.attachments.success.add'));
|
|
705
|
-
await refresh();
|
|
706
|
-
}
|
|
707
|
-
catch (err) {
|
|
708
|
-
setError(err instanceof ApiError ? err.envelope.error.message : t('productEditor.attachments.error.add'));
|
|
709
|
-
}
|
|
710
|
-
}, [productId, refresh, t]);
|
|
711
|
-
const handleDelete = useCallback(async (attachmentId, name) => {
|
|
712
|
-
if (!confirm(t('productEditor.attachments.deleteConfirm', { name })))
|
|
713
|
-
return;
|
|
714
|
-
try {
|
|
715
|
-
await apiClient.delete(`/api/v1/admin/catalog/products/${productId}/attachments/${attachmentId}`);
|
|
716
|
-
setInfo(t('productEditor.attachments.success.delete', { name }));
|
|
717
|
-
await refresh();
|
|
718
|
-
}
|
|
719
|
-
catch (err) {
|
|
720
|
-
setError(err instanceof ApiError ? err.envelope.error.message : t('productEditor.attachments.error.delete'));
|
|
721
|
-
}
|
|
722
|
-
}, [productId, refresh, t]);
|
|
723
|
-
return (_jsxs(Card, { className: "mt-4", children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: t('productEditor.attachments.title') }) }), _jsxs(CardContent, { className: "space-y-4", children: [error ? (_jsx(Alert, { variant: "destructive", children: _jsx(AlertDescription, { children: error }) })) : null, info ? (_jsx(Alert, { children: _jsx(AlertDescription, { children: info }) })) : null, loading ? (_jsx("p", { className: "text-sm text-muted-foreground", children: t('productEditor.loading') })) : attachments.length === 0 ? (_jsx("p", { className: "text-sm text-muted-foreground", children: t('productEditor.attachments.empty') })) : (_jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: t('productEditor.attachments.column.type') }), _jsx(TableHead, { children: t('productEditor.attachments.column.name') }), _jsx(TableHead, { children: t('productEditor.attachments.column.description') }), _jsx(TableHead, { children: t('productEditor.attachments.column.file') }), _jsx(TableHead, { className: "w-[1%] whitespace-nowrap", children: t('productEditor.attachments.column.actions') })] }) }), _jsx(TableBody, { children: attachments.map((att) => (_jsxs(TableRow, { children: [_jsx(TableCell, { children: att.type?.name['en-US'] ?? att.type?.code ?? '—' }), _jsx(TableCell, { className: "font-medium", children: att.name }), _jsx(TableCell, { className: "text-muted-foreground", children: att.description ?? '—' }), _jsx(TableCell, { children: att.asset?.url ? (_jsx("a", { href: att.asset.url, target: "_blank", rel: "noopener", className: "text-xs underline", children: att.asset.filename })) : ('—') }), _jsx(TableCell, { children: _jsx(Button, { type: "button", size: "sm", variant: "destructive", onClick: () => void handleDelete(att.id, att.name), children: t('productEditor.attachments.action.delete') }) })] }, att.id))) })] })), _jsx(CreateAttachmentInline, { types: types, onCreate: handleCreate })] })] }));
|
|
724
|
-
}
|
|
725
|
-
function CreateAttachmentInline({ types, onCreate, }) {
|
|
726
|
-
const [assetId, setAssetId] = useState('');
|
|
727
|
-
const [attachmentTypeId, setAttachmentTypeId] = useState('');
|
|
728
|
-
const [name, setName] = useState('');
|
|
729
|
-
const [description, setDescription] = useState('');
|
|
730
|
-
const [pickerOpen, setPickerOpen] = useState(false);
|
|
731
|
-
const [pickedFilename, setPickedFilename] = useState(null);
|
|
732
|
-
const t = useTranslation('catalog');
|
|
733
|
-
return (_jsxs("div", { className: "space-y-3 border-t pt-4", role: "group", "aria-label": t('productEditor.attachments.addTitle'), children: [pickerOpen ? (_jsx(AssetPicker, { allowUpload: true, onSelect: (a) => {
|
|
734
|
-
setAssetId(a.id);
|
|
735
|
-
setPickedFilename(a.filename);
|
|
736
|
-
setPickerOpen(false);
|
|
737
|
-
}, onClose: () => setPickerOpen(false) })) : null, _jsxs("div", { className: "grid gap-3 md:grid-cols-4", children: [_jsxs("div", { className: "space-y-1", children: [_jsx(Label, { htmlFor: "aasset", children: t('productEditor.attachments.field.asset') }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Input, { id: "aasset", value: pickedFilename ?? assetId, readOnly: true, placeholder: t('productEditor.attachments.field.noAsset') }), _jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: () => setPickerOpen(true), children: t('productEditor.attachments.action.pickOrUpload') })] })] }), _jsxs("div", { className: "space-y-1", children: [_jsx(Label, { htmlFor: "atype", children: t('productEditor.attachments.field.type') }), _jsxs(Select, { id: "atype", value: attachmentTypeId, onChange: (e) => setAttachmentTypeId(e.target.value), children: [_jsx("option", { value: "", children: "\u2014" }), types.map((typ) => (_jsx("option", { value: typ.id, children: typ.name['en-US'] ?? typ.code }, typ.id)))] })] }), _jsxs("div", { className: "space-y-1", children: [_jsx(Label, { htmlFor: "aname", children: t('productEditor.attachments.field.name') }), _jsx(Input, { id: "aname", value: name, onChange: (e) => setName(e.target.value), placeholder: t('productEditor.attachments.field.namePlaceholder') })] }), _jsxs("div", { className: "space-y-1", children: [_jsx(Label, { htmlFor: "adesc", children: t('productEditor.attachments.field.description') }), _jsx(Input, { id: "adesc", value: description, onChange: (e) => setDescription(e.target.value), placeholder: t('productEditor.attachments.field.descriptionPlaceholder') })] }), _jsx("div", { className: "md:col-span-4", children: _jsx(Button, { type: "button", onClick: () => {
|
|
738
|
-
if (!assetId || !attachmentTypeId || !name)
|
|
739
|
-
return;
|
|
740
|
-
void onCreate({ assetId, attachmentTypeId, name, description }).then(() => {
|
|
741
|
-
setAssetId('');
|
|
742
|
-
setPickedFilename(null);
|
|
743
|
-
setAttachmentTypeId('');
|
|
744
|
-
setName('');
|
|
745
|
-
setDescription('');
|
|
746
|
-
});
|
|
747
|
-
}, children: t('productEditor.attachments.action.add') }) })] })] }));
|
|
748
|
-
}
|
|
749
|
-
// ---------------------------------------------------------------------------
|
|
750
595
|
// Product Links section (T109, US4) — Related / Up-sell / Cross-sell.
|
|
751
596
|
// Three sub-lists, one product picker (paste id) + kind selector +
|
|
752
597
|
// "Add" button per kind. Backend bulkCreate is all-or-nothing and
|
|
@@ -849,10 +694,12 @@ function ProductLinksSection({ productId }) {
|
|
|
849
694
|
return (_jsxs(Card, { className: "mt-4", children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: t('productEditor.links.title') }) }), _jsxs(CardContent, { className: "space-y-4", children: [error ? (_jsx(Alert, { variant: "destructive", children: _jsx(AlertDescription, { children: error }) })) : null, info ? (_jsx(Alert, { children: _jsx(AlertDescription, { children: info }) })) : null, loading ? (_jsx("p", { className: "text-sm text-muted-foreground", children: t('productEditor.loading') })) : (_jsx("div", { className: "space-y-6", children: LINK_KINDS.map((kind) => (_jsxs("div", { className: "space-y-2", children: [_jsxs("h3", { className: "text-sm font-medium uppercase tracking-wide", children: [t(`productEditor.links.kind.${kind}`), " (", byKind[kind].length, ")"] }), byKind[kind].length === 0 ? (_jsx("p", { className: "text-xs text-muted-foreground", children: t('productEditor.links.empty') })) : (_jsxs(Table, { children: [_jsx(TableHeader, { children: _jsxs(TableRow, { children: [_jsx(TableHead, { children: t('productEditor.links.column.target') }), _jsx(TableHead, { children: t('productEditor.links.column.sku') }), _jsx(TableHead, { children: t('productEditor.links.column.position') }), _jsx(TableHead, { className: "w-[1%] whitespace-nowrap", children: t('productEditor.links.column.actions') })] }) }), _jsx(TableBody, { children: byKind[kind].map((link) => {
|
|
850
695
|
const target = targetsById.get(link.targetProductId);
|
|
851
696
|
const isMissing = !target;
|
|
697
|
+
// `inactive` is plain off; archived is its own fact.
|
|
852
698
|
const isInactive = target?.status === 'inactive';
|
|
853
|
-
|
|
699
|
+
const isArchived = target?.archivedAt != null;
|
|
700
|
+
return (_jsxs(TableRow, { children: [_jsx(TableCell, { children: _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: isMissing || isInactive || isArchived ? 'text-muted-foreground' : '', children: target
|
|
854
701
|
? pickProductName(target.name, target.slug)
|
|
855
|
-
: `${link.targetProductId.slice(0, 8)}…` }), isMissing ? (_jsx("span", { className: "rounded border px-1.5 py-0.5 text-[10px] uppercase text-muted-foreground", children: t('productEditor.links.badge.missing') })) : null, isInactive ? (_jsx("span", { className: "rounded border px-1.5 py-0.5 text-[10px] uppercase text-muted-foreground", children: t('productEditor.links.badge.inactive') })) : null] }) }), _jsx(TableCell, { className: "font-mono text-xs", children: target?.sku ?? '—' }), _jsx(TableCell, { children: link.position }), _jsx(TableCell, { children: _jsx(Button, { type: "button", size: "sm", variant: "destructive", onClick: () => void handleDelete(link.id), children: t('productEditor.links.action.remove') }) })] }, link.id));
|
|
702
|
+
: `${link.targetProductId.slice(0, 8)}…` }), isMissing ? (_jsx("span", { className: "rounded border px-1.5 py-0.5 text-[10px] uppercase text-muted-foreground", children: t('productEditor.links.badge.missing') })) : null, isInactive ? (_jsx("span", { className: "rounded border px-1.5 py-0.5 text-[10px] uppercase text-muted-foreground", children: t('productEditor.links.badge.inactive') })) : null, isArchived ? (_jsx("span", { className: "rounded border px-1.5 py-0.5 text-[10px] uppercase text-muted-foreground", children: t('productEditor.links.badge.archived') })) : null] }) }), _jsx(TableCell, { className: "font-mono text-xs", children: target?.sku ?? '—' }), _jsx(TableCell, { children: link.position }), _jsx(TableCell, { children: _jsx(Button, { type: "button", size: "sm", variant: "destructive", onClick: () => void handleDelete(link.id), children: t('productEditor.links.action.remove') }) })] }, link.id));
|
|
856
703
|
}) })] }))] }, kind))) })), _jsx(CreateProductLinkInline, { onCreate: handleCreate, sourceProductId: productId })] })] }));
|
|
857
704
|
}
|
|
858
705
|
function CreateProductLinkInline({ onCreate, sourceProductId, }) {
|