@vendure/dashboard 3.2.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/README.md +13 -0
- package/dist/plugin/.vendure-dashboard-temp/dev-config.js +227 -0
- package/dist/plugin/.vendure-dashboard-temp/dev-config.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/api/api-extensions.js +33 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/api/api-extensions.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/api/mv.resolver.js +69 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/api/mv.resolver.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/config/mv-order-process.js +110 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/config/mv-order-process.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/config/mv-order-seller-strategy.js +134 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/config/mv-order-seller-strategy.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/config/mv-payment-handler.js +86 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/config/mv-payment-handler.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/config/mv-shipping-eligibility-checker.js +49 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/config/mv-shipping-eligibility-checker.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/config/mv-shipping-line-assignment-strategy.js +57 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/config/mv-shipping-line-assignment-strategy.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/constants.js +20 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/constants.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/multivendor.plugin.js +151 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/multivendor.plugin.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/payment/mv-connect-sdk.js +47 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/payment/mv-connect-sdk.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/service/mv.service.js +222 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/service/mv.service.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/types.js +4 -0
- package/dist/plugin/.vendure-dashboard-temp/example-plugins/multivendor-plugin/types.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/package.json +3 -0
- package/dist/plugin/.vendure-dashboard-temp/schema.graphql +6378 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/api/api-extensions.js +103 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/api/api-extensions.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/api/product-entity.resolver.js +105 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/api/product-entity.resolver.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/api/product-review-admin.resolver.js +183 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/api/product-review-admin.resolver.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/api/product-review-entity.resolver.js +113 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/api/product-review-entity.resolver.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/api/product-review-shop.resolver.js +112 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/api/product-review-shop.resolver.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/entities/product-review.entity.js +111 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/entities/product-review.entity.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/generated-admin-types.js +616 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/generated-admin-types.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/generated-shop-types.js +563 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/generated-shop-types.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/reviews-plugin.js +135 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/reviews-plugin.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/types.js +4 -0
- package/dist/plugin/.vendure-dashboard-temp/test-plugins/reviews/types.js.map +1 -0
- package/dist/plugin/.vendure-dashboard-temp/tsconfig.json +10 -0
- package/dist/plugin/config-loader.d.ts +27 -0
- package/dist/plugin/config-loader.js +141 -0
- package/dist/plugin/constants.d.ts +5 -0
- package/dist/plugin/constants.js +277 -0
- package/dist/plugin/index.d.ts +1 -0
- package/dist/plugin/index.js +1 -0
- package/dist/plugin/schema-generator.d.ts +5 -0
- package/dist/plugin/schema-generator.js +24 -0
- package/dist/plugin/ui-config.d.ts +3 -0
- package/dist/plugin/ui-config.js +35 -0
- package/dist/plugin/vite-plugin-admin-api-schema.d.ts +24 -0
- package/dist/plugin/vite-plugin-admin-api-schema.js +82 -0
- package/dist/plugin/vite-plugin-config-loader.d.ts +17 -0
- package/dist/plugin/vite-plugin-config-loader.js +56 -0
- package/dist/plugin/vite-plugin-config.d.ts +4 -0
- package/dist/plugin/vite-plugin-config.js +38 -0
- package/dist/plugin/vite-plugin-dashboard-metadata.d.ts +9 -0
- package/dist/plugin/vite-plugin-dashboard-metadata.js +52 -0
- package/dist/plugin/vite-plugin-gql-tada.d.ts +6 -0
- package/dist/plugin/vite-plugin-gql-tada.js +51 -0
- package/dist/plugin/vite-plugin-set-root.d.ts +4 -0
- package/dist/plugin/vite-plugin-set-root.js +15 -0
- package/dist/plugin/vite-plugin-ui-config.d.ts +15 -0
- package/dist/plugin/vite-plugin-ui-config.js +43 -0
- package/dist/plugin/vite-plugin-vendure-dashboard.d.ts +35 -0
- package/dist/plugin/vite-plugin-vendure-dashboard.js +81 -0
- package/index.html +15 -0
- package/lingui.config.js +12 -0
- package/package.json +118 -0
- package/src/app/app-providers.tsx +30 -0
- package/src/app/main.tsx +97 -0
- package/src/app/routeTree.gen.ts +1372 -0
- package/src/app/routes/__root.tsx +24 -0
- package/src/app/routes/_authenticated/_administrators/administrators.graphql.ts +79 -0
- package/src/app/routes/_authenticated/_administrators/administrators.tsx +86 -0
- package/src/app/routes/_authenticated/_administrators/administrators_.$id.tsx +155 -0
- package/src/app/routes/_authenticated/_administrators/components/role-permissions-display.tsx +133 -0
- package/src/app/routes/_authenticated/_assets/assets.tsx +19 -0
- package/src/app/routes/_authenticated/_channels/channels.graphql.ts +93 -0
- package/src/app/routes/_authenticated/_channels/channels.tsx +60 -0
- package/src/app/routes/_authenticated/_channels/channels_.$id.tsx +248 -0
- package/src/app/routes/_authenticated/_collections/collections.graphql.ts +133 -0
- package/src/app/routes/_authenticated/_collections/collections.tsx +195 -0
- package/src/app/routes/_authenticated/_collections/collections_.$id.tsx +224 -0
- package/src/app/routes/_authenticated/_collections/components/collection-contents-preview-table.tsx +127 -0
- package/src/app/routes/_authenticated/_collections/components/collection-contents-sheet.tsx +46 -0
- package/src/app/routes/_authenticated/_collections/components/collection-contents-table.tsx +82 -0
- package/src/app/routes/_authenticated/_collections/components/collection-filters-selector.tsx +91 -0
- package/src/app/routes/_authenticated/_countries/countries.graphql.ts +69 -0
- package/src/app/routes/_authenticated/_countries/countries.tsx +67 -0
- package/src/app/routes/_authenticated/_countries/countries_.$id.tsx +122 -0
- package/src/app/routes/_authenticated/_customer-groups/components/customer-group-members-sheet.tsx +44 -0
- package/src/app/routes/_authenticated/_customer-groups/components/customer-group-members-table.tsx +129 -0
- package/src/app/routes/_authenticated/_customer-groups/customer-groups.graphql.ts +71 -0
- package/src/app/routes/_authenticated/_customer-groups/customer-groups.tsx +68 -0
- package/src/app/routes/_authenticated/_customer-groups/customer-groups_.$id.tsx +111 -0
- package/src/app/routes/_authenticated/_customers/components/customer-address-card.tsx +155 -0
- package/src/app/routes/_authenticated/_customers/components/customer-address-form.tsx +344 -0
- package/src/app/routes/_authenticated/_customers/components/customer-group-controls.tsx +4 -0
- package/src/app/routes/_authenticated/_customers/components/customer-history/customer-history-container.tsx +78 -0
- package/src/app/routes/_authenticated/_customers/components/customer-history/customer-history.tsx +77 -0
- package/src/app/routes/_authenticated/_customers/components/customer-history/index.ts +3 -0
- package/src/app/routes/_authenticated/_customers/components/customer-history/use-customer-history.ts +169 -0
- package/src/app/routes/_authenticated/_customers/components/customer-order-table.tsx +88 -0
- package/src/app/routes/_authenticated/_customers/components/customer-status-badge.tsx +33 -0
- package/src/app/routes/_authenticated/_customers/customers.graphql.ts +204 -0
- package/src/app/routes/_authenticated/_customers/customers.tsx +82 -0
- package/src/app/routes/_authenticated/_customers/customers_.$id.tsx +274 -0
- package/src/app/routes/_authenticated/_facets/components/edit-facet-value.tsx +129 -0
- package/src/app/routes/_authenticated/_facets/components/facet-values-sheet.tsx +46 -0
- package/src/app/routes/_authenticated/_facets/components/facet-values-table.tsx +97 -0
- package/src/app/routes/_authenticated/_facets/facets.graphql.ts +104 -0
- package/src/app/routes/_authenticated/_facets/facets.tsx +97 -0
- package/src/app/routes/_authenticated/_facets/facets_.$id.tsx +139 -0
- package/src/app/routes/_authenticated/_global-settings/global-settings.graphql.ts +28 -0
- package/src/app/routes/_authenticated/_global-settings/global-settings.tsx +161 -0
- package/src/app/routes/_authenticated/_orders/components/order-address.tsx +58 -0
- package/src/app/routes/_authenticated/_orders/components/order-history/index.ts +3 -0
- package/src/app/routes/_authenticated/_orders/components/order-history/order-history-container.tsx +73 -0
- package/src/app/routes/_authenticated/_orders/components/order-history/order-history.tsx +96 -0
- package/src/app/routes/_authenticated/_orders/components/order-history/use-order-history.ts +171 -0
- package/src/app/routes/_authenticated/_orders/components/order-table.tsx +169 -0
- package/src/app/routes/_authenticated/_orders/components/order-tax-summary.tsx +39 -0
- package/src/app/routes/_authenticated/_orders/components/payment-details.tsx +61 -0
- package/src/app/routes/_authenticated/_orders/orders.graphql.ts +325 -0
- package/src/app/routes/_authenticated/_orders/orders.tsx +120 -0
- package/src/app/routes/_authenticated/_orders/orders_.$id.tsx +133 -0
- package/src/app/routes/_authenticated/_payment-methods/components/payment-eligibility-checker-selector.tsx +104 -0
- package/src/app/routes/_authenticated/_payment-methods/components/payment-handler-selector.tsx +100 -0
- package/src/app/routes/_authenticated/_payment-methods/payment-methods.graphql.ts +83 -0
- package/src/app/routes/_authenticated/_payment-methods/payment-methods.tsx +64 -0
- package/src/app/routes/_authenticated/_payment-methods/payment-methods_.$id.tsx +183 -0
- package/src/app/routes/_authenticated/_product-variants/components/variant-price-detail.tsx +87 -0
- package/src/app/routes/_authenticated/_product-variants/product-variants.graphql.ts +123 -0
- package/src/app/routes/_authenticated/_product-variants/product-variants.tsx +78 -0
- package/src/app/routes/_authenticated/_product-variants/product-variants_.$id.tsx +331 -0
- package/src/app/routes/_authenticated/_products/components/create-product-variants-dialog.tsx +228 -0
- package/src/app/routes/_authenticated/_products/components/create-product-variants.tsx +462 -0
- package/src/app/routes/_authenticated/_products/components/option-value-input.tsx +96 -0
- package/src/app/routes/_authenticated/_products/components/product-variants-table.tsx +87 -0
- package/src/app/routes/_authenticated/_products/products.graphql.ts +116 -0
- package/src/app/routes/_authenticated/_products/products.tsx +48 -0
- package/src/app/routes/_authenticated/_products/products_.$id.tsx +196 -0
- package/src/app/routes/_authenticated/_profile/profile.graphql.ts +23 -0
- package/src/app/routes/_authenticated/_profile/profile.tsx +122 -0
- package/src/app/routes/_authenticated/_promotions/components/promotion-actions-selector.tsx +107 -0
- package/src/app/routes/_authenticated/_promotions/components/promotion-conditions-selector.tsx +107 -0
- package/src/app/routes/_authenticated/_promotions/promotions.graphql.ts +96 -0
- package/src/app/routes/_authenticated/_promotions/promotions.tsx +61 -0
- package/src/app/routes/_authenticated/_promotions/promotions_.$id.tsx +235 -0
- package/src/app/routes/_authenticated/_roles/components/expandable-permissions.tsx +54 -0
- package/src/app/routes/_authenticated/_roles/components/permissions-grid.tsx +116 -0
- package/src/app/routes/_authenticated/_roles/roles.graphql.ts +67 -0
- package/src/app/routes/_authenticated/_roles/roles.tsx +96 -0
- package/src/app/routes/_authenticated/_roles/roles_.$id.tsx +142 -0
- package/src/app/routes/_authenticated/_sellers/sellers.graphql.ts +61 -0
- package/src/app/routes/_authenticated/_sellers/sellers.tsx +51 -0
- package/src/app/routes/_authenticated/_sellers/sellers_.$id.tsx +111 -0
- package/src/app/routes/_authenticated/_shipping-methods/components/fulfillment-handler-selector.tsx +56 -0
- package/src/app/routes/_authenticated/_shipping-methods/components/shipping-calculator-selector.tsx +101 -0
- package/src/app/routes/_authenticated/_shipping-methods/components/shipping-eligibility-checker-selector.tsx +101 -0
- package/src/app/routes/_authenticated/_shipping-methods/components/test-shipping-method-dialog.tsx +32 -0
- package/src/app/routes/_authenticated/_shipping-methods/shipping-methods.graphql.ts +83 -0
- package/src/app/routes/_authenticated/_shipping-methods/shipping-methods.tsx +55 -0
- package/src/app/routes/_authenticated/_shipping-methods/shipping-methods_.$id.tsx +171 -0
- package/src/app/routes/_authenticated/_stock-locations/stock-locations.graphql.ts +62 -0
- package/src/app/routes/_authenticated/_stock-locations/stock-locations.tsx +48 -0
- package/src/app/routes/_authenticated/_stock-locations/stock-locations_.$id.tsx +115 -0
- package/src/app/routes/_authenticated/_system/components/payload-dialog.tsx +34 -0
- package/src/app/routes/_authenticated/_system/healthchecks.tsx +93 -0
- package/src/app/routes/_authenticated/_system/job-queue.graphql.ts +43 -0
- package/src/app/routes/_authenticated/_system/job-queue.tsx +161 -0
- package/src/app/routes/_authenticated/_tax-categories/tax-categories.graphql.ts +63 -0
- package/src/app/routes/_authenticated/_tax-categories/tax-categories.tsx +65 -0
- package/src/app/routes/_authenticated/_tax-categories/tax-categories_.$id.tsx +115 -0
- package/src/app/routes/_authenticated/_tax-rates/tax-rates.graphql.ts +75 -0
- package/src/app/routes/_authenticated/_tax-rates/tax-rates.tsx +108 -0
- package/src/app/routes/_authenticated/_tax-rates/tax-rates_.$id.tsx +148 -0
- package/src/app/routes/_authenticated/_zones/components/zone-countries-add.tsx +0 -0
- package/src/app/routes/_authenticated/_zones/components/zone-countries-sheet.tsx +31 -0
- package/src/app/routes/_authenticated/_zones/components/zone-countries-table.tsx +79 -0
- package/src/app/routes/_authenticated/_zones/zones.graphql.ts +96 -0
- package/src/app/routes/_authenticated/_zones/zones.tsx +57 -0
- package/src/app/routes/_authenticated/_zones/zones_.$id.tsx +103 -0
- package/src/app/routes/_authenticated/index.tsx +194 -0
- package/src/app/routes/_authenticated.tsx +25 -0
- package/src/app/routes/login.tsx +48 -0
- package/src/app/styles.css +82 -0
- package/src/app/tailwindcss-animate.css +275 -0
- package/src/i18n/locales/de.po +1579 -0
- package/src/i18n/locales/en.po +1579 -0
- package/src/lib/components/data-display/boolean.tsx +23 -0
- package/src/lib/components/data-display/date-time.tsx +13 -0
- package/src/lib/components/data-display/json.tsx +5 -0
- package/src/lib/components/data-display/money.tsx +15 -0
- package/src/lib/components/data-input/affixed-input.tsx +49 -0
- package/src/lib/components/data-input/customer-group-input.tsx +72 -0
- package/src/lib/components/data-input/datetime-input.tsx +150 -0
- package/src/lib/components/data-input/facet-value-input.tsx +68 -0
- package/src/lib/components/data-input/money-input.tsx +112 -0
- package/src/lib/components/data-input/richt-text-input.tsx +99 -0
- package/src/lib/components/data-table/data-table-column-header.tsx +73 -0
- package/src/lib/components/data-table/data-table-faceted-filter.tsx +172 -0
- package/src/lib/components/data-table/data-table-filter-dialog.tsx +73 -0
- package/src/lib/components/data-table/data-table-pagination.tsx +87 -0
- package/src/lib/components/data-table/data-table-view-options.tsx +53 -0
- package/src/lib/components/data-table/data-table.tsx +218 -0
- package/src/lib/components/layout/app-layout.tsx +42 -0
- package/src/lib/components/layout/app-sidebar.tsx +34 -0
- package/src/lib/components/layout/channel-switcher.tsx +87 -0
- package/src/lib/components/layout/content-language-selector.tsx +41 -0
- package/src/lib/components/layout/generated-breadcrumbs.tsx +82 -0
- package/src/lib/components/layout/language-dialog.tsx +104 -0
- package/src/lib/components/layout/nav-main.tsx +178 -0
- package/src/lib/components/layout/nav-projects.tsx +81 -0
- package/src/lib/components/layout/nav-user.tsx +176 -0
- package/src/lib/components/layout/prerelease-popup.tsx +38 -0
- package/src/lib/components/login/login-form.tsx +173 -0
- package/src/lib/components/shared/alerts.tsx +20 -0
- package/src/lib/components/shared/animated-number.tsx +49 -0
- package/src/lib/components/shared/asset-gallery.tsx +433 -0
- package/src/lib/components/shared/asset-picker-dialog.tsx +72 -0
- package/src/lib/components/shared/asset-preview-dialog.tsx +48 -0
- package/src/lib/components/shared/asset-preview.tsx +345 -0
- package/src/lib/components/shared/assigned-facet-values.tsx +68 -0
- package/src/lib/components/shared/channel-code-label.tsx +7 -0
- package/src/lib/components/shared/channel-selector.tsx +51 -0
- package/src/lib/components/shared/configurable-operation-arg-input.tsx +51 -0
- package/src/lib/components/shared/configurable-operation-input.tsx +133 -0
- package/src/lib/components/shared/confirmation-dialog.tsx +58 -0
- package/src/lib/components/shared/copyable-text.tsx +31 -0
- package/src/lib/components/shared/country-selector.tsx +105 -0
- package/src/lib/components/shared/currency-selector.tsx +33 -0
- package/src/lib/components/shared/custom-fields-form.tsx +86 -0
- package/src/lib/components/shared/customer-address-form.tsx +330 -0
- package/src/lib/components/shared/customer-group-chip.tsx +30 -0
- package/src/lib/components/shared/customer-group-selector.tsx +62 -0
- package/src/lib/components/shared/customer-selector.tsx +107 -0
- package/src/lib/components/shared/detail-page-button.tsx +22 -0
- package/src/lib/components/shared/entity-assets.tsx +340 -0
- package/src/lib/components/shared/error-page.tsx +31 -0
- package/src/lib/components/shared/facet-value-chip.tsx +45 -0
- package/src/lib/components/shared/facet-value-selector.tsx +306 -0
- package/src/lib/components/shared/focal-point-control.tsx +65 -0
- package/src/lib/components/shared/form-field-wrapper.tsx +37 -0
- package/src/lib/components/shared/history-timeline/history-entry.tsx +112 -0
- package/src/lib/components/shared/history-timeline/history-note-checkbox.tsx +28 -0
- package/src/lib/components/shared/history-timeline/history-note-editor.tsx +60 -0
- package/src/lib/components/shared/history-timeline/history-note-input.tsx +39 -0
- package/src/lib/components/shared/history-timeline/history-timeline.tsx +56 -0
- package/src/lib/components/shared/icon-mark.tsx +18 -0
- package/src/lib/components/shared/language-selector.tsx +48 -0
- package/src/lib/components/shared/logo-mark.tsx +24 -0
- package/src/lib/components/shared/multi-select.tsx +159 -0
- package/src/lib/components/shared/option-value-input.tsx +95 -0
- package/src/lib/components/shared/paginated-list-data-table.tsx +520 -0
- package/src/lib/components/shared/permission-guard.tsx +21 -0
- package/src/lib/components/shared/rich-text-editor.tsx +0 -0
- package/src/lib/components/shared/role-code-label.tsx +8 -0
- package/src/lib/components/shared/role-selector.tsx +56 -0
- package/src/lib/components/shared/seller-selector.tsx +107 -0
- package/src/lib/components/shared/tax-category-selector.tsx +65 -0
- package/src/lib/components/shared/translatable-form-field.tsx +74 -0
- package/src/lib/components/shared/vendure-image.tsx +159 -0
- package/src/lib/components/shared/zone-selector.tsx +66 -0
- package/src/lib/components/ui/accordion.tsx +59 -0
- package/src/lib/components/ui/alert-dialog.tsx +128 -0
- package/src/lib/components/ui/alert.tsx +60 -0
- package/src/lib/components/ui/avatar.tsx +38 -0
- package/src/lib/components/ui/badge.tsx +38 -0
- package/src/lib/components/ui/breadcrumb.tsx +102 -0
- package/src/lib/components/ui/button.tsx +51 -0
- package/src/lib/components/ui/calendar.tsx +69 -0
- package/src/lib/components/ui/card.tsx +47 -0
- package/src/lib/components/ui/checkbox.tsx +27 -0
- package/src/lib/components/ui/collapsible.tsx +33 -0
- package/src/lib/components/ui/command.tsx +133 -0
- package/src/lib/components/ui/dialog.tsx +116 -0
- package/src/lib/components/ui/dropdown-menu.tsx +220 -0
- package/src/lib/components/ui/form.tsx +141 -0
- package/src/lib/components/ui/hover-card.tsx +36 -0
- package/src/lib/components/ui/input.tsx +19 -0
- package/src/lib/components/ui/label.tsx +21 -0
- package/src/lib/components/ui/pagination.tsx +127 -0
- package/src/lib/components/ui/popover.tsx +40 -0
- package/src/lib/components/ui/scroll-area.tsx +50 -0
- package/src/lib/components/ui/select.tsx +161 -0
- package/src/lib/components/ui/separator.tsx +26 -0
- package/src/lib/components/ui/sheet.tsx +118 -0
- package/src/lib/components/ui/sidebar.tsx +696 -0
- package/src/lib/components/ui/skeleton.tsx +13 -0
- package/src/lib/components/ui/sonner.tsx +27 -0
- package/src/lib/components/ui/switch.tsx +26 -0
- package/src/lib/components/ui/table.tsx +82 -0
- package/src/lib/components/ui/tabs.tsx +48 -0
- package/src/lib/components/ui/textarea.tsx +18 -0
- package/src/lib/components/ui/tooltip.tsx +51 -0
- package/src/lib/constants.ts +326 -0
- package/src/lib/framework/component-registry/component-registry.tsx +70 -0
- package/src/lib/framework/component-registry/dynamic-component.tsx +58 -0
- package/src/lib/framework/dashboard-widget/base-widget.tsx +97 -0
- package/src/lib/framework/dashboard-widget/latest-orders-widget/index.tsx +96 -0
- package/src/lib/framework/dashboard-widget/latest-orders-widget/latest-orders-widget.graphql.ts +35 -0
- package/src/lib/framework/dashboard-widget/metrics-widget/chart.tsx +24 -0
- package/src/lib/framework/dashboard-widget/metrics-widget/index.tsx +82 -0
- package/src/lib/framework/dashboard-widget/metrics-widget/metrics-widget.graphql.ts +14 -0
- package/src/lib/framework/dashboard-widget/orders-summary/index.tsx +167 -0
- package/src/lib/framework/dashboard-widget/orders-summary/order-summary-widget.graphql.ts +14 -0
- package/src/lib/framework/dashboard-widget/types.ts +22 -0
- package/src/lib/framework/dashboard-widget/widget-extensions.tsx +19 -0
- package/src/lib/framework/defaults.ts +219 -0
- package/src/lib/framework/document-introspection/add-custom-fields.spec.ts +242 -0
- package/src/lib/framework/document-introspection/add-custom-fields.ts +246 -0
- package/src/lib/framework/document-introspection/get-document-structure.spec.ts +310 -0
- package/src/lib/framework/document-introspection/get-document-structure.ts +460 -0
- package/src/lib/framework/document-introspection/hooks.ts +10 -0
- package/src/lib/framework/extension-api/define-dashboard-extension.ts +66 -0
- package/src/lib/framework/extension-api/extension-api-types.ts +58 -0
- package/src/lib/framework/extension-api/use-dashboard-extensions.ts +26 -0
- package/src/lib/framework/form-engine/form-schema-tools.ts +98 -0
- package/src/lib/framework/form-engine/use-generated-form.tsx +116 -0
- package/src/lib/framework/layout-engine/layout-extensions.ts +30 -0
- package/src/lib/framework/layout-engine/location-wrapper.tsx +96 -0
- package/src/lib/framework/layout-engine/page-layout.tsx +272 -0
- package/src/lib/framework/nav-menu/nav-menu-extensions.ts +66 -0
- package/src/lib/framework/page/detail-page-route-loader.tsx +48 -0
- package/src/lib/framework/page/detail-page.tsx +131 -0
- package/src/lib/framework/page/list-page.tsx +166 -0
- package/src/lib/framework/page/page-api.ts +9 -0
- package/src/lib/framework/page/page-types.ts +51 -0
- package/src/lib/framework/page/use-detail-page.ts +217 -0
- package/src/lib/framework/page/use-extended-router.tsx +69 -0
- package/src/lib/framework/registry/global-registry.ts +46 -0
- package/src/lib/framework/registry/registry-types.ts +15 -0
- package/src/lib/graphql/api.ts +61 -0
- package/src/lib/graphql/fragments.tsx +54 -0
- package/src/lib/graphql/graphql-env.d.ts +499 -0
- package/src/lib/graphql/graphql.ts +15 -0
- package/src/lib/hooks/use-auth.tsx +11 -0
- package/src/lib/hooks/use-channel.ts +12 -0
- package/src/lib/hooks/use-custom-field-config.ts +10 -0
- package/src/lib/hooks/use-grouped-permissions.ts +54 -0
- package/src/lib/hooks/use-local-format.ts +119 -0
- package/src/lib/hooks/use-mobile.ts +19 -0
- package/src/lib/hooks/use-page.tsx +11 -0
- package/src/lib/hooks/use-permissions.ts +22 -0
- package/src/lib/hooks/use-server-config.ts +4 -0
- package/src/lib/hooks/use-theme.ts +10 -0
- package/src/lib/hooks/use-user-settings.tsx +12 -0
- package/src/lib/index.ts +149 -0
- package/src/lib/lib/trans.tsx +16 -0
- package/src/lib/lib/utils.ts +60 -0
- package/src/lib/providers/auth.tsx +152 -0
- package/src/lib/providers/channel-provider.tsx +121 -0
- package/src/lib/providers/i18n-provider.tsx +28 -0
- package/src/lib/providers/server-config.tsx +279 -0
- package/src/lib/providers/theme-provider.tsx +54 -0
- package/src/lib/providers/user-settings.tsx +89 -0
- package/src/lib/virtual.d.ts +12 -0
- package/vite/config-loader.ts +181 -0
- package/vite/constants.ts +280 -0
- package/vite/index.ts +1 -0
- package/vite/schema-generator.ts +40 -0
- package/vite/ui-config.ts +60 -0
- package/vite/vite-plugin-admin-api-schema.ts +141 -0
- package/vite/vite-plugin-config-loader.ts +64 -0
- package/vite/vite-plugin-config.ts +42 -0
- package/vite/vite-plugin-dashboard-metadata.ts +58 -0
- package/vite/vite-plugin-gql-tada.ts +62 -0
- package/vite/vite-plugin-theme.ts +195 -0
- package/vite/vite-plugin-ui-config.ts +60 -0
- package/vite/vite-plugin-vendure-dashboard.ts +118 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Button } from '@/components/ui/button.js';
|
|
2
|
+
import { Command, CommandItem, CommandList } from '@/components/ui/command.js';
|
|
3
|
+
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover.js';
|
|
4
|
+
import { api } from '@/graphql/api.js';
|
|
5
|
+
import { graphql } from '@/graphql/graphql.js';
|
|
6
|
+
import { Trans } from '@/lib/trans.js';
|
|
7
|
+
import { useQuery } from '@tanstack/react-query';
|
|
8
|
+
import { Plus } from 'lucide-react';
|
|
9
|
+
import { useState } from 'react';
|
|
10
|
+
|
|
11
|
+
const customerGroupsDocument = graphql(`
|
|
12
|
+
query GetCustomerGroups($options: CustomerGroupListOptions) {
|
|
13
|
+
customerGroups(options: $options) {
|
|
14
|
+
items {
|
|
15
|
+
id
|
|
16
|
+
name
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
`);
|
|
21
|
+
|
|
22
|
+
export interface CustomerGroupSelectorProps {
|
|
23
|
+
onSelect: (value: { id: string; name: string }) => void;
|
|
24
|
+
readOnly?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function CustomerGroupSelector(props: CustomerGroupSelectorProps) {
|
|
28
|
+
const [open, setOpen] = useState(false);
|
|
29
|
+
|
|
30
|
+
const { data: groups } = useQuery({
|
|
31
|
+
queryKey: ['customerGroups'],
|
|
32
|
+
queryFn: () =>
|
|
33
|
+
api.query(customerGroupsDocument, {
|
|
34
|
+
options: {
|
|
35
|
+
sort: { name: 'ASC' },
|
|
36
|
+
},
|
|
37
|
+
}),
|
|
38
|
+
staleTime: 1000 * 60 * 5,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Popover open={open} onOpenChange={setOpen}>
|
|
43
|
+
<PopoverTrigger asChild>
|
|
44
|
+
<Button variant="outline" size="sm" type="button" disabled={props.readOnly} className="gap-2">
|
|
45
|
+
<Plus className="h-4 w-4" />
|
|
46
|
+
<Trans>Add customer groups</Trans>
|
|
47
|
+
</Button>
|
|
48
|
+
</PopoverTrigger>
|
|
49
|
+
<PopoverContent className="p-0" align="start">
|
|
50
|
+
<Command shouldFilter={false}>
|
|
51
|
+
<CommandList>
|
|
52
|
+
{groups?.customerGroups.items.map(group => (
|
|
53
|
+
<CommandItem key={group.id} onSelect={() => props.onSelect(group)}>
|
|
54
|
+
{group.name}
|
|
55
|
+
</CommandItem>
|
|
56
|
+
))}
|
|
57
|
+
</CommandList>
|
|
58
|
+
</Command>
|
|
59
|
+
</PopoverContent>
|
|
60
|
+
</Popover>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { Button } from '@/components/ui/button.js';
|
|
2
|
+
import { Command, CommandEmpty, CommandInput, CommandItem, CommandList } from '@/components/ui/command.js';
|
|
3
|
+
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover.js';
|
|
4
|
+
import { api } from '@/graphql/api.js';
|
|
5
|
+
import { graphql } from '@/graphql/graphql.js';
|
|
6
|
+
import { Trans } from '@/lib/trans.js';
|
|
7
|
+
import { useQuery } from '@tanstack/react-query';
|
|
8
|
+
import { Plus, Search } from 'lucide-react';
|
|
9
|
+
import { useState } from 'react';
|
|
10
|
+
|
|
11
|
+
const customersDocument = graphql(`
|
|
12
|
+
query GetCustomers($options: CustomerListOptions) {
|
|
13
|
+
customers(options: $options) {
|
|
14
|
+
items {
|
|
15
|
+
id
|
|
16
|
+
firstName
|
|
17
|
+
lastName
|
|
18
|
+
emailAddress
|
|
19
|
+
}
|
|
20
|
+
totalItems
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
`);
|
|
24
|
+
|
|
25
|
+
export interface Customer {
|
|
26
|
+
id: string;
|
|
27
|
+
firstName: string;
|
|
28
|
+
lastName: string;
|
|
29
|
+
emailAddress: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface CustomerSelectorProps {
|
|
33
|
+
onSelect: (value: Customer) => void;
|
|
34
|
+
label?: string | React.ReactNode;
|
|
35
|
+
readOnly?: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function CustomerSelector(props: CustomerSelectorProps) {
|
|
39
|
+
const [open, setOpen] = useState(false);
|
|
40
|
+
const [searchTerm, setSearchTerm] = useState('');
|
|
41
|
+
|
|
42
|
+
const { data, isLoading } = useQuery({
|
|
43
|
+
queryKey: ['customers', searchTerm],
|
|
44
|
+
queryFn: () =>
|
|
45
|
+
api.query(customersDocument, {
|
|
46
|
+
options: {
|
|
47
|
+
sort: { lastName: 'ASC' },
|
|
48
|
+
filter: searchTerm ? {
|
|
49
|
+
firstName: { contains: searchTerm },
|
|
50
|
+
lastName: { contains: searchTerm },
|
|
51
|
+
emailAddress: { contains: searchTerm },
|
|
52
|
+
} : undefined,
|
|
53
|
+
filterOperator: searchTerm ? 'OR' : undefined,
|
|
54
|
+
},
|
|
55
|
+
}),
|
|
56
|
+
staleTime: 1000 * 60, // 1 minute
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const handleSearch = (value: string) => {
|
|
60
|
+
setSearchTerm(value);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<Popover open={open} onOpenChange={setOpen}>
|
|
65
|
+
<PopoverTrigger asChild>
|
|
66
|
+
<Button variant="outline" size="sm" type="button" disabled={props.readOnly} className="gap-2">
|
|
67
|
+
<Plus className="h-4 w-4" />
|
|
68
|
+
{props.label ?? <Trans>Select customer</Trans>}
|
|
69
|
+
</Button>
|
|
70
|
+
</PopoverTrigger>
|
|
71
|
+
<PopoverContent className="p-0 w-[350px]" align="start">
|
|
72
|
+
<Command shouldFilter={false}>
|
|
73
|
+
<div className="flex items-center border-b px-3">
|
|
74
|
+
<Search className="mr-2 h-4 w-4 shrink-0 opacity-50" />
|
|
75
|
+
<CommandInput
|
|
76
|
+
placeholder="Search customers..."
|
|
77
|
+
onValueChange={handleSearch}
|
|
78
|
+
className="h-10 flex-1 bg-transparent outline-none placeholder:text-muted-foreground"
|
|
79
|
+
/>
|
|
80
|
+
</div>
|
|
81
|
+
<CommandList>
|
|
82
|
+
<CommandEmpty>
|
|
83
|
+
{isLoading ? (
|
|
84
|
+
<Trans>Loading...</Trans>
|
|
85
|
+
) : (
|
|
86
|
+
<Trans>No customers found</Trans>
|
|
87
|
+
)}
|
|
88
|
+
</CommandEmpty>
|
|
89
|
+
{data?.customers.items.map(customer => (
|
|
90
|
+
<CommandItem
|
|
91
|
+
key={customer.id}
|
|
92
|
+
onSelect={() => {
|
|
93
|
+
props.onSelect(customer);
|
|
94
|
+
setOpen(false);
|
|
95
|
+
}}
|
|
96
|
+
className="flex flex-col items-start"
|
|
97
|
+
>
|
|
98
|
+
<div className="font-medium">{customer.firstName} {customer.lastName}</div>
|
|
99
|
+
<div className="text-sm text-muted-foreground">{customer.emailAddress}</div>
|
|
100
|
+
</CommandItem>
|
|
101
|
+
))}
|
|
102
|
+
</CommandList>
|
|
103
|
+
</Command>
|
|
104
|
+
</PopoverContent>
|
|
105
|
+
</Popover>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Link } from '@tanstack/react-router';
|
|
2
|
+
import { Button } from '../ui/button.js';
|
|
3
|
+
import { SquareArrowOutUpRightIcon } from 'lucide-react';
|
|
4
|
+
|
|
5
|
+
export function DetailPageButton({
|
|
6
|
+
id,
|
|
7
|
+
label,
|
|
8
|
+
disabled,
|
|
9
|
+
}: {
|
|
10
|
+
id: string;
|
|
11
|
+
label: string | React.ReactNode;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
}) {
|
|
14
|
+
return (
|
|
15
|
+
<Button asChild variant="ghost" disabled={disabled}>
|
|
16
|
+
<Link to={`./${id}`}>
|
|
17
|
+
{label}
|
|
18
|
+
{!disabled && <SquareArrowOutUpRightIcon className="h-3 w-3 text-muted-foreground" />}
|
|
19
|
+
</Link>
|
|
20
|
+
</Button>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import { Button } from '@/components/ui/button.js';
|
|
2
|
+
import {
|
|
3
|
+
DropdownMenu,
|
|
4
|
+
DropdownMenuContent,
|
|
5
|
+
DropdownMenuItem,
|
|
6
|
+
DropdownMenuTrigger,
|
|
7
|
+
} from '@/components/ui/dropdown-menu.js';
|
|
8
|
+
import { AssetFragment } from '@/graphql/fragments.js';
|
|
9
|
+
import {
|
|
10
|
+
closestCenter,
|
|
11
|
+
DndContext,
|
|
12
|
+
DragEndEvent,
|
|
13
|
+
KeyboardSensor,
|
|
14
|
+
PointerSensor,
|
|
15
|
+
useSensor,
|
|
16
|
+
useSensors,
|
|
17
|
+
} from '@dnd-kit/core';
|
|
18
|
+
import {
|
|
19
|
+
arrayMove,
|
|
20
|
+
horizontalListSortingStrategy,
|
|
21
|
+
SortableContext,
|
|
22
|
+
sortableKeyboardCoordinates,
|
|
23
|
+
useSortable,
|
|
24
|
+
} from '@dnd-kit/sortable';
|
|
25
|
+
import { CSS } from '@dnd-kit/utilities';
|
|
26
|
+
import { EllipsisIcon, ImageIcon, PaperclipIcon } from 'lucide-react';
|
|
27
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
28
|
+
import { AssetPickerDialog } from './asset-picker-dialog.js';
|
|
29
|
+
import { AssetPreviewDialog } from './asset-preview-dialog.js';
|
|
30
|
+
import { VendureImage } from './vendure-image.js';
|
|
31
|
+
|
|
32
|
+
type Asset = AssetFragment;
|
|
33
|
+
|
|
34
|
+
export interface EntityAssetValue {
|
|
35
|
+
assetIds?: string[] | null;
|
|
36
|
+
featuredAssetId?: string | null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface EntityAssetsProps {
|
|
40
|
+
assets?: Asset[];
|
|
41
|
+
featuredAsset?: Asset | null;
|
|
42
|
+
compact?: boolean;
|
|
43
|
+
updatePermissions?: boolean;
|
|
44
|
+
multiSelect?: boolean;
|
|
45
|
+
value?: EntityAssetValue;
|
|
46
|
+
onBlur?: () => void;
|
|
47
|
+
onChange?: (change: EntityAssetValue) => void;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Sortable asset item component
|
|
51
|
+
function SortableAsset({
|
|
52
|
+
asset,
|
|
53
|
+
compact,
|
|
54
|
+
isFeatured,
|
|
55
|
+
updatePermissions,
|
|
56
|
+
onPreview,
|
|
57
|
+
onSetAsFeatured,
|
|
58
|
+
onRemove,
|
|
59
|
+
}: {
|
|
60
|
+
asset: Asset;
|
|
61
|
+
compact: boolean;
|
|
62
|
+
isFeatured: boolean;
|
|
63
|
+
updatePermissions: boolean;
|
|
64
|
+
onPreview: (asset: Asset) => void;
|
|
65
|
+
onSetAsFeatured: (asset: Asset) => void;
|
|
66
|
+
onRemove: (asset: Asset) => void;
|
|
67
|
+
}) {
|
|
68
|
+
const { attributes, listeners, setNodeRef, transform, transition, isDragging } = useSortable({
|
|
69
|
+
id: asset.id,
|
|
70
|
+
disabled: !updatePermissions,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const style = {
|
|
74
|
+
transform: CSS.Transform.toString(transform),
|
|
75
|
+
transition,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<div ref={setNodeRef} style={style} className="relative group" {...attributes}>
|
|
80
|
+
{/* Draggable Image Area */}
|
|
81
|
+
<div
|
|
82
|
+
{...listeners}
|
|
83
|
+
className={`
|
|
84
|
+
flex items-center justify-center
|
|
85
|
+
${compact ? 'w-12 h-12' : 'w-16 h-16'}
|
|
86
|
+
border rounded-md overflow-hidden cursor-grab
|
|
87
|
+
${isFeatured ? 'border-primary ring-1 ring-primary/30' : 'border-border'}
|
|
88
|
+
${updatePermissions ? 'hover:border-muted-foreground' : ''}
|
|
89
|
+
${isDragging ? 'opacity-50 cursor-grabbing' : ''}
|
|
90
|
+
`}
|
|
91
|
+
>
|
|
92
|
+
<VendureImage asset={asset} mode="crop" preset="tiny" />
|
|
93
|
+
</div>
|
|
94
|
+
|
|
95
|
+
{/* Menu Trigger */}
|
|
96
|
+
{updatePermissions && (
|
|
97
|
+
<div className="absolute -top-2 -right-2 opacity-0 group-hover:opacity-100 transition-opacity">
|
|
98
|
+
<DropdownMenu>
|
|
99
|
+
<DropdownMenuTrigger asChild>
|
|
100
|
+
<Button
|
|
101
|
+
variant="secondary"
|
|
102
|
+
size="icon"
|
|
103
|
+
className="h-6 w-6 rounded-full shadow-md"
|
|
104
|
+
>
|
|
105
|
+
<EllipsisIcon className="h-4 w-4" />
|
|
106
|
+
</Button>
|
|
107
|
+
</DropdownMenuTrigger>
|
|
108
|
+
<DropdownMenuContent align="end">
|
|
109
|
+
<DropdownMenuItem onClick={() => onPreview(asset)}>Preview</DropdownMenuItem>
|
|
110
|
+
<DropdownMenuItem disabled={isFeatured} onClick={() => onSetAsFeatured(asset)}>
|
|
111
|
+
Set as featured asset
|
|
112
|
+
</DropdownMenuItem>
|
|
113
|
+
<DropdownMenuItem className="text-destructive" onClick={() => onRemove(asset)}>
|
|
114
|
+
Remove asset
|
|
115
|
+
</DropdownMenuItem>
|
|
116
|
+
</DropdownMenuContent>
|
|
117
|
+
</DropdownMenu>
|
|
118
|
+
</div>
|
|
119
|
+
)}
|
|
120
|
+
</div>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function EntityAssets({
|
|
125
|
+
assets: initialAssets = [],
|
|
126
|
+
featuredAsset: initialFeaturedAsset,
|
|
127
|
+
compact = false,
|
|
128
|
+
updatePermissions = true,
|
|
129
|
+
multiSelect = true,
|
|
130
|
+
onChange,
|
|
131
|
+
}: EntityAssetsProps) {
|
|
132
|
+
const [assets, setAssets] = useState<Asset[]>([...initialAssets]);
|
|
133
|
+
const [featuredAsset, setFeaturedAsset] = useState<Asset | undefined | null>(initialFeaturedAsset);
|
|
134
|
+
const [isPickerOpen, setIsPickerOpen] = useState(false);
|
|
135
|
+
const [previewAsset, setPreviewAsset] = useState<Asset | null>(null);
|
|
136
|
+
|
|
137
|
+
// Setup sensors for drag and drop
|
|
138
|
+
const sensors = useSensors(
|
|
139
|
+
useSensor(PointerSensor),
|
|
140
|
+
useSensor(KeyboardSensor, {
|
|
141
|
+
coordinateGetter: sortableKeyboardCoordinates,
|
|
142
|
+
}),
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
// Update internal state when props change
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
if (initialAssets.length) {
|
|
148
|
+
setAssets([...initialAssets]);
|
|
149
|
+
}
|
|
150
|
+
}, [initialAssets]);
|
|
151
|
+
|
|
152
|
+
useEffect(() => {
|
|
153
|
+
setFeaturedAsset(initialFeaturedAsset);
|
|
154
|
+
}, [initialFeaturedAsset]);
|
|
155
|
+
|
|
156
|
+
const emitChange = useCallback(
|
|
157
|
+
(newAssets: Asset[], newFeaturedAsset: Asset | undefined | null) => {
|
|
158
|
+
onChange?.({
|
|
159
|
+
assetIds: newAssets.map(a => a.id),
|
|
160
|
+
featuredAssetId: newFeaturedAsset?.id ?? undefined,
|
|
161
|
+
});
|
|
162
|
+
},
|
|
163
|
+
[onChange],
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
const handleSelectAssets = useCallback(() => {
|
|
167
|
+
setIsPickerOpen(true);
|
|
168
|
+
}, []);
|
|
169
|
+
|
|
170
|
+
const handleAssetsPicked = useCallback(
|
|
171
|
+
(selectedAssets: Asset[]) => {
|
|
172
|
+
if (selectedAssets.length) {
|
|
173
|
+
// Remove duplicates
|
|
174
|
+
const uniqueAssets = multiSelect
|
|
175
|
+
? [...new Map([...assets, ...selectedAssets].map(item => [item.id, item])).values()]
|
|
176
|
+
: selectedAssets;
|
|
177
|
+
|
|
178
|
+
const newFeaturedAsset = !featuredAsset || !multiSelect ? selectedAssets[0] : featuredAsset;
|
|
179
|
+
|
|
180
|
+
setAssets(uniqueAssets);
|
|
181
|
+
setFeaturedAsset(newFeaturedAsset);
|
|
182
|
+
emitChange(uniqueAssets, newFeaturedAsset);
|
|
183
|
+
}
|
|
184
|
+
setIsPickerOpen(false);
|
|
185
|
+
},
|
|
186
|
+
[assets, featuredAsset, multiSelect, emitChange],
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
const handleSetAsFeatured = useCallback(
|
|
190
|
+
(asset: Asset) => {
|
|
191
|
+
setFeaturedAsset(asset);
|
|
192
|
+
emitChange(assets, asset);
|
|
193
|
+
},
|
|
194
|
+
[assets, emitChange],
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
const handleRemoveAsset = useCallback(
|
|
198
|
+
(asset: Asset) => {
|
|
199
|
+
const newAssets = assets.filter(a => a.id !== asset.id);
|
|
200
|
+
let newFeaturedAsset = featuredAsset;
|
|
201
|
+
|
|
202
|
+
if (featuredAsset && featuredAsset.id === asset.id) {
|
|
203
|
+
newFeaturedAsset = newAssets.length > 0 ? newAssets[0] : undefined;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
setAssets(newAssets);
|
|
207
|
+
setFeaturedAsset(newFeaturedAsset);
|
|
208
|
+
emitChange(newAssets, newFeaturedAsset);
|
|
209
|
+
},
|
|
210
|
+
[assets, featuredAsset, emitChange],
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
const handleDragEnd = useCallback(
|
|
214
|
+
(event: DragEndEvent) => {
|
|
215
|
+
const { active, over } = event;
|
|
216
|
+
|
|
217
|
+
if (over && active.id !== over.id) {
|
|
218
|
+
setAssets(items => {
|
|
219
|
+
const oldIndex = items.findIndex(item => item.id === active.id);
|
|
220
|
+
const newIndex = items.findIndex(item => item.id === over.id);
|
|
221
|
+
|
|
222
|
+
const newAssets = arrayMove(items, oldIndex, newIndex);
|
|
223
|
+
emitChange(newAssets, featuredAsset);
|
|
224
|
+
return newAssets;
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
[emitChange, featuredAsset],
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
const isFeatured = useCallback(
|
|
232
|
+
(asset: Asset) => {
|
|
233
|
+
return !!featuredAsset && featuredAsset.id === asset.id;
|
|
234
|
+
},
|
|
235
|
+
[featuredAsset],
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
const renderAssetList = () => (
|
|
239
|
+
<DndContext sensors={sensors} collisionDetection={closestCenter} onDragEnd={handleDragEnd}>
|
|
240
|
+
<div className={`${compact ? 'max-h-32' : ''} overflow-auto p-1`}>
|
|
241
|
+
<SortableContext
|
|
242
|
+
items={assets.map(asset => asset.id)}
|
|
243
|
+
strategy={horizontalListSortingStrategy}
|
|
244
|
+
>
|
|
245
|
+
<div className="flex flex-wrap gap-2">
|
|
246
|
+
{assets.map(asset => (
|
|
247
|
+
<SortableAsset
|
|
248
|
+
key={asset.id}
|
|
249
|
+
asset={asset}
|
|
250
|
+
compact={compact}
|
|
251
|
+
isFeatured={isFeatured(asset)}
|
|
252
|
+
updatePermissions={updatePermissions}
|
|
253
|
+
onPreview={setPreviewAsset}
|
|
254
|
+
onSetAsFeatured={handleSetAsFeatured}
|
|
255
|
+
onRemove={handleRemoveAsset}
|
|
256
|
+
/>
|
|
257
|
+
))}
|
|
258
|
+
</div>
|
|
259
|
+
</SortableContext>
|
|
260
|
+
</div>
|
|
261
|
+
</DndContext>
|
|
262
|
+
);
|
|
263
|
+
|
|
264
|
+
const FeaturedAsset = () => (
|
|
265
|
+
<div
|
|
266
|
+
className={`flex items-center justify-center ${compact ? 'h-40' : 'h-64'} border border-dashed rounded-md`}
|
|
267
|
+
>
|
|
268
|
+
{featuredAsset ? (
|
|
269
|
+
<VendureImage
|
|
270
|
+
asset={featuredAsset}
|
|
271
|
+
mode="crop"
|
|
272
|
+
preset="small"
|
|
273
|
+
onClick={() => setPreviewAsset(featuredAsset)}
|
|
274
|
+
className="max-w-full max-h-full object-contain cursor-pointer"
|
|
275
|
+
/>
|
|
276
|
+
) : (
|
|
277
|
+
<div
|
|
278
|
+
className="flex flex-col items-center justify-center text-muted-foreground cursor-pointer"
|
|
279
|
+
onClick={handleSelectAssets}
|
|
280
|
+
>
|
|
281
|
+
<ImageIcon className={compact ? 'h-10 w-10' : 'h-16 w-16'} />
|
|
282
|
+
{!compact && <div className="mt-2">No featured asset</div>}
|
|
283
|
+
</div>
|
|
284
|
+
)}
|
|
285
|
+
</div>
|
|
286
|
+
);
|
|
287
|
+
|
|
288
|
+
// AddAssetButton component
|
|
289
|
+
const AddAssetButton = () =>
|
|
290
|
+
updatePermissions && (
|
|
291
|
+
<Button
|
|
292
|
+
variant="outline"
|
|
293
|
+
size={compact ? 'sm' : 'default'}
|
|
294
|
+
className={compact ? 'w-full' : ''}
|
|
295
|
+
onClick={handleSelectAssets}
|
|
296
|
+
>
|
|
297
|
+
<PaperclipIcon className="mr-2 h-4 w-4" />
|
|
298
|
+
Add asset
|
|
299
|
+
</Button>
|
|
300
|
+
);
|
|
301
|
+
|
|
302
|
+
return (
|
|
303
|
+
<>
|
|
304
|
+
{compact ? (
|
|
305
|
+
<div className="flex flex-col gap-3">
|
|
306
|
+
<FeaturedAsset />
|
|
307
|
+
{renderAssetList()}
|
|
308
|
+
<AddAssetButton />
|
|
309
|
+
</div>
|
|
310
|
+
) : (
|
|
311
|
+
<div className="grid grid-cols-1 md:grid-cols-[256px_1fr] gap-4">
|
|
312
|
+
<FeaturedAsset />
|
|
313
|
+
<div className="flex flex-col gap-4">
|
|
314
|
+
{renderAssetList()}
|
|
315
|
+
<AddAssetButton />
|
|
316
|
+
</div>
|
|
317
|
+
</div>
|
|
318
|
+
)}
|
|
319
|
+
|
|
320
|
+
{/* Dialogs - moved outside conditional rendering */}
|
|
321
|
+
{isPickerOpen && (
|
|
322
|
+
<AssetPickerDialog
|
|
323
|
+
multiSelect={multiSelect}
|
|
324
|
+
onSelect={handleAssetsPicked}
|
|
325
|
+
onClose={() => setIsPickerOpen(false)}
|
|
326
|
+
open={isPickerOpen}
|
|
327
|
+
/>
|
|
328
|
+
)}
|
|
329
|
+
|
|
330
|
+
{previewAsset && (
|
|
331
|
+
<AssetPreviewDialog
|
|
332
|
+
asset={previewAsset}
|
|
333
|
+
assets={assets}
|
|
334
|
+
onOpenChange={() => setPreviewAsset(null)}
|
|
335
|
+
open={!!previewAsset}
|
|
336
|
+
/>
|
|
337
|
+
)}
|
|
338
|
+
</>
|
|
339
|
+
);
|
|
340
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Page, PageBlock, PageLayout, PageTitle } from '@/framework/layout-engine/page-layout.js';
|
|
2
|
+
import { Trans } from '@/lib/trans.js';
|
|
3
|
+
import { AlertCircle } from 'lucide-react';
|
|
4
|
+
import { Alert, AlertTitle, AlertDescription } from '../ui/alert.js';
|
|
5
|
+
|
|
6
|
+
export interface ErrorPageProps {
|
|
7
|
+
message: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @description
|
|
12
|
+
* A generic error page that displays an error message.
|
|
13
|
+
*/
|
|
14
|
+
export function ErrorPage({ message }: ErrorPageProps) {
|
|
15
|
+
return (
|
|
16
|
+
<Page>
|
|
17
|
+
<PageTitle>
|
|
18
|
+
<Trans>Error</Trans>
|
|
19
|
+
</PageTitle>
|
|
20
|
+
<PageLayout>
|
|
21
|
+
<PageBlock column="main">
|
|
22
|
+
<Alert variant="destructive">
|
|
23
|
+
<AlertCircle className="h-4 w-4" />
|
|
24
|
+
<AlertTitle>Error</AlertTitle>
|
|
25
|
+
<AlertDescription>{message}</AlertDescription>
|
|
26
|
+
</Alert>
|
|
27
|
+
</PageBlock>
|
|
28
|
+
</PageLayout>
|
|
29
|
+
</Page>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Badge } from '@/components/ui/badge.js';
|
|
2
|
+
import { X } from 'lucide-react';
|
|
3
|
+
|
|
4
|
+
// Interface for facet value type
|
|
5
|
+
interface FacetValue {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
code: string;
|
|
9
|
+
facet: {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
code: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface FacetValueChipProps {
|
|
17
|
+
facetValue: FacetValue;
|
|
18
|
+
removable?: boolean;
|
|
19
|
+
displayFacetName?: boolean;
|
|
20
|
+
onRemove?: (id: string) => void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function FacetValueChip({ facetValue, removable = true, onRemove, displayFacetName = true }: FacetValueChipProps) {
|
|
24
|
+
return (
|
|
25
|
+
<Badge
|
|
26
|
+
variant="secondary"
|
|
27
|
+
className="flex items-center gap-2 py-0.5 pl-2 pr-1 h-6 hover:bg-secondary/80"
|
|
28
|
+
>
|
|
29
|
+
<div className="flex items-center gap-1.5">
|
|
30
|
+
<span className="font-medium">{facetValue.name}</span>
|
|
31
|
+
{displayFacetName && <span className="text-muted-foreground text-xs">in {facetValue.facet.name}</span>}
|
|
32
|
+
</div>
|
|
33
|
+
{removable && (
|
|
34
|
+
<button
|
|
35
|
+
type="button"
|
|
36
|
+
className="ml-0.5 inline-flex h-4 w-4 items-center justify-center rounded-full hover:bg-muted/30"
|
|
37
|
+
onClick={() => onRemove?.(facetValue.id)}
|
|
38
|
+
aria-label={`Remove ${facetValue.name} from ${facetValue.facet.name}`}
|
|
39
|
+
>
|
|
40
|
+
<X className="h-3 w-3" />
|
|
41
|
+
</button>
|
|
42
|
+
)}
|
|
43
|
+
</Badge>
|
|
44
|
+
);
|
|
45
|
+
}
|