@endora-commerce/mod-catalog 0.108.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 +7 -1
- package/dist/admin/components/PackagingUnitsEditor.d.ts.map +1 -1
- package/dist/admin/components/PackagingUnitsEditor.js +82 -11
- 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.map +1 -1
- package/dist/admin/components/ProductOrderRulesCard.js +134 -6
- package/dist/admin/components/ProductOrderRulesCard.js.map +1 -1
- 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 +288 -133
- 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 +214 -346
- 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/rows.d.ts +7 -0
- package/dist/backend/demo/rows.d.ts.map +1 -1
- package/dist/backend/demo/rows.js +17 -12
- package/dist/backend/demo/rows.js.map +1 -1
- package/dist/backend/demo/seed.js +2 -2
- 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 +7 -1
- package/dist/backend/entities/product-packaging-unit.entity.d.ts.map +1 -1
- package/dist/backend/entities/product-packaging-unit.entity.js +10 -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.entity.d.ts +17 -2
- package/dist/backend/entities/product.entity.d.ts.map +1 -1
- package/dist/backend/entities/product.entity.js +24 -1
- package/dist/backend/entities/product.entity.js.map +1 -1
- package/dist/backend/index.d.ts +24 -2
- package/dist/backend/index.d.ts.map +1 -1
- package/dist/backend/index.js +206 -11
- package/dist/backend/index.js.map +1 -1
- package/dist/backend/plugin.d.ts +44 -3
- 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 +123 -54
- 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 +55 -26
- 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 +111 -18
- package/dist/backend/services/catalog-admin.service.d.ts.map +1 -1
- package/dist/backend/services/catalog-admin.service.js +298 -142
- 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 +107 -11
- package/dist/backend/services/catalog-bulk-update.service.js.map +1 -1
- package/dist/backend/services/catalog-org-price-decorator.d.ts +12 -25
- package/dist/backend/services/catalog-org-price-decorator.d.ts.map +1 -1
- package/dist/backend/services/catalog-org-price-decorator.js +48 -13
- 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.map +1 -1
- package/dist/backend/services/catalog-product-read.service.js +5 -8
- package/dist/backend/services/catalog-product-read.service.js.map +1 -1
- package/dist/backend/services/catalog-query.service.d.ts +135 -38
- package/dist/backend/services/catalog-query.service.d.ts.map +1 -1
- package/dist/backend/services/catalog-query.service.js +683 -354
- 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 +76 -45
- 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 +32 -22
- 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/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/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 +170 -10
- package/dist/manifest.js.map +1 -1
- 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/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 +6 -1
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +11 -1
- package/dist/migrations/index.js.map +1 -1
- package/docs/catalog/attachments.md +46 -4
- package/docs/catalog/gallery-and-labels.md +63 -4
- package/docs/catalog/packaging-units.md +42 -5
- package/docs/catalog/per-channel-per-language-overrides.md +166 -8
- package/docs/catalog/url-keys-and-redirects.md +142 -0
- package/docs/catalog.md +182 -15
- package/i18n/en.json +903 -49
- package/i18n/pl.json +902 -48
- package/package.json +10 -10
|
@@ -1,17 +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
12
|
import { ProductOrderRulesCard } from '../components/ProductOrderRulesCard.js';
|
|
13
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';
|
|
14
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';
|
|
15
22
|
const LOCALES = ['en-US', 'pl-PL'];
|
|
16
23
|
const PRODUCT_TYPES = [
|
|
17
24
|
'simple',
|
|
@@ -21,7 +28,23 @@ const PRODUCT_TYPES = [
|
|
|
21
28
|
'virtual',
|
|
22
29
|
];
|
|
23
30
|
const VISIBILITIES = ['public', 'logged_in_only', 'organization_restricted'];
|
|
24
|
-
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
|
+
]);
|
|
25
48
|
/**
|
|
26
49
|
* Order-insensitive JSON snapshot of the editable form fields, used to detect
|
|
27
50
|
* unsaved changes (object keys + array members are sorted so re-ordering alone
|
|
@@ -49,13 +72,25 @@ export function ProductEditor() {
|
|
|
49
72
|
const channelContributions = useAdminZone('product.editor.channels', {
|
|
50
73
|
productId: id ?? '',
|
|
51
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');
|
|
52
79
|
const [loading, setLoading] = useState(!isNew);
|
|
53
80
|
const [error, setError] = useState(null);
|
|
54
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);
|
|
55
90
|
const [categories, setCategories] = useState([]);
|
|
56
91
|
const [sku, setSku] = useState('');
|
|
57
92
|
const [type, setType] = useState('simple');
|
|
58
|
-
const [status, setStatus] = useState('
|
|
93
|
+
const [status, setStatus] = useState('inactive');
|
|
59
94
|
const [visibility, setVisibility] = useState('public');
|
|
60
95
|
const [name, setName] = useState({ 'en-US': '', 'pl-PL': '' });
|
|
61
96
|
const [description, setDescription] = useState({
|
|
@@ -63,12 +98,23 @@ export function ProductEditor() {
|
|
|
63
98
|
'pl-PL': '',
|
|
64
99
|
});
|
|
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);
|
|
@@ -89,11 +135,24 @@ export function ProductEditor() {
|
|
|
89
135
|
categoryIds,
|
|
90
136
|
attributeSetId,
|
|
91
137
|
attrValues,
|
|
138
|
+
publishFrom,
|
|
139
|
+
publishUntil,
|
|
92
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]);
|
|
93
150
|
const dirty = !loading &&
|
|
94
|
-
initialSnapshotRef.current !== '' &&
|
|
95
|
-
currentSnapshot !== initialSnapshotRef.current;
|
|
151
|
+
((initialSnapshotRef.current !== '' && currentSnapshot !== initialSnapshotRef.current) || galleryDirty);
|
|
96
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;
|
|
97
156
|
const refresh = useCallback(async () => {
|
|
98
157
|
setLoading(true);
|
|
99
158
|
setError(null);
|
|
@@ -113,13 +172,15 @@ export function ProductEditor() {
|
|
|
113
172
|
initialSnapshotRef.current = stableSnapshot({
|
|
114
173
|
sku: '',
|
|
115
174
|
type: 'simple',
|
|
116
|
-
status: '
|
|
175
|
+
status: 'inactive',
|
|
117
176
|
visibility: 'public',
|
|
118
177
|
name: { 'en-US': '', 'pl-PL': '' },
|
|
119
178
|
description: { 'en-US': '', 'pl-PL': '' },
|
|
120
179
|
categoryIds: [],
|
|
121
180
|
attributeSetId: defaultSet?.id ?? '',
|
|
122
181
|
attrValues: {},
|
|
182
|
+
publishFrom: '',
|
|
183
|
+
publishUntil: '',
|
|
123
184
|
});
|
|
124
185
|
}
|
|
125
186
|
if (id) {
|
|
@@ -128,6 +189,7 @@ export function ProductEditor() {
|
|
|
128
189
|
setSku(p.sku);
|
|
129
190
|
setType(p.type);
|
|
130
191
|
setStatus(p.status);
|
|
192
|
+
setArchivedAt(p.archivedAt ?? null);
|
|
131
193
|
setVisibility(p.visibility);
|
|
132
194
|
const loadedName = {
|
|
133
195
|
'en-US': p.name['en-US'] ?? '',
|
|
@@ -142,6 +204,23 @@ export function ProductEditor() {
|
|
|
142
204
|
setAttrValues(p.attributeValues ?? {});
|
|
143
205
|
setAttributeSetId(p.attributeSetId);
|
|
144
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);
|
|
145
224
|
// Capture the loaded state as the clean baseline for dirty-tracking.
|
|
146
225
|
initialSnapshotRef.current = stableSnapshot({
|
|
147
226
|
sku: p.sku,
|
|
@@ -153,11 +232,13 @@ export function ProductEditor() {
|
|
|
153
232
|
categoryIds: p.categoryIds ?? [],
|
|
154
233
|
attributeSetId: p.attributeSetId,
|
|
155
234
|
attrValues: p.attributeValues ?? {},
|
|
235
|
+
publishFrom: loadedFrom,
|
|
236
|
+
publishUntil: loadedUntil,
|
|
156
237
|
});
|
|
157
238
|
}
|
|
158
239
|
}
|
|
159
240
|
catch (err) {
|
|
160
|
-
setError(err instanceof ApiError ? err.envelope.error.message : '
|
|
241
|
+
setError(err instanceof ApiError ? err.envelope.error.message : tRef.current('productEditor.error.load'));
|
|
161
242
|
}
|
|
162
243
|
finally {
|
|
163
244
|
setLoading(false);
|
|
@@ -170,6 +251,7 @@ export function ProductEditor() {
|
|
|
170
251
|
e.preventDefault();
|
|
171
252
|
setError(null);
|
|
172
253
|
setInfo(null);
|
|
254
|
+
setGateWarning(null);
|
|
173
255
|
const trimmedName = {};
|
|
174
256
|
const trimmedDescription = {};
|
|
175
257
|
for (const l of LOCALES) {
|
|
@@ -179,17 +261,33 @@ export function ProductEditor() {
|
|
|
179
261
|
trimmedDescription[l] = description[l];
|
|
180
262
|
}
|
|
181
263
|
if (Object.keys(trimmedName).length === 0) {
|
|
182
|
-
setError('
|
|
264
|
+
setError(t('productEditor.error.nameRequired'));
|
|
183
265
|
return;
|
|
184
266
|
}
|
|
185
267
|
// The Attributes-tab edits. A product has no price of its own: prices
|
|
186
268
|
// are set in price books (feature 160), so nothing else is added here.
|
|
187
269
|
const attributeValues = { ...attrValues };
|
|
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);
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
windowPatch = { publishFrom: check.from, publishUntil: check.until };
|
|
281
|
+
}
|
|
282
|
+
setWindowError(null);
|
|
188
283
|
try {
|
|
189
284
|
if (isNew) {
|
|
190
285
|
const res = await apiClient.post('/api/v1/admin/catalog/products', {
|
|
191
286
|
sku,
|
|
192
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,
|
|
193
291
|
name: trimmedName,
|
|
194
292
|
description: trimmedDescription,
|
|
195
293
|
categoryIds,
|
|
@@ -200,33 +298,58 @@ export function ProductEditor() {
|
|
|
200
298
|
navigate(`/catalog/products/${res.data.id}`);
|
|
201
299
|
}
|
|
202
300
|
else if (id) {
|
|
203
|
-
// Feature 023 — page-Save commits
|
|
204
|
-
//
|
|
205
|
-
//
|
|
206
|
-
//
|
|
207
|
-
//
|
|
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
|
+
});
|
|
208
317
|
await Promise.all([
|
|
209
|
-
apiClient.patch(`/api/v1/admin/catalog/products/${id}`, {
|
|
210
|
-
sku: sku.trim(),
|
|
211
|
-
status,
|
|
212
|
-
name: trimmedName,
|
|
213
|
-
description: trimmedDescription,
|
|
214
|
-
categoryIds,
|
|
215
|
-
attributeValues,
|
|
216
|
-
visibility,
|
|
217
|
-
...(attributeSetId ? { attributeSetId } : {}),
|
|
218
|
-
}),
|
|
219
318
|
scopeEditorRef.current?.flushOverrides() ?? Promise.resolve(),
|
|
220
319
|
galleryRef.current?.flushGallery() ?? Promise.resolve(),
|
|
221
320
|
]);
|
|
222
|
-
|
|
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
|
+
}
|
|
223
334
|
await refresh();
|
|
224
335
|
}
|
|
225
336
|
}
|
|
226
337
|
catch (err) {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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]);
|
|
230
353
|
const handleAttrChange = useCallback((key, value) => {
|
|
231
354
|
setAttrValues((prev) => ({ ...prev, [key]: value }));
|
|
232
355
|
}, []);
|
|
@@ -265,14 +388,14 @@ export function ProductEditor() {
|
|
|
265
388
|
navigate('/catalog/products');
|
|
266
389
|
}
|
|
267
390
|
catch (err) {
|
|
268
|
-
setError(err instanceof ApiError ? err.envelope.error.message : '
|
|
391
|
+
setError(err instanceof ApiError ? err.envelope.error.message : t('productEditor.error.delete'));
|
|
269
392
|
}
|
|
270
393
|
}, [id, navigate, t]);
|
|
271
394
|
const [duplicating, setDuplicating] = useState(false);
|
|
272
395
|
const handleDuplicate = useCallback(async () => {
|
|
273
396
|
if (!id || duplicating)
|
|
274
397
|
return;
|
|
275
|
-
if (!confirm('
|
|
398
|
+
if (!confirm(t('productEditor.duplicateConfirm')))
|
|
276
399
|
return;
|
|
277
400
|
setDuplicating(true);
|
|
278
401
|
setError(null);
|
|
@@ -281,12 +404,36 @@ export function ProductEditor() {
|
|
|
281
404
|
navigate(`/catalog/products/${res.data.id}`);
|
|
282
405
|
}
|
|
283
406
|
catch (err) {
|
|
284
|
-
setError(err instanceof ApiError ? err.envelope.error.message : '
|
|
407
|
+
setError(err instanceof ApiError ? err.envelope.error.message : t('productEditor.error.duplicate'));
|
|
285
408
|
}
|
|
286
409
|
finally {
|
|
287
410
|
setDuplicating(false);
|
|
288
411
|
}
|
|
289
|
-
}, [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]);
|
|
290
437
|
if (loading)
|
|
291
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') }) }));
|
|
292
439
|
const tabs = [
|
|
@@ -321,35 +468,46 @@ export function ProductEditor() {
|
|
|
321
468
|
icon: _jsx(StoreIcon, { size: 14 }),
|
|
322
469
|
show: !isNew && channelContributions.length > 0,
|
|
323
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 },
|
|
324
473
|
{ id: 'seo', label: 'SEO', icon: _jsx(Globe, { size: 14 }), show: !isNew },
|
|
325
474
|
];
|
|
326
475
|
const visibleTabs = tabs.filter((t) => t.show);
|
|
327
|
-
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) => {
|
|
328
480
|
void handleSave(e);
|
|
329
|
-
}, 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({
|
|
330
487
|
'en-US': next['en-US'] ?? '',
|
|
331
488
|
'pl-PL': next['pl-PL'] ?? '',
|
|
332
489
|
}), onBaselineDescriptionChange: (next) => setDescription({
|
|
333
490
|
'en-US': next['en-US'] ?? '',
|
|
334
491
|
'pl-PL': next['pl-PL'] ?? '',
|
|
335
|
-
}) })) : 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", {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
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] })] })] }));
|
|
345
507
|
}
|
|
346
508
|
function pickName(name) {
|
|
347
509
|
return name['en-US'] ?? Object.values(name)[0] ?? '';
|
|
348
510
|
}
|
|
349
|
-
function SeoStub({ name }) {
|
|
350
|
-
const t = useTranslation('catalog');
|
|
351
|
-
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) })] })] }));
|
|
352
|
-
}
|
|
353
511
|
function VariantsSection({ productId }) {
|
|
354
512
|
const t = useTranslation('catalog');
|
|
355
513
|
const [variants, setVariants] = useState([]);
|
|
@@ -434,298 +592,6 @@ function CreateVariantInline({ onCreate, }) {
|
|
|
434
592
|
}, children: t('productEditor.variants.action.add') }) })] }));
|
|
435
593
|
}
|
|
436
594
|
// ---------------------------------------------------------------------------
|
|
437
|
-
// Gallery section (T085) — admin CRUD for the Product's gallery items.
|
|
438
|
-
// Foundation lacks an admin Asset upload endpoint, so for now the form
|
|
439
|
-
// accepts an existing assetId; future work adds drag-and-drop on top of
|
|
440
|
-
// an Assets module admin upload route.
|
|
441
|
-
// ---------------------------------------------------------------------------
|
|
442
|
-
const GALLERY_LABELS = ['base_image', 'small_image', 'thumbnail'];
|
|
443
|
-
/** Immutable array move used by drag-and-drop / arrow reordering. */
|
|
444
|
-
function moveGalleryItem(items, from, to) {
|
|
445
|
-
if (to < 0 || to >= items.length || from === to)
|
|
446
|
-
return items;
|
|
447
|
-
const next = items.slice();
|
|
448
|
-
const [moved] = next.splice(from, 1);
|
|
449
|
-
if (moved === undefined)
|
|
450
|
-
return items;
|
|
451
|
-
next.splice(to, 0, moved);
|
|
452
|
-
return next;
|
|
453
|
-
}
|
|
454
|
-
const GallerySection = forwardRef(function GallerySection({ productId }, ref) {
|
|
455
|
-
const t = useTranslation('catalog');
|
|
456
|
-
const [items, setItems] = useState([]);
|
|
457
|
-
const [images, setImages] = useState([]);
|
|
458
|
-
const [loading, setLoading] = useState(true);
|
|
459
|
-
const [busy, setBusy] = useState(false);
|
|
460
|
-
const [error, setError] = useState(null);
|
|
461
|
-
const [info, setInfo] = useState(null);
|
|
462
|
-
const [previewUrl, setPreviewUrl] = useState(null);
|
|
463
|
-
const dragIdRef = useRef(null);
|
|
464
|
-
// Server-truth snapshot (id order + labels) used to diff the staged edits
|
|
465
|
-
// that the page-Save button flushes.
|
|
466
|
-
const baselineRef = useRef('');
|
|
467
|
-
const snapshot = (list) => JSON.stringify(list.map((g) => ({ id: g.id, labels: [...g.labels].sort() })));
|
|
468
|
-
const refresh = useCallback(async () => {
|
|
469
|
-
setLoading(true);
|
|
470
|
-
setError(null);
|
|
471
|
-
try {
|
|
472
|
-
// Public PDP carries the resolved gallery (with asset urls) so
|
|
473
|
-
// admins see the same shape customers do; the admin GET returns
|
|
474
|
-
// bare ids without urls. The PDP also carries the product's flat
|
|
475
|
-
// `assets` (legacy product_assets) — the storefront renders those
|
|
476
|
-
// when the label-aware gallery is empty, so we surface them here
|
|
477
|
-
// too, otherwise a product whose images live on product_assets
|
|
478
|
-
// looks empty in the admin while showing fine on the storefront.
|
|
479
|
-
const res = await apiClient.get(`/api/v1/catalog/products/${productId}`);
|
|
480
|
-
const gallery = res.data.gallery ?? [];
|
|
481
|
-
const mapped = gallery
|
|
482
|
-
.slice()
|
|
483
|
-
.sort((a, b) => a.position - b.position)
|
|
484
|
-
.map((g) => ({
|
|
485
|
-
id: g.id,
|
|
486
|
-
productId,
|
|
487
|
-
assetId: g.asset.id,
|
|
488
|
-
position: g.position,
|
|
489
|
-
labels: g.labels,
|
|
490
|
-
asset: { url: g.asset.url, kind: g.asset.kind },
|
|
491
|
-
}));
|
|
492
|
-
setItems(mapped);
|
|
493
|
-
baselineRef.current = snapshot(mapped);
|
|
494
|
-
const assets = res.data.assets ?? [];
|
|
495
|
-
setImages(assets
|
|
496
|
-
.filter((a) => a.kind === 'image' || a.kind === 'video')
|
|
497
|
-
.map((a) => ({
|
|
498
|
-
id: a.id,
|
|
499
|
-
kind: a.kind,
|
|
500
|
-
url: a.url,
|
|
501
|
-
altText: a.altText ?? null,
|
|
502
|
-
})));
|
|
503
|
-
}
|
|
504
|
-
catch (err) {
|
|
505
|
-
setError(err instanceof ApiError ? err.envelope.error.message : t('productEditor.gallery.error.load'));
|
|
506
|
-
}
|
|
507
|
-
finally {
|
|
508
|
-
setLoading(false);
|
|
509
|
-
}
|
|
510
|
-
}, [productId, t]);
|
|
511
|
-
useEffect(() => {
|
|
512
|
-
void refresh();
|
|
513
|
-
}, [refresh]);
|
|
514
|
-
// --- Staged label edits: each label lives on at most one item; assigning it
|
|
515
|
-
// to one item strips it from every other (radio semantics). Persisted on
|
|
516
|
-
// page Save, so no per-row Save button and no "already taken" error. ---
|
|
517
|
-
const assignLabel = useCallback((label, itemId) => {
|
|
518
|
-
setInfo(null);
|
|
519
|
-
setItems((prev) => prev.map((it) => {
|
|
520
|
-
const without = it.labels.filter((l) => l !== label);
|
|
521
|
-
return { ...it, labels: it.id === itemId ? [...without, label] : without };
|
|
522
|
-
}));
|
|
523
|
-
}, []);
|
|
524
|
-
const clearLabel = useCallback((label) => {
|
|
525
|
-
setInfo(null);
|
|
526
|
-
setItems((prev) => prev.map((it) => ({ ...it, labels: it.labels.filter((l) => l !== label) })));
|
|
527
|
-
}, []);
|
|
528
|
-
// --- Staged reorder (array order === display order). ---
|
|
529
|
-
const moveItem = useCallback((from, to) => {
|
|
530
|
-
setInfo(null);
|
|
531
|
-
setItems((prev) => moveGalleryItem(prev, from, to));
|
|
532
|
-
}, []);
|
|
533
|
-
const handleDrop = useCallback((index) => {
|
|
534
|
-
const draggedId = dragIdRef.current;
|
|
535
|
-
if (!draggedId)
|
|
536
|
-
return;
|
|
537
|
-
setItems((prev) => {
|
|
538
|
-
const from = prev.findIndex((it) => it.id === draggedId);
|
|
539
|
-
return from < 0 || from === index ? prev : moveGalleryItem(prev, from, index);
|
|
540
|
-
});
|
|
541
|
-
}, []);
|
|
542
|
-
// --- Immediate CRUD (add / remove) — these hit the server directly and
|
|
543
|
-
// re-load, which also resets the staged baseline. ---
|
|
544
|
-
const handleCreate = useCallback(async (assetId) => {
|
|
545
|
-
setBusy(true);
|
|
546
|
-
try {
|
|
547
|
-
await apiClient.post(`/api/v1/admin/catalog/products/${productId}/gallery`, {
|
|
548
|
-
assetId,
|
|
549
|
-
labels: [],
|
|
550
|
-
});
|
|
551
|
-
setInfo(t('productEditor.gallery.success.add'));
|
|
552
|
-
await refresh();
|
|
553
|
-
}
|
|
554
|
-
catch (err) {
|
|
555
|
-
setError(err instanceof ApiError ? err.envelope.error.message : t('productEditor.gallery.error.add'));
|
|
556
|
-
}
|
|
557
|
-
finally {
|
|
558
|
-
setBusy(false);
|
|
559
|
-
}
|
|
560
|
-
}, [productId, refresh, t]);
|
|
561
|
-
const handleDelete = useCallback(async (itemId) => {
|
|
562
|
-
if (!confirm(t('productEditor.gallery.removeConfirm')))
|
|
563
|
-
return;
|
|
564
|
-
setBusy(true);
|
|
565
|
-
try {
|
|
566
|
-
await apiClient.delete(`/api/v1/admin/catalog/products/${productId}/gallery/${itemId}`);
|
|
567
|
-
setInfo(t('productEditor.gallery.success.remove'));
|
|
568
|
-
await refresh();
|
|
569
|
-
}
|
|
570
|
-
catch (err) {
|
|
571
|
-
setError(err instanceof ApiError ? err.envelope.error.message : t('productEditor.gallery.error.delete'));
|
|
572
|
-
}
|
|
573
|
-
finally {
|
|
574
|
-
setBusy(false);
|
|
575
|
-
}
|
|
576
|
-
}, [productId, refresh, t]);
|
|
577
|
-
// --- Page-Save hook: flush staged label + order edits. Labels are patched
|
|
578
|
-
// with `replace=true` so reassigning a label moves it atomically. ---
|
|
579
|
-
const flushGallery = useCallback(async () => {
|
|
580
|
-
const baseline = JSON.parse(baselineRef.current || '[]');
|
|
581
|
-
const baseLabels = new Map(baseline.map((b) => [b.id, [...b.labels].sort().join(',')]));
|
|
582
|
-
const changed = items.filter((it) => baseLabels.get(it.id) !== [...it.labels].sort().join(','));
|
|
583
|
-
for (const it of changed) {
|
|
584
|
-
await apiClient.patch(`/api/v1/admin/catalog/products/${productId}/gallery/${it.id}?replace=true`, { labels: it.labels });
|
|
585
|
-
}
|
|
586
|
-
const baseOrder = baseline.map((b) => b.id).join(',');
|
|
587
|
-
const curOrder = items.map((it) => it.id).join(',');
|
|
588
|
-
if (items.length > 0 && curOrder !== baseOrder) {
|
|
589
|
-
await apiClient.put(`/api/v1/admin/catalog/products/${productId}/gallery/order`, {
|
|
590
|
-
orderedGalleryItemIds: items.map((it) => it.id),
|
|
591
|
-
});
|
|
592
|
-
}
|
|
593
|
-
if (changed.length > 0 || curOrder !== baseOrder) {
|
|
594
|
-
await refresh();
|
|
595
|
-
}
|
|
596
|
-
}, [items, productId, refresh]);
|
|
597
|
-
useImperativeHandle(ref, () => ({ flushGallery }), [flushGallery]);
|
|
598
|
-
const disabled = busy || loading;
|
|
599
|
-
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) => {
|
|
600
|
-
dragIdRef.current = id;
|
|
601
|
-
}, onDragOver: (e) => e.preventDefault(), onDrop: handleDrop, onDragEnd: () => {
|
|
602
|
-
dragIdRef.current = null;
|
|
603
|
-
}, 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] }));
|
|
604
|
-
});
|
|
605
|
-
function GalleryRow({ item, index, total, disabled, onAssignLabel, onClearLabel, onMove, onDragStart, onDragOver, onDrop, onDragEnd, onPreview, onDelete, }) {
|
|
606
|
-
const t = useTranslation('catalog');
|
|
607
|
-
const url = item.asset?.url ? toAbsoluteAssetUrl(item.asset.url) : null;
|
|
608
|
-
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) => {
|
|
609
|
-
const checked = item.labels.includes(label);
|
|
610
|
-
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));
|
|
611
|
-
}), _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') })] })] }));
|
|
612
|
-
}
|
|
613
|
-
function CreateGalleryItemInline({ disabled, onCreate, }) {
|
|
614
|
-
const t = useTranslation('catalog');
|
|
615
|
-
const [assetId, setAssetId] = useState('');
|
|
616
|
-
const [pickerOpen, setPickerOpen] = useState(false);
|
|
617
|
-
const [pickedFilename, setPickedFilename] = useState(null);
|
|
618
|
-
const onPick = (a) => {
|
|
619
|
-
setAssetId(a.id);
|
|
620
|
-
setPickedFilename(a.filename);
|
|
621
|
-
setPickerOpen(false);
|
|
622
|
-
};
|
|
623
|
-
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: () => {
|
|
624
|
-
if (!assetId)
|
|
625
|
-
return;
|
|
626
|
-
void onCreate(assetId).then(() => {
|
|
627
|
-
setAssetId('');
|
|
628
|
-
setPickedFilename(null);
|
|
629
|
-
});
|
|
630
|
-
}, children: t('productEditor.gallery.action.add') }) })] })] }));
|
|
631
|
-
}
|
|
632
|
-
function AttachmentsSection({ productId }) {
|
|
633
|
-
const t = useTranslation('catalog');
|
|
634
|
-
const [attachments, setAttachments] = useState([]);
|
|
635
|
-
const [types, setTypes] = useState([]);
|
|
636
|
-
const [loading, setLoading] = useState(true);
|
|
637
|
-
const [error, setError] = useState(null);
|
|
638
|
-
const [info, setInfo] = useState(null);
|
|
639
|
-
const refresh = useCallback(async () => {
|
|
640
|
-
setLoading(true);
|
|
641
|
-
setError(null);
|
|
642
|
-
try {
|
|
643
|
-
const [detail, typesRes] = await Promise.all([
|
|
644
|
-
apiClient.get(`/api/v1/catalog/products/${productId}`),
|
|
645
|
-
apiClient.get('/api/v1/admin/catalog/attachment-types'),
|
|
646
|
-
]);
|
|
647
|
-
const detailAttachments = detail.data.attachments ?? [];
|
|
648
|
-
setAttachments(detailAttachments.map((a) => ({
|
|
649
|
-
id: a.id,
|
|
650
|
-
productId,
|
|
651
|
-
assetId: a.asset.id,
|
|
652
|
-
attachmentTypeId: a.type.id,
|
|
653
|
-
name: a.name,
|
|
654
|
-
description: a.description,
|
|
655
|
-
position: a.position,
|
|
656
|
-
asset: {
|
|
657
|
-
url: a.asset.url,
|
|
658
|
-
filename: a.asset.filename,
|
|
659
|
-
mimeType: a.asset.mimeType,
|
|
660
|
-
},
|
|
661
|
-
type: { code: a.type.code, name: a.type.name },
|
|
662
|
-
})));
|
|
663
|
-
setTypes(typesRes.data);
|
|
664
|
-
}
|
|
665
|
-
catch (err) {
|
|
666
|
-
setError(err instanceof ApiError ? err.envelope.error.message : t('productEditor.attachments.error.load'));
|
|
667
|
-
}
|
|
668
|
-
finally {
|
|
669
|
-
setLoading(false);
|
|
670
|
-
}
|
|
671
|
-
}, [productId, t]);
|
|
672
|
-
useEffect(() => {
|
|
673
|
-
void refresh();
|
|
674
|
-
}, [refresh]);
|
|
675
|
-
const handleCreate = useCallback(async (input) => {
|
|
676
|
-
try {
|
|
677
|
-
await apiClient.post(`/api/v1/admin/catalog/products/${productId}/attachments`, {
|
|
678
|
-
assetId: input.assetId,
|
|
679
|
-
attachmentTypeId: input.attachmentTypeId,
|
|
680
|
-
name: input.name,
|
|
681
|
-
...(input.description ? { description: input.description } : {}),
|
|
682
|
-
});
|
|
683
|
-
setInfo(t('productEditor.attachments.success.add'));
|
|
684
|
-
await refresh();
|
|
685
|
-
}
|
|
686
|
-
catch (err) {
|
|
687
|
-
setError(err instanceof ApiError ? err.envelope.error.message : t('productEditor.attachments.error.add'));
|
|
688
|
-
}
|
|
689
|
-
}, [productId, refresh, t]);
|
|
690
|
-
const handleDelete = useCallback(async (attachmentId, name) => {
|
|
691
|
-
if (!confirm(t('productEditor.attachments.deleteConfirm', { name })))
|
|
692
|
-
return;
|
|
693
|
-
try {
|
|
694
|
-
await apiClient.delete(`/api/v1/admin/catalog/products/${productId}/attachments/${attachmentId}`);
|
|
695
|
-
setInfo(t('productEditor.attachments.success.delete', { name }));
|
|
696
|
-
await refresh();
|
|
697
|
-
}
|
|
698
|
-
catch (err) {
|
|
699
|
-
setError(err instanceof ApiError ? err.envelope.error.message : t('productEditor.attachments.error.delete'));
|
|
700
|
-
}
|
|
701
|
-
}, [productId, refresh, t]);
|
|
702
|
-
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 })] })] }));
|
|
703
|
-
}
|
|
704
|
-
function CreateAttachmentInline({ types, onCreate, }) {
|
|
705
|
-
const [assetId, setAssetId] = useState('');
|
|
706
|
-
const [attachmentTypeId, setAttachmentTypeId] = useState('');
|
|
707
|
-
const [name, setName] = useState('');
|
|
708
|
-
const [description, setDescription] = useState('');
|
|
709
|
-
const [pickerOpen, setPickerOpen] = useState(false);
|
|
710
|
-
const [pickedFilename, setPickedFilename] = useState(null);
|
|
711
|
-
const t = useTranslation('catalog');
|
|
712
|
-
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) => {
|
|
713
|
-
setAssetId(a.id);
|
|
714
|
-
setPickedFilename(a.filename);
|
|
715
|
-
setPickerOpen(false);
|
|
716
|
-
}, 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: () => {
|
|
717
|
-
if (!assetId || !attachmentTypeId || !name)
|
|
718
|
-
return;
|
|
719
|
-
void onCreate({ assetId, attachmentTypeId, name, description }).then(() => {
|
|
720
|
-
setAssetId('');
|
|
721
|
-
setPickedFilename(null);
|
|
722
|
-
setAttachmentTypeId('');
|
|
723
|
-
setName('');
|
|
724
|
-
setDescription('');
|
|
725
|
-
});
|
|
726
|
-
}, children: t('productEditor.attachments.action.add') }) })] })] }));
|
|
727
|
-
}
|
|
728
|
-
// ---------------------------------------------------------------------------
|
|
729
595
|
// Product Links section (T109, US4) — Related / Up-sell / Cross-sell.
|
|
730
596
|
// Three sub-lists, one product picker (paste id) + kind selector +
|
|
731
597
|
// "Add" button per kind. Backend bulkCreate is all-or-nothing and
|
|
@@ -828,10 +694,12 @@ function ProductLinksSection({ productId }) {
|
|
|
828
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) => {
|
|
829
695
|
const target = targetsById.get(link.targetProductId);
|
|
830
696
|
const isMissing = !target;
|
|
697
|
+
// `inactive` is plain off; archived is its own fact.
|
|
831
698
|
const isInactive = target?.status === 'inactive';
|
|
832
|
-
|
|
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
|
|
833
701
|
? pickProductName(target.name, target.slug)
|
|
834
|
-
: `${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));
|
|
835
703
|
}) })] }))] }, kind))) })), _jsx(CreateProductLinkInline, { onCreate: handleCreate, sourceProductId: productId })] })] }));
|
|
836
704
|
}
|
|
837
705
|
function CreateProductLinkInline({ onCreate, sourceProductId, }) {
|