@vendure-platform/create 0.1.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 +70 -0
- package/dist/assets/demo-data/branding/logo.svg +4 -0
- package/dist/assets/demo-data/images/absorbent-pad.webp +0 -0
- package/dist/assets/demo-data/images/adjustable-wrench.webp +0 -0
- package/dist/assets/demo-data/images/anchor-bolt.webp +0 -0
- package/dist/assets/demo-data/images/angle-grinder.webp +0 -0
- package/dist/assets/demo-data/images/barrier-tape.webp +0 -0
- package/dist/assets/demo-data/images/bench-grinder.webp +0 -0
- package/dist/assets/demo-data/images/bracket.webp +0 -0
- package/dist/assets/demo-data/images/broom.webp +0 -0
- package/dist/assets/demo-data/images/bucket.webp +0 -0
- package/dist/assets/demo-data/images/cable-gland.webp +0 -0
- package/dist/assets/demo-data/images/cable-tie.webp +0 -0
- package/dist/assets/demo-data/images/cable-tray.webp +0 -0
- package/dist/assets/demo-data/images/cable.webp +0 -0
- package/dist/assets/demo-data/images/chimney-base-kit.webp +0 -0
- package/dist/assets/demo-data/images/chimney-cowl-bird-guard.webp +0 -0
- package/dist/assets/demo-data/images/chimney-cowl-open.webp +0 -0
- package/dist/assets/demo-data/images/chimney-storm-collar.webp +0 -0
- package/dist/assets/demo-data/images/chimney-wall-bracket.webp +0 -0
- package/dist/assets/demo-data/images/circular-saw.webp +0 -0
- package/dist/assets/demo-data/images/cleaning-spray.webp +0 -0
- package/dist/assets/demo-data/images/conduit.webp +0 -0
- package/dist/assets/demo-data/images/cordless-drill.webp +0 -0
- package/dist/assets/demo-data/images/drill-bits.webp +0 -0
- package/dist/assets/demo-data/images/dust-mask.webp +0 -0
- package/dist/assets/demo-data/images/ear-defenders.webp +0 -0
- package/dist/assets/demo-data/images/ear-plugs.webp +0 -0
- package/dist/assets/demo-data/images/extension-lead.webp +0 -0
- package/dist/assets/demo-data/images/eye-wash-station.webp +0 -0
- package/dist/assets/demo-data/images/face-shield.webp +0 -0
- package/dist/assets/demo-data/images/file-set.webp +0 -0
- package/dist/assets/demo-data/images/first-aid-kit.webp +0 -0
- package/dist/assets/demo-data/images/floor-sign.webp +0 -0
- package/dist/assets/demo-data/images/flue-bend-45.webp +0 -0
- package/dist/assets/demo-data/images/flue-bend-90.webp +0 -0
- package/dist/assets/demo-data/images/flue-section-1000mm.webp +0 -0
- package/dist/assets/demo-data/images/flue-section-250mm.webp +0 -0
- package/dist/assets/demo-data/images/flue-section-500mm.webp +0 -0
- package/dist/assets/demo-data/images/fuse.webp +0 -0
- package/dist/assets/demo-data/images/glove-dispenser.webp +0 -0
- package/dist/assets/demo-data/images/grinding-disc.webp +0 -0
- package/dist/assets/demo-data/images/hacksaw.webp +0 -0
- package/dist/assets/demo-data/images/hammer.webp +0 -0
- package/dist/assets/demo-data/images/hand-sanitiser.webp +0 -0
- package/dist/assets/demo-data/images/head-torch.webp +0 -0
- package/dist/assets/demo-data/images/heat-gun.webp +0 -0
- package/dist/assets/demo-data/images/hex-bolt.webp +0 -0
- package/dist/assets/demo-data/images/hex-key-set.webp +0 -0
- package/dist/assets/demo-data/images/hex-nut.webp +0 -0
- package/dist/assets/demo-data/images/hi-vis-jacket.webp +0 -0
- package/dist/assets/demo-data/images/hi-vis-vest.webp +0 -0
- package/dist/assets/demo-data/images/hose-clamp.webp +0 -0
- package/dist/assets/demo-data/images/impact-driver.webp +0 -0
- package/dist/assets/demo-data/images/jigsaw.webp +0 -0
- package/dist/assets/demo-data/images/junction-box.webp +0 -0
- package/dist/assets/demo-data/images/knee-pads.webp +0 -0
- package/dist/assets/demo-data/images/machine-screw.webp +0 -0
- package/dist/assets/demo-data/images/made-to-order-configurable-chimney.webp +0 -0
- package/dist/assets/demo-data/images/mallet.webp +0 -0
- package/dist/assets/demo-data/images/mcb.webp +0 -0
- package/dist/assets/demo-data/images/mop.webp +0 -0
- package/dist/assets/demo-data/images/paper-towels.webp +0 -0
- package/dist/assets/demo-data/images/pipe-wrench.webp +0 -0
- package/dist/assets/demo-data/images/pliers-set.webp +0 -0
- package/dist/assets/demo-data/images/pry-bar.webp +0 -0
- package/dist/assets/demo-data/images/rcd.webp +0 -0
- package/dist/assets/demo-data/images/reciprocating-saw.webp +0 -0
- package/dist/assets/demo-data/images/rivet.webp +0 -0
- package/dist/assets/demo-data/images/roof-flashing-high-pitch.webp +0 -0
- package/dist/assets/demo-data/images/roof-flashing-low-pitch.webp +0 -0
- package/dist/assets/demo-data/images/safety-boots.webp +0 -0
- package/dist/assets/demo-data/images/safety-glasses.webp +0 -0
- package/dist/assets/demo-data/images/safety-harness.webp +0 -0
- package/dist/assets/demo-data/images/safety-helmet.webp +0 -0
- package/dist/assets/demo-data/images/safety-sign.webp +0 -0
- package/dist/assets/demo-data/images/sanding-disc.webp +0 -0
- package/dist/assets/demo-data/images/saw-blade.webp +0 -0
- package/dist/assets/demo-data/images/screwdriver-set.webp +0 -0
- package/dist/assets/demo-data/images/screwdriver.webp +0 -0
- package/dist/assets/demo-data/images/self-tapping-screw.webp +0 -0
- package/dist/assets/demo-data/images/socket-set.webp +0 -0
- package/dist/assets/demo-data/images/socket.webp +0 -0
- package/dist/assets/demo-data/images/spanner-set.webp +0 -0
- package/dist/assets/demo-data/images/spanner.webp +0 -0
- package/dist/assets/demo-data/images/spill-kit.webp +0 -0
- package/dist/assets/demo-data/images/spirit-level.webp +0 -0
- package/dist/assets/demo-data/images/switch.webp +0 -0
- package/dist/assets/demo-data/images/tape-measure.webp +0 -0
- package/dist/assets/demo-data/images/terminal-block.webp +0 -0
- package/dist/assets/demo-data/images/threaded-rod.webp +0 -0
- package/dist/assets/demo-data/images/torque-wrench.webp +0 -0
- package/dist/assets/demo-data/images/utility-knife.webp +0 -0
- package/dist/assets/demo-data/images/wall-pass-sleeve.webp +0 -0
- package/dist/assets/demo-data/images/wall-plug.webp +0 -0
- package/dist/assets/demo-data/images/washer.webp +0 -0
- package/dist/assets/demo-data/images/waste-bin.webp +0 -0
- package/dist/assets/demo-data/images/wire-connector.webp +0 -0
- package/dist/assets/demo-data/images/wire-cutters.webp +0 -0
- package/dist/assets/demo-data/images/wood-screw.webp +0 -0
- package/dist/assets/demo-data/images/work-gloves.webp +0 -0
- package/dist/assets/demo-data/images/work-light.webp +0 -0
- package/dist/assets/demo-data/initial-data.json +667 -0
- package/dist/assets/demo-data/products.csv +779 -0
- package/dist/assets/storefront/.env.example +14 -0
- package/dist/assets/storefront/.env.local +1 -0
- package/dist/assets/storefront/components.json +22 -0
- package/dist/assets/storefront/eslint.config.mjs +23 -0
- package/dist/assets/storefront/graphql.config.yml +2 -0
- package/dist/assets/storefront/messages/de.json +1196 -0
- package/dist/assets/storefront/messages/en.json +1196 -0
- package/dist/assets/storefront/next-env.d.ts +6 -0
- package/dist/assets/storefront/next.config.ts +73 -0
- package/dist/assets/storefront/package.json +77 -0
- package/dist/assets/storefront/postcss.config.mjs +5 -0
- package/dist/assets/storefront/public/next.svg +22 -0
- package/dist/assets/storefront/public/scenarios/b2b-wholesale/hero/hero-bg.webp +0 -0
- package/dist/assets/storefront/public/scenarios/b2b-wholesale/logo.svg +4 -0
- package/dist/assets/storefront/public/scenarios/default/logo.svg +4 -0
- package/dist/assets/storefront/public/scenarios/kaminpro/hero/hero-bg.webp +0 -0
- package/dist/assets/storefront/public/scenarios/kaminpro/logo.svg +7 -0
- package/dist/assets/storefront/public/vendure.svg +4 -0
- package/dist/assets/storefront/src/app/[locale]/(catalog)/catalog/page.tsx +65 -0
- package/dist/assets/storefront/src/app/[locale]/(catalog)/collection/[slug]/loading.tsx +24 -0
- package/dist/assets/storefront/src/app/[locale]/(catalog)/collection/[slug]/page.tsx +194 -0
- package/dist/assets/storefront/src/app/[locale]/(catalog)/layout.tsx +9 -0
- package/dist/assets/storefront/src/app/[locale]/(catalog)/product/[slug]/actions.ts +139 -0
- package/dist/assets/storefront/src/app/[locale]/(catalog)/product/[slug]/loading.tsx +46 -0
- package/dist/assets/storefront/src/app/[locale]/(catalog)/product/[slug]/page.tsx +330 -0
- package/dist/assets/storefront/src/app/[locale]/(catalog)/search/actions.ts +11 -0
- package/dist/assets/storefront/src/app/[locale]/(catalog)/search/loading.tsx +20 -0
- package/dist/assets/storefront/src/app/[locale]/(catalog)/search/page.tsx +97 -0
- package/dist/assets/storefront/src/app/[locale]/(catalog)/search/search-analytics-tracker.tsx +46 -0
- package/dist/assets/storefront/src/app/[locale]/(catalog)/search/search-results.tsx +53 -0
- package/dist/assets/storefront/src/app/[locale]/(catalog)/search/search-term.tsx +26 -0
- package/dist/assets/storefront/src/app/[locale]/(scenario)/[...path]/page.tsx +31 -0
- package/dist/assets/storefront/src/app/[locale]/accept-invitation/[token]/accept-invitation-client.tsx +56 -0
- package/dist/assets/storefront/src/app/[locale]/accept-invitation/[token]/actions.ts +32 -0
- package/dist/assets/storefront/src/app/[locale]/accept-invitation/[token]/page.tsx +85 -0
- package/dist/assets/storefront/src/app/[locale]/accept-invitation/[token]/sign-out-and-retry.tsx +26 -0
- package/dist/assets/storefront/src/app/[locale]/account/addresses/actions.ts +125 -0
- package/dist/assets/storefront/src/app/[locale]/account/addresses/address-form.tsx +180 -0
- package/dist/assets/storefront/src/app/[locale]/account/addresses/addresses-client.tsx +292 -0
- package/dist/assets/storefront/src/app/[locale]/account/addresses/loading.tsx +48 -0
- package/dist/assets/storefront/src/app/[locale]/account/addresses/page.tsx +54 -0
- package/dist/assets/storefront/src/app/[locale]/account/approvals/actions.ts +28 -0
- package/dist/assets/storefront/src/app/[locale]/account/approvals/page.tsx +340 -0
- package/dist/assets/storefront/src/app/[locale]/account/company/actions.ts +33 -0
- package/dist/assets/storefront/src/app/[locale]/account/company/addresses/actions.ts +83 -0
- package/dist/assets/storefront/src/app/[locale]/account/company/addresses/address-form.tsx +267 -0
- package/dist/assets/storefront/src/app/[locale]/account/company/addresses/addresses-client.tsx +253 -0
- package/dist/assets/storefront/src/app/[locale]/account/company/addresses/page.tsx +75 -0
- package/dist/assets/storefront/src/app/[locale]/account/company/business-units/actions.ts +70 -0
- package/dist/assets/storefront/src/app/[locale]/account/company/business-units/business-unit-form.tsx +153 -0
- package/dist/assets/storefront/src/app/[locale]/account/company/business-units/business-units-client.tsx +210 -0
- package/dist/assets/storefront/src/app/[locale]/account/company/business-units/page.tsx +66 -0
- package/dist/assets/storefront/src/app/[locale]/account/company/business-units/types.ts +8 -0
- package/dist/assets/storefront/src/app/[locale]/account/company/edit-company-form.tsx +57 -0
- package/dist/assets/storefront/src/app/[locale]/account/company/page.tsx +89 -0
- package/dist/assets/storefront/src/app/[locale]/account/company/payment-methods/page.tsx +65 -0
- package/dist/assets/storefront/src/app/[locale]/account/company/payment-methods/payment-methods-client.tsx +55 -0
- package/dist/assets/storefront/src/app/[locale]/account/company/roles/page.tsx +66 -0
- package/dist/assets/storefront/src/app/[locale]/account/company/roles/roles-client.tsx +93 -0
- package/dist/assets/storefront/src/app/[locale]/account/company/tax-ids/actions.ts +51 -0
- package/dist/assets/storefront/src/app/[locale]/account/company/tax-ids/page.tsx +57 -0
- package/dist/assets/storefront/src/app/[locale]/account/company/tax-ids/tax-ids-client.tsx +326 -0
- package/dist/assets/storefront/src/app/[locale]/account/company/users/actions.ts +74 -0
- package/dist/assets/storefront/src/app/[locale]/account/company/users/edit-user-form.tsx +157 -0
- package/dist/assets/storefront/src/app/[locale]/account/company/users/invite-user-form.tsx +133 -0
- package/dist/assets/storefront/src/app/[locale]/account/company/users/page.tsx +104 -0
- package/dist/assets/storefront/src/app/[locale]/account/company/users/users-client.tsx +266 -0
- package/dist/assets/storefront/src/app/[locale]/account/error.tsx +24 -0
- package/dist/assets/storefront/src/app/[locale]/account/layout.tsx +50 -0
- package/dist/assets/storefront/src/app/[locale]/account/orders/[code]/page.tsx +463 -0
- package/dist/assets/storefront/src/app/[locale]/account/orders/[code]/reorder-actions.ts +160 -0
- package/dist/assets/storefront/src/app/[locale]/account/orders/[code]/reorder-dialog.tsx +386 -0
- package/dist/assets/storefront/src/app/[locale]/account/orders/loading.tsx +45 -0
- package/dist/assets/storefront/src/app/[locale]/account/orders/page.tsx +309 -0
- package/dist/assets/storefront/src/app/[locale]/account/profile/actions.ts +106 -0
- package/dist/assets/storefront/src/app/[locale]/account/profile/change-password-form.tsx +82 -0
- package/dist/assets/storefront/src/app/[locale]/account/profile/edit-email-form.tsx +88 -0
- package/dist/assets/storefront/src/app/[locale]/account/profile/edit-profile-form.tsx +80 -0
- package/dist/assets/storefront/src/app/[locale]/account/profile/loading.tsx +54 -0
- package/dist/assets/storefront/src/app/[locale]/account/profile/page.tsx +44 -0
- package/dist/assets/storefront/src/app/[locale]/account/quick-order/actions.ts +103 -0
- package/dist/assets/storefront/src/app/[locale]/account/quick-order/file-upload-tab.tsx +148 -0
- package/dist/assets/storefront/src/app/[locale]/account/quick-order/manual-entry-tab.tsx +112 -0
- package/dist/assets/storefront/src/app/[locale]/account/quick-order/page.tsx +26 -0
- package/dist/assets/storefront/src/app/[locale]/account/quick-order/preview-table.tsx +170 -0
- package/dist/assets/storefront/src/app/[locale]/account/quick-order/quick-order-form.tsx +243 -0
- package/dist/assets/storefront/src/app/[locale]/account/quick-order/save-to-list-dialog.tsx +153 -0
- package/dist/assets/storefront/src/app/[locale]/account/quick-order/sku-autocomplete.tsx +118 -0
- package/dist/assets/storefront/src/app/[locale]/account/quick-order/text-input-tab.tsx +40 -0
- package/dist/assets/storefront/src/app/[locale]/account/quotes/[id]/page.tsx +260 -0
- package/dist/assets/storefront/src/app/[locale]/account/quotes/actions.ts +253 -0
- package/dist/assets/storefront/src/app/[locale]/account/quotes/new/new-quote-form.tsx +28 -0
- package/dist/assets/storefront/src/app/[locale]/account/quotes/new/page.tsx +51 -0
- package/dist/assets/storefront/src/app/[locale]/account/quotes/page.tsx +248 -0
- package/dist/assets/storefront/src/app/[locale]/account/shopping-lists/[id]/loading.tsx +44 -0
- package/dist/assets/storefront/src/app/[locale]/account/shopping-lists/[id]/page.tsx +51 -0
- package/dist/assets/storefront/src/app/[locale]/account/shopping-lists/[id]/shopping-list-detail-client.tsx +562 -0
- package/dist/assets/storefront/src/app/[locale]/account/shopping-lists/actions.ts +235 -0
- package/dist/assets/storefront/src/app/[locale]/account/shopping-lists/create-shopping-list-form.tsx +86 -0
- package/dist/assets/storefront/src/app/[locale]/account/shopping-lists/loading.tsx +48 -0
- package/dist/assets/storefront/src/app/[locale]/account/shopping-lists/page.tsx +176 -0
- package/dist/assets/storefront/src/app/[locale]/account/store-credits/actions.ts +31 -0
- package/dist/assets/storefront/src/app/[locale]/account/store-credits/claim-form.tsx +41 -0
- package/dist/assets/storefront/src/app/[locale]/account/store-credits/page.tsx +190 -0
- package/dist/assets/storefront/src/app/[locale]/account/store-credits/reveal-code.tsx +38 -0
- package/dist/assets/storefront/src/app/[locale]/account/verify-email/page.tsx +117 -0
- package/dist/assets/storefront/src/app/[locale]/cart/actions.ts +128 -0
- package/dist/assets/storefront/src/app/[locale]/cart/cart-items.tsx +228 -0
- package/dist/assets/storefront/src/app/[locale]/cart/cart-line-actions.tsx +55 -0
- package/dist/assets/storefront/src/app/[locale]/cart/cart-quantity-control.tsx +158 -0
- package/dist/assets/storefront/src/app/[locale]/cart/cart-remove-button.tsx +36 -0
- package/dist/assets/storefront/src/app/[locale]/cart/cart.tsx +151 -0
- package/dist/assets/storefront/src/app/[locale]/cart/code-input.tsx +49 -0
- package/dist/assets/storefront/src/app/[locale]/cart/loading.tsx +10 -0
- package/dist/assets/storefront/src/app/[locale]/cart/order-summary.tsx +178 -0
- package/dist/assets/storefront/src/app/[locale]/cart/page.tsx +33 -0
- package/dist/assets/storefront/src/app/[locale]/cart/promotion-code.tsx +142 -0
- package/dist/assets/storefront/src/app/[locale]/cart/reapproval-confirm.tsx +76 -0
- package/dist/assets/storefront/src/app/[locale]/cart/request-quote-button.tsx +80 -0
- package/dist/assets/storefront/src/app/[locale]/checkout/actions.ts +192 -0
- package/dist/assets/storefront/src/app/[locale]/checkout/cancel-quote-checkout-button.tsx +30 -0
- package/dist/assets/storefront/src/app/[locale]/checkout/checkout-flow.tsx +214 -0
- package/dist/assets/storefront/src/app/[locale]/checkout/checkout-provider.tsx +181 -0
- package/dist/assets/storefront/src/app/[locale]/checkout/loading.tsx +90 -0
- package/dist/assets/storefront/src/app/[locale]/checkout/order-summary.tsx +160 -0
- package/dist/assets/storefront/src/app/[locale]/checkout/page.tsx +154 -0
- package/dist/assets/storefront/src/app/[locale]/checkout/steps/delivery-step.tsx +107 -0
- package/dist/assets/storefront/src/app/[locale]/checkout/steps/payment-step.tsx +110 -0
- package/dist/assets/storefront/src/app/[locale]/checkout/steps/review-step.tsx +180 -0
- package/dist/assets/storefront/src/app/[locale]/checkout/steps/shipping-address-step.tsx +518 -0
- package/dist/assets/storefront/src/app/[locale]/checkout/types.ts +7 -0
- package/dist/assets/storefront/src/app/[locale]/error.tsx +28 -0
- package/dist/assets/storefront/src/app/[locale]/forgot-password/actions.ts +28 -0
- package/dist/assets/storefront/src/app/[locale]/forgot-password/forgot-password-form.tsx +128 -0
- package/dist/assets/storefront/src/app/[locale]/forgot-password/page.tsx +24 -0
- package/dist/assets/storefront/src/app/[locale]/globals.css +72 -0
- package/dist/assets/storefront/src/app/[locale]/layout.tsx +202 -0
- package/dist/assets/storefront/src/app/[locale]/not-found.tsx +26 -0
- package/dist/assets/storefront/src/app/[locale]/order-confirmation/[code]/order-confirmation.tsx +296 -0
- package/dist/assets/storefront/src/app/[locale]/order-confirmation/[code]/page.tsx +18 -0
- package/dist/assets/storefront/src/app/[locale]/page.tsx +125 -0
- package/dist/assets/storefront/src/app/[locale]/register/actions.ts +50 -0
- package/dist/assets/storefront/src/app/[locale]/register/page.tsx +82 -0
- package/dist/assets/storefront/src/app/[locale]/register/registration-form.tsx +237 -0
- package/dist/assets/storefront/src/app/[locale]/register-company/actions.ts +40 -0
- package/dist/assets/storefront/src/app/[locale]/register-company/page.tsx +43 -0
- package/dist/assets/storefront/src/app/[locale]/register-company/registration-form.tsx +48 -0
- package/dist/assets/storefront/src/app/[locale]/reset-password/actions.ts +40 -0
- package/dist/assets/storefront/src/app/[locale]/reset-password/page.tsx +32 -0
- package/dist/assets/storefront/src/app/[locale]/reset-password/reset-password-form.tsx +96 -0
- package/dist/assets/storefront/src/app/[locale]/shopping-list/[code]/add-to-cart-button.tsx +31 -0
- package/dist/assets/storefront/src/app/[locale]/shopping-list/[code]/loading.tsx +29 -0
- package/dist/assets/storefront/src/app/[locale]/shopping-list/[code]/page.tsx +157 -0
- package/dist/assets/storefront/src/app/[locale]/sign-in/actions.ts +76 -0
- package/dist/assets/storefront/src/app/[locale]/sign-in/login-form.tsx +177 -0
- package/dist/assets/storefront/src/app/[locale]/sign-in/page.tsx +81 -0
- package/dist/assets/storefront/src/app/[locale]/verify/actions.ts +41 -0
- package/dist/assets/storefront/src/app/[locale]/verify/page.tsx +40 -0
- package/dist/assets/storefront/src/app/[locale]/verify/verify-content.tsx +127 -0
- package/dist/assets/storefront/src/app/[locale]/verify-pending/page.tsx +67 -0
- package/dist/assets/storefront/src/app/api/clear-company-context/route.ts +26 -0
- package/dist/assets/storefront/src/app/api/draft/disable/route.ts +12 -0
- package/dist/assets/storefront/src/app/api/draft/route.ts +17 -0
- package/dist/assets/storefront/src/app/api/revalidate/route.ts +110 -0
- package/dist/assets/storefront/src/app/api/search-analytics/route.ts +16 -0
- package/dist/assets/storefront/src/app/favicon.ico +0 -0
- package/dist/assets/storefront/src/components/commerce/account-nav-items.ts +56 -0
- package/dist/assets/storefront/src/components/commerce/account-sidebar.tsx +112 -0
- package/dist/assets/storefront/src/components/commerce/active-filters.tsx +107 -0
- package/dist/assets/storefront/src/components/commerce/approval-decision-form.tsx +70 -0
- package/dist/assets/storefront/src/components/commerce/approval-status-badge.tsx +37 -0
- package/dist/assets/storefront/src/components/commerce/business-unit-switcher.tsx +56 -0
- package/dist/assets/storefront/src/components/commerce/catalog-search-bar.tsx +83 -0
- package/dist/assets/storefront/src/components/commerce/category-product-section.tsx +69 -0
- package/dist/assets/storefront/src/components/commerce/category-sidebar.tsx +133 -0
- package/dist/assets/storefront/src/components/commerce/collection-hero-banner.tsx +36 -0
- package/dist/assets/storefront/src/components/commerce/company-state-badge.tsx +32 -0
- package/dist/assets/storefront/src/components/commerce/company-switcher.tsx +58 -0
- package/dist/assets/storefront/src/components/commerce/configurator-form.tsx +606 -0
- package/dist/assets/storefront/src/components/commerce/facet-filters.tsx +286 -0
- package/dist/assets/storefront/src/components/commerce/gift-card-pdp.tsx +43 -0
- package/dist/assets/storefront/src/components/commerce/gift-card-product-info.tsx +137 -0
- package/dist/assets/storefront/src/components/commerce/highlighted-text.tsx +30 -0
- package/dist/assets/storefront/src/components/commerce/instant-search-dropdown.tsx +377 -0
- package/dist/assets/storefront/src/components/commerce/order-status-badge.tsx +41 -0
- package/dist/assets/storefront/src/components/commerce/packaging-unit-selector.tsx +146 -0
- package/dist/assets/storefront/src/components/commerce/permission-gate.tsx +20 -0
- package/dist/assets/storefront/src/components/commerce/price-range-filter.tsx +111 -0
- package/dist/assets/storefront/src/components/commerce/price-tiers.tsx +98 -0
- package/dist/assets/storefront/src/components/commerce/price.tsx +29 -0
- package/dist/assets/storefront/src/components/commerce/product-card-list.tsx +121 -0
- package/dist/assets/storefront/src/components/commerce/product-card.tsx +89 -0
- package/dist/assets/storefront/src/components/commerce/product-carousel.tsx +42 -0
- package/dist/assets/storefront/src/components/commerce/product-grid.tsx +54 -0
- package/dist/assets/storefront/src/components/commerce/product-image-carousel.tsx +127 -0
- package/dist/assets/storefront/src/components/commerce/product-info.tsx +525 -0
- package/dist/assets/storefront/src/components/commerce/product-list-expansion.tsx +393 -0
- package/dist/assets/storefront/src/components/commerce/product-list-view.tsx +34 -0
- package/dist/assets/storefront/src/components/commerce/product-sidebar.tsx +175 -0
- package/dist/assets/storefront/src/components/commerce/product-view-switcher.tsx +107 -0
- package/dist/assets/storefront/src/components/commerce/quote-action-buttons.tsx +235 -0
- package/dist/assets/storefront/src/components/commerce/quote-activity-timeline.tsx +320 -0
- package/dist/assets/storefront/src/components/commerce/quote-comment-form.tsx +52 -0
- package/dist/assets/storefront/src/components/commerce/quote-csv-export-button.tsx +97 -0
- package/dist/assets/storefront/src/components/commerce/quote-product-search.tsx +139 -0
- package/dist/assets/storefront/src/components/commerce/quote-request-form.tsx +252 -0
- package/dist/assets/storefront/src/components/commerce/quote-status-badge.tsx +41 -0
- package/dist/assets/storefront/src/components/commerce/quote-validity-indicator.tsx +33 -0
- package/dist/assets/storefront/src/components/commerce/quote-version-comparison.tsx +88 -0
- package/dist/assets/storefront/src/components/commerce/related-products.tsx +56 -0
- package/dist/assets/storefront/src/components/commerce/shop-by-category.tsx +59 -0
- package/dist/assets/storefront/src/components/commerce/shopping-list-toggle.tsx +158 -0
- package/dist/assets/storefront/src/components/commerce/sort-dropdown.tsx +51 -0
- package/dist/assets/storefront/src/components/commerce/store-credit-summary.tsx +45 -0
- package/dist/assets/storefront/src/components/commerce/subcollection-tiles.tsx +56 -0
- package/dist/assets/storefront/src/components/layout/auth-page-shell.tsx +15 -0
- package/dist/assets/storefront/src/components/layout/draft-mode-action.ts +8 -0
- package/dist/assets/storefront/src/components/layout/draft-mode-indicator.tsx +54 -0
- package/dist/assets/storefront/src/components/layout/draft-mode-link.tsx +29 -0
- package/dist/assets/storefront/src/components/layout/footer.tsx +168 -0
- package/dist/assets/storefront/src/components/layout/navbar/actions.ts +33 -0
- package/dist/assets/storefront/src/components/layout/navbar/cart-icon.tsx +50 -0
- package/dist/assets/storefront/src/components/layout/navbar/channel-picker-wrapper.tsx +19 -0
- package/dist/assets/storefront/src/components/layout/navbar/channel-picker.tsx +53 -0
- package/dist/assets/storefront/src/components/layout/navbar/currency-picker-wrapper.tsx +21 -0
- package/dist/assets/storefront/src/components/layout/navbar/currency-picker.tsx +52 -0
- package/dist/assets/storefront/src/components/layout/navbar/language-picker.tsx +51 -0
- package/dist/assets/storefront/src/components/layout/navbar/login-button.tsx +34 -0
- package/dist/assets/storefront/src/components/layout/navbar/mobile-nav.tsx +74 -0
- package/dist/assets/storefront/src/components/layout/navbar/nav-menu-items.tsx +51 -0
- package/dist/assets/storefront/src/components/layout/navbar/navbar-cart.tsx +5 -0
- package/dist/assets/storefront/src/components/layout/navbar/navbar-collections.tsx +291 -0
- package/dist/assets/storefront/src/components/layout/navbar/navbar-link.tsx +28 -0
- package/dist/assets/storefront/src/components/layout/navbar/navbar-user.tsx +147 -0
- package/dist/assets/storefront/src/components/layout/navbar/theme-switcher.tsx +39 -0
- package/dist/assets/storefront/src/components/layout/navbar.tsx +117 -0
- package/dist/assets/storefront/src/components/layout/search-input.tsx +71 -0
- package/dist/assets/storefront/src/components/providers/awaiting-approval-banner.tsx +58 -0
- package/dist/assets/storefront/src/components/providers/cart-count-server.tsx +31 -0
- package/dist/assets/storefront/src/components/providers/company-context-guard.tsx +47 -0
- package/dist/assets/storefront/src/components/providers/company-permissions-server.tsx +14 -0
- package/dist/assets/storefront/src/components/providers/theme-provider.tsx +16 -0
- package/dist/assets/storefront/src/components/shared/breadcrumbs.tsx +39 -0
- package/dist/assets/storefront/src/components/shared/catalog-sidebar-skeleton.tsx +21 -0
- package/dist/assets/storefront/src/components/shared/country-select.tsx +83 -0
- package/dist/assets/storefront/src/components/shared/error-state.tsx +16 -0
- package/dist/assets/storefront/src/components/shared/pagination.tsx +119 -0
- package/dist/assets/storefront/src/components/shared/prefetch-link.tsx +36 -0
- package/dist/assets/storefront/src/components/shared/product-grid-skeleton.tsx +26 -0
- package/dist/assets/storefront/src/components/shared/scenario-paused.tsx +80 -0
- package/dist/assets/storefront/src/components/shared/skeletons/cart-skeleton.tsx +48 -0
- package/dist/assets/storefront/src/components/shared/skeletons/navbar-user-skeleton.tsx +9 -0
- package/dist/assets/storefront/src/components/shared/skeletons/search-input-skeleton.tsx +7 -0
- package/dist/assets/storefront/src/components/shared/skeletons/search-results-skeleton.tsx +17 -0
- package/dist/assets/storefront/src/components/ui/accordion.tsx +66 -0
- package/dist/assets/storefront/src/components/ui/alert-dialog.tsx +157 -0
- package/dist/assets/storefront/src/components/ui/alert.tsx +66 -0
- package/dist/assets/storefront/src/components/ui/aspect-ratio.tsx +11 -0
- package/dist/assets/storefront/src/components/ui/avatar.tsx +53 -0
- package/dist/assets/storefront/src/components/ui/badge.tsx +46 -0
- package/dist/assets/storefront/src/components/ui/breadcrumb.tsx +109 -0
- package/dist/assets/storefront/src/components/ui/button.tsx +58 -0
- package/dist/assets/storefront/src/components/ui/calendar.tsx +213 -0
- package/dist/assets/storefront/src/components/ui/card.tsx +92 -0
- package/dist/assets/storefront/src/components/ui/carousel.tsx +241 -0
- package/dist/assets/storefront/src/components/ui/chart.tsx +357 -0
- package/dist/assets/storefront/src/components/ui/checkbox.tsx +32 -0
- package/dist/assets/storefront/src/components/ui/collapsible.tsx +33 -0
- package/dist/assets/storefront/src/components/ui/command.tsx +184 -0
- package/dist/assets/storefront/src/components/ui/context-menu.tsx +252 -0
- package/dist/assets/storefront/src/components/ui/dialog.tsx +143 -0
- package/dist/assets/storefront/src/components/ui/drawer.tsx +135 -0
- package/dist/assets/storefront/src/components/ui/dropdown-menu.tsx +257 -0
- package/dist/assets/storefront/src/components/ui/empty-state.tsx +37 -0
- package/dist/assets/storefront/src/components/ui/field.tsx +244 -0
- package/dist/assets/storefront/src/components/ui/form.tsx +167 -0
- package/dist/assets/storefront/src/components/ui/hover-card.tsx +44 -0
- package/dist/assets/storefront/src/components/ui/input-otp.tsx +77 -0
- package/dist/assets/storefront/src/components/ui/input.tsx +21 -0
- package/dist/assets/storefront/src/components/ui/kbd-shortcut.tsx +20 -0
- package/dist/assets/storefront/src/components/ui/label.tsx +24 -0
- package/dist/assets/storefront/src/components/ui/menubar.tsx +276 -0
- package/dist/assets/storefront/src/components/ui/navigation-menu.tsx +168 -0
- package/dist/assets/storefront/src/components/ui/pagination.tsx +127 -0
- package/dist/assets/storefront/src/components/ui/popover.tsx +48 -0
- package/dist/assets/storefront/src/components/ui/progress.tsx +31 -0
- package/dist/assets/storefront/src/components/ui/radio-group.tsx +45 -0
- package/dist/assets/storefront/src/components/ui/resizable.tsx +56 -0
- package/dist/assets/storefront/src/components/ui/scroll-area.tsx +58 -0
- package/dist/assets/storefront/src/components/ui/select.tsx +185 -0
- package/dist/assets/storefront/src/components/ui/separator.tsx +28 -0
- package/dist/assets/storefront/src/components/ui/sheet.tsx +139 -0
- package/dist/assets/storefront/src/components/ui/sidebar.tsx +728 -0
- package/dist/assets/storefront/src/components/ui/skeleton.tsx +13 -0
- package/dist/assets/storefront/src/components/ui/slider.tsx +63 -0
- package/dist/assets/storefront/src/components/ui/sonner.tsx +25 -0
- package/dist/assets/storefront/src/components/ui/switch.tsx +31 -0
- package/dist/assets/storefront/src/components/ui/table.tsx +116 -0
- package/dist/assets/storefront/src/components/ui/tabs.tsx +66 -0
- package/dist/assets/storefront/src/components/ui/textarea.tsx +18 -0
- package/dist/assets/storefront/src/components/ui/toggle-group.tsx +73 -0
- package/dist/assets/storefront/src/components/ui/toggle.tsx +47 -0
- package/dist/assets/storefront/src/components/ui/tooltip.tsx +61 -0
- package/dist/assets/storefront/src/config/branding.ts +4 -0
- package/dist/assets/storefront/src/config/scenario-meta.ts +46 -0
- package/dist/assets/storefront/src/config/scenario.ts +313 -0
- package/dist/assets/storefront/src/contexts/auth-context.tsx +35 -0
- package/dist/assets/storefront/src/graphql.ts +14 -0
- package/dist/assets/storefront/src/hooks/use-mobile.ts +19 -0
- package/dist/assets/storefront/src/i18n/locale-utils.ts +33 -0
- package/dist/assets/storefront/src/i18n/locales.ts +18 -0
- package/dist/assets/storefront/src/i18n/navigation.ts +35 -0
- package/dist/assets/storefront/src/i18n/request.ts +19 -0
- package/dist/assets/storefront/src/i18n/routing.ts +19 -0
- package/dist/assets/storefront/src/i18n/server.ts +16 -0
- package/dist/assets/storefront/src/lib/actions/switch-channel.ts +32 -0
- package/dist/assets/storefront/src/lib/actions/switch-currency.ts +25 -0
- package/dist/assets/storefront/src/lib/auth.ts +18 -0
- package/dist/assets/storefront/src/lib/backend-health.ts +38 -0
- package/dist/assets/storefront/src/lib/cart-count-context.tsx +59 -0
- package/dist/assets/storefront/src/lib/cart-guard-utils.ts +10 -0
- package/dist/assets/storefront/src/lib/cart-guard.ts +104 -0
- package/dist/assets/storefront/src/lib/channel-server.ts +28 -0
- package/dist/assets/storefront/src/lib/channel.ts +2 -0
- package/dist/assets/storefront/src/lib/company-context.ts +35 -0
- package/dist/assets/storefront/src/lib/company-permissions-context.tsx +40 -0
- package/dist/assets/storefront/src/lib/currency-server.ts +20 -0
- package/dist/assets/storefront/src/lib/currency.ts +2 -0
- package/dist/assets/storefront/src/lib/format.ts +48 -0
- package/dist/assets/storefront/src/lib/metadata.ts +85 -0
- package/dist/assets/storefront/src/lib/quantity.test.js +20 -0
- package/dist/assets/storefront/src/lib/quantity.ts +20 -0
- package/dist/assets/storefront/src/lib/search-bar-context.tsx +45 -0
- package/dist/assets/storefront/src/lib/search-helpers.ts +69 -0
- package/dist/assets/storefront/src/lib/use-recent-searches.ts +55 -0
- package/dist/assets/storefront/src/lib/utils.ts +6 -0
- package/dist/assets/storefront/src/lib/vendure/actions.ts +96 -0
- package/dist/assets/storefront/src/lib/vendure/api.ts +164 -0
- package/dist/assets/storefront/src/lib/vendure/approval-utils.ts +21 -0
- package/dist/assets/storefront/src/lib/vendure/cached.ts +71 -0
- package/dist/assets/storefront/src/lib/vendure/fragments.ts +213 -0
- package/dist/assets/storefront/src/lib/vendure/instant-search-action.ts +104 -0
- package/dist/assets/storefront/src/lib/vendure/mutations.ts +1136 -0
- package/dist/assets/storefront/src/lib/vendure/queries.ts +1406 -0
- package/dist/assets/storefront/src/middleware.ts +11 -0
- package/dist/assets/storefront/src/scenarios/b2b-wholesale/branding.ts +180 -0
- package/dist/assets/storefront/src/scenarios/b2b-wholesale/hero.tsx +122 -0
- package/dist/assets/storefront/src/scenarios/b2b-wholesale/index.ts +21 -0
- package/dist/assets/storefront/src/scenarios/b2b-wholesale/meta.ts +3 -0
- package/dist/assets/storefront/src/scenarios/default/branding.ts +148 -0
- package/dist/assets/storefront/src/scenarios/default/hero.tsx +107 -0
- package/dist/assets/storefront/src/scenarios/default/index.ts +12 -0
- package/dist/assets/storefront/src/scenarios/default/meta.ts +3 -0
- package/dist/assets/storefront/src/scenarios/kaminpro/auth-gate.tsx +36 -0
- package/dist/assets/storefront/src/scenarios/kaminpro/branding.ts +238 -0
- package/dist/assets/storefront/src/scenarios/kaminpro/cart-items.tsx +359 -0
- package/dist/assets/storefront/src/scenarios/kaminpro/hero.tsx +123 -0
- package/dist/assets/storefront/src/scenarios/kaminpro/index.ts +50 -0
- package/dist/assets/storefront/src/scenarios/kaminpro/meta.ts +9 -0
- package/dist/assets/storefront/src/scenarios/kaminpro/pdp/components/banners.tsx +21 -0
- package/dist/assets/storefront/src/scenarios/kaminpro/pdp/components/bom-basket.tsx +221 -0
- package/dist/assets/storefront/src/scenarios/kaminpro/pdp/components/btn.tsx +38 -0
- package/dist/assets/storefront/src/scenarios/kaminpro/pdp/components/chip.tsx +35 -0
- package/dist/assets/storefront/src/scenarios/kaminpro/pdp/components/config-header.tsx +72 -0
- package/dist/assets/storefront/src/scenarios/kaminpro/pdp/components/field-row.tsx +126 -0
- package/dist/assets/storefront/src/scenarios/kaminpro/pdp/components/info-dot.tsx +38 -0
- package/dist/assets/storefront/src/scenarios/kaminpro/pdp/components/login-notice.tsx +81 -0
- package/dist/assets/storefront/src/scenarios/kaminpro/pdp/components/module-panel.tsx +144 -0
- package/dist/assets/storefront/src/scenarios/kaminpro/pdp/components/quote-dialog.tsx +110 -0
- package/dist/assets/storefront/src/scenarios/kaminpro/pdp/components/schematic.tsx +674 -0
- package/dist/assets/storefront/src/scenarios/kaminpro/pdp/components/why-panel.tsx +66 -0
- package/dist/assets/storefront/src/scenarios/kaminpro/pdp/configurator-pdp.tsx +43 -0
- package/dist/assets/storefront/src/scenarios/kaminpro/pdp/configurator-shell.tsx +320 -0
- package/dist/assets/storefront/src/scenarios/kaminpro/pdp/lib/data.ts +150 -0
- package/dist/assets/storefront/src/scenarios/kaminpro/pdp/lib/types.ts +30 -0
- package/dist/assets/storefront/src/scenarios/kaminpro/pdp/styles.css +104 -0
- package/dist/assets/storefront/src/scenarios/kaminpro/shop-by-system.tsx +97 -0
- package/dist/assets/storefront/src/scenarios/kaminpro/system-finder/decision-tree.ts +261 -0
- package/dist/assets/storefront/src/scenarios/kaminpro/system-finder/page.tsx +21 -0
- package/dist/assets/storefront/src/scenarios/kaminpro/system-finder/wizard.tsx +600 -0
- package/dist/assets/storefront/src/schema.graphql.placeholder +5 -0
- package/dist/assets/storefront/tsconfig.json +37 -0
- package/dist/assets/templates/CLAUDE.md.hbs +63 -0
- package/dist/assets/templates/README.md.hbs +53 -0
- package/dist/assets/templates/custom-populate.ts.hbs +28 -0
- package/dist/assets/templates/docker-compose.yml.hbs +29 -0
- package/dist/assets/templates/env.hbs +44 -0
- package/dist/assets/templates/environment.d.ts.hbs +32 -0
- package/dist/assets/templates/gitignore.hbs +7 -0
- package/dist/assets/templates/index.ts.hbs +16 -0
- package/dist/assets/templates/npmrc.hbs +1 -0
- package/dist/assets/templates/populate.ts.hbs +27 -0
- package/dist/assets/templates/root-package.json.hbs +17 -0
- package/dist/assets/templates/server-package.json.hbs +31 -0
- package/dist/assets/templates/tsconfig.dashboard.json.hbs +17 -0
- package/dist/assets/templates/tsconfig.root.json.hbs +16 -0
- package/dist/assets/templates/tsconfig.server.json.hbs +20 -0
- package/dist/assets/templates/vendure-config.ts.hbs +80 -0
- package/dist/assets/templates/vite.config.mts.hbs +27 -0
- package/dist/bin/run.d.ts +2 -0
- package/dist/bin/run.js +79 -0
- package/dist/bin/run.js.map +1 -0
- package/dist/cli.d.ts +6 -0
- package/dist/cli.js +154 -0
- package/dist/cli.js.map +1 -0
- package/dist/git-init.d.ts +4 -0
- package/dist/git-init.js +60 -0
- package/dist/git-init.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin-registry.d.ts +10 -0
- package/dist/plugin-registry.js +485 -0
- package/dist/plugin-registry.js.map +1 -0
- package/dist/scaffolder.d.ts +10 -0
- package/dist/scaffolder.js +218 -0
- package/dist/scaffolder.js.map +1 -0
- package/dist/storefront-copier.d.ts +6 -0
- package/dist/storefront-copier.js +68 -0
- package/dist/storefront-copier.js.map +1 -0
- package/dist/template-renderer.d.ts +30 -0
- package/dist/template-renderer.js +177 -0
- package/dist/template-renderer.js.map +1 -0
- package/dist/types.d.ts +60 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useState, useEffect, useRef, useCallback, useTransition } from 'react';
|
|
4
|
+
import { useLocale, useTranslations } from 'next-intl';
|
|
5
|
+
import { useRouter } from '@/i18n/navigation';
|
|
6
|
+
import { Search, Clock, ArrowRight, Package, FolderOpen, X } from 'lucide-react';
|
|
7
|
+
import Image from 'next/image';
|
|
8
|
+
import { instantSearch, type InstantSearchResult } from '@/lib/vendure/instant-search-action';
|
|
9
|
+
import { useRecentSearches } from '@/lib/use-recent-searches';
|
|
10
|
+
import { formatPrice } from '@/lib/format';
|
|
11
|
+
|
|
12
|
+
interface InstantSearchDropdownProps {
|
|
13
|
+
inputRef: React.RefObject<HTMLInputElement | null>;
|
|
14
|
+
searchValue: string;
|
|
15
|
+
onSearchValueChange: (value: string) => void;
|
|
16
|
+
onSubmit: (term: string) => void;
|
|
17
|
+
children: React.ReactNode;
|
|
18
|
+
dropdownClassName?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function InstantSearchDropdown({
|
|
22
|
+
inputRef,
|
|
23
|
+
searchValue,
|
|
24
|
+
onSearchValueChange,
|
|
25
|
+
onSubmit,
|
|
26
|
+
children,
|
|
27
|
+
dropdownClassName = '',
|
|
28
|
+
}: InstantSearchDropdownProps) {
|
|
29
|
+
const router = useRouter();
|
|
30
|
+
const locale = useLocale();
|
|
31
|
+
const tProduct = useTranslations('Product');
|
|
32
|
+
const tCatalog = useTranslations('Catalog');
|
|
33
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
34
|
+
const [results, setResults] = useState<InstantSearchResult | null>(null);
|
|
35
|
+
const [activeIndex, setActiveIndex] = useState(-1);
|
|
36
|
+
const [isPending, startTransition] = useTransition();
|
|
37
|
+
const dropdownRef = useRef<HTMLDivElement>(null);
|
|
38
|
+
const debounceRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
39
|
+
const { searches: recentSearches, addSearch, removeSearch } = useRecentSearches();
|
|
40
|
+
|
|
41
|
+
const collections = results?.collections ?? [];
|
|
42
|
+
|
|
43
|
+
// Build flat list of navigable items for keyboard nav (products first, then collections)
|
|
44
|
+
const items = buildItemList(searchValue, results, collections, recentSearches);
|
|
45
|
+
|
|
46
|
+
// Debounced search
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
49
|
+
|
|
50
|
+
if (!searchValue.trim() || searchValue.trim().length < 2) {
|
|
51
|
+
setResults(null);
|
|
52
|
+
setActiveIndex(-1);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
debounceRef.current = setTimeout(() => {
|
|
57
|
+
startTransition(async () => {
|
|
58
|
+
const data = await instantSearch(searchValue);
|
|
59
|
+
setResults(data);
|
|
60
|
+
setActiveIndex(-1);
|
|
61
|
+
});
|
|
62
|
+
}, 250);
|
|
63
|
+
|
|
64
|
+
return () => {
|
|
65
|
+
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
66
|
+
};
|
|
67
|
+
}, [searchValue]);
|
|
68
|
+
|
|
69
|
+
// Close on outside click
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
function handleClick(e: MouseEvent) {
|
|
72
|
+
if (
|
|
73
|
+
dropdownRef.current &&
|
|
74
|
+
!dropdownRef.current.contains(e.target as Node) &&
|
|
75
|
+
inputRef.current &&
|
|
76
|
+
!inputRef.current.contains(e.target as Node)
|
|
77
|
+
) {
|
|
78
|
+
setIsOpen(false);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
document.addEventListener('mousedown', handleClick);
|
|
82
|
+
return () => document.removeEventListener('mousedown', handleClick);
|
|
83
|
+
}, [inputRef]);
|
|
84
|
+
|
|
85
|
+
const handleFocus = useCallback(() => setIsOpen(true), []);
|
|
86
|
+
|
|
87
|
+
const navigateToItem = useCallback((item: NavItem) => {
|
|
88
|
+
setIsOpen(false);
|
|
89
|
+
if (item.type === 'product') {
|
|
90
|
+
addSearch(searchValue.trim());
|
|
91
|
+
router.push(`/product/${item.slug}`);
|
|
92
|
+
} else if (item.type === 'collection') {
|
|
93
|
+
addSearch(searchValue.trim());
|
|
94
|
+
router.push(`/collection/${item.slug}`);
|
|
95
|
+
} else if (item.type === 'recent') {
|
|
96
|
+
onSearchValueChange(item.term);
|
|
97
|
+
onSubmit(item.term);
|
|
98
|
+
} else if (item.type === 'view-all') {
|
|
99
|
+
addSearch(searchValue.trim());
|
|
100
|
+
onSubmit(searchValue.trim());
|
|
101
|
+
}
|
|
102
|
+
}, [router, searchValue, addSearch, onSearchValueChange, onSubmit]);
|
|
103
|
+
|
|
104
|
+
// eslint-disable-next-line react-hooks/preserve-manual-memoization
|
|
105
|
+
const handleKeyDown = useCallback((e: React.KeyboardEvent) => {
|
|
106
|
+
if (!isOpen) {
|
|
107
|
+
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
108
|
+
setIsOpen(true);
|
|
109
|
+
e.preventDefault();
|
|
110
|
+
}
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
switch (e.key) {
|
|
115
|
+
case 'ArrowDown':
|
|
116
|
+
e.preventDefault();
|
|
117
|
+
setActiveIndex(prev => (prev + 1) % items.length);
|
|
118
|
+
break;
|
|
119
|
+
case 'ArrowUp':
|
|
120
|
+
e.preventDefault();
|
|
121
|
+
setActiveIndex(prev => (prev <= 0 ? items.length - 1 : prev - 1));
|
|
122
|
+
break;
|
|
123
|
+
case 'Enter':
|
|
124
|
+
if (activeIndex >= 0 && activeIndex < items.length) {
|
|
125
|
+
e.preventDefault();
|
|
126
|
+
navigateToItem(items[activeIndex]);
|
|
127
|
+
} else if (searchValue.trim()) {
|
|
128
|
+
e.preventDefault();
|
|
129
|
+
const firstProduct = items.find(item => item.type === 'product');
|
|
130
|
+
if (firstProduct) {
|
|
131
|
+
addSearch(searchValue.trim());
|
|
132
|
+
navigateToItem(firstProduct);
|
|
133
|
+
} else {
|
|
134
|
+
addSearch(searchValue.trim());
|
|
135
|
+
onSubmit(searchValue.trim());
|
|
136
|
+
setIsOpen(false);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
break;
|
|
140
|
+
case 'Escape':
|
|
141
|
+
setIsOpen(false);
|
|
142
|
+
setActiveIndex(-1);
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
// eslint-disable-next-line react-hooks/preserve-manual-memoization
|
|
146
|
+
}, [isOpen, activeIndex, items, searchValue, navigateToItem, addSearch, onSubmit]);
|
|
147
|
+
|
|
148
|
+
const showDropdown = isOpen && (
|
|
149
|
+
(searchValue.trim().length >= 2 && (results || isPending)) ||
|
|
150
|
+
(!searchValue.trim() && recentSearches.length > 0)
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
return (
|
|
154
|
+
<div
|
|
155
|
+
onFocus={handleFocus}
|
|
156
|
+
onKeyDown={handleKeyDown}
|
|
157
|
+
className="relative"
|
|
158
|
+
>
|
|
159
|
+
{children}
|
|
160
|
+
{showDropdown && (
|
|
161
|
+
<div
|
|
162
|
+
ref={dropdownRef}
|
|
163
|
+
className={`absolute top-full left-0 right-0 mt-1 bg-popover border border-border rounded-md shadow-lg z-50 overflow-hidden ${dropdownClassName}`}
|
|
164
|
+
role="listbox"
|
|
165
|
+
>
|
|
166
|
+
{/* Recent searches (when input is empty) */}
|
|
167
|
+
{!searchValue.trim() && recentSearches.length > 0 && (
|
|
168
|
+
<div>
|
|
169
|
+
<div className="px-3 py-2 text-xs font-medium text-muted-foreground uppercase tracking-wider">
|
|
170
|
+
Recent Searches
|
|
171
|
+
</div>
|
|
172
|
+
{recentSearches.map((term, i) => (
|
|
173
|
+
<div
|
|
174
|
+
key={term}
|
|
175
|
+
role="option"
|
|
176
|
+
aria-selected={activeIndex === i}
|
|
177
|
+
className={`flex items-center gap-2 px-3 py-2 cursor-pointer text-sm ${
|
|
178
|
+
activeIndex === i ? 'bg-primary/15' : 'hover:bg-accent/50'
|
|
179
|
+
}`}
|
|
180
|
+
onMouseEnter={() => setActiveIndex(i)}
|
|
181
|
+
onClick={() => navigateToItem(items[i])}
|
|
182
|
+
>
|
|
183
|
+
<Clock className="h-3.5 w-3.5 text-muted-foreground flex-shrink-0" />
|
|
184
|
+
<span className={`flex-1 truncate ${activeIndex === i ? 'text-primary' : ''}`}>{term}</span>
|
|
185
|
+
<button
|
|
186
|
+
type="button"
|
|
187
|
+
onClick={(e) => {
|
|
188
|
+
e.stopPropagation();
|
|
189
|
+
removeSearch(term);
|
|
190
|
+
}}
|
|
191
|
+
className="p-0.5 hover:bg-muted rounded"
|
|
192
|
+
>
|
|
193
|
+
<X className="h-3 w-3 text-muted-foreground" />
|
|
194
|
+
</button>
|
|
195
|
+
</div>
|
|
196
|
+
))}
|
|
197
|
+
</div>
|
|
198
|
+
)}
|
|
199
|
+
|
|
200
|
+
{/* Loading state */}
|
|
201
|
+
{searchValue.trim().length >= 2 && isPending && !results && (
|
|
202
|
+
<div className="px-3 py-4 text-sm text-muted-foreground text-center">
|
|
203
|
+
Searching...
|
|
204
|
+
</div>
|
|
205
|
+
)}
|
|
206
|
+
|
|
207
|
+
{/* Results */}
|
|
208
|
+
{searchValue.trim().length >= 2 && results && (
|
|
209
|
+
<>
|
|
210
|
+
{/* Product results (shown first) */}
|
|
211
|
+
{results.products.length > 0 && (
|
|
212
|
+
<div>
|
|
213
|
+
<div className="px-3 py-2 text-xs font-medium text-muted-foreground uppercase tracking-wider">
|
|
214
|
+
Products
|
|
215
|
+
</div>
|
|
216
|
+
{results.products.map((product, i) => {
|
|
217
|
+
const itemIndex = i;
|
|
218
|
+
return (
|
|
219
|
+
<div
|
|
220
|
+
key={product.productId}
|
|
221
|
+
role="option"
|
|
222
|
+
aria-selected={activeIndex === itemIndex}
|
|
223
|
+
className={`flex items-center gap-3 px-3 py-2 cursor-pointer ${
|
|
224
|
+
activeIndex === itemIndex ? 'bg-primary/15' : 'hover:bg-accent/50'
|
|
225
|
+
}`}
|
|
226
|
+
onMouseEnter={() => setActiveIndex(itemIndex)}
|
|
227
|
+
onClick={() => navigateToItem(items[itemIndex])}
|
|
228
|
+
>
|
|
229
|
+
{product.imageUrl ? (
|
|
230
|
+
<Image
|
|
231
|
+
src={`${product.imageUrl}?w=80&h=80&mode=crop`}
|
|
232
|
+
alt={product.productName}
|
|
233
|
+
width={40}
|
|
234
|
+
height={40}
|
|
235
|
+
className="rounded object-cover flex-shrink-0"
|
|
236
|
+
/>
|
|
237
|
+
) : (
|
|
238
|
+
<div className="w-10 h-10 rounded bg-muted flex items-center justify-center flex-shrink-0">
|
|
239
|
+
<Package className="h-4 w-4 text-muted-foreground" />
|
|
240
|
+
</div>
|
|
241
|
+
)}
|
|
242
|
+
<div className="flex-1 min-w-0">
|
|
243
|
+
<div className={`text-sm font-medium truncate ${activeIndex === itemIndex ? 'text-primary' : ''}`}>
|
|
244
|
+
{product.productName}
|
|
245
|
+
</div>
|
|
246
|
+
<div className="flex items-center gap-2 text-xs text-muted-foreground">
|
|
247
|
+
<span className="font-mono">{product.sku}</span>
|
|
248
|
+
<span>·</span>
|
|
249
|
+
<span>{formatProductPrice(product, locale)}</span>
|
|
250
|
+
</div>
|
|
251
|
+
</div>
|
|
252
|
+
{product.inStock ? (
|
|
253
|
+
<span className="text-xs text-green-500 flex-shrink-0">{tProduct('inStock')}</span>
|
|
254
|
+
) : (
|
|
255
|
+
<span className="text-xs text-red-500 flex-shrink-0">{tProduct('outOfStock')}</span>
|
|
256
|
+
)}
|
|
257
|
+
</div>
|
|
258
|
+
);
|
|
259
|
+
})}
|
|
260
|
+
</div>
|
|
261
|
+
)}
|
|
262
|
+
|
|
263
|
+
{/* Collection suggestions */}
|
|
264
|
+
{collections.length > 0 && (
|
|
265
|
+
<div>
|
|
266
|
+
{results.products.length > 0 && (
|
|
267
|
+
<div className="border-t border-border" />
|
|
268
|
+
)}
|
|
269
|
+
<div className="px-3 py-2 text-xs font-medium text-muted-foreground uppercase tracking-wider">
|
|
270
|
+
{tCatalog('categories')}
|
|
271
|
+
</div>
|
|
272
|
+
{collections.map((collection, i) => {
|
|
273
|
+
const itemIndex = results.products.length + i;
|
|
274
|
+
return (
|
|
275
|
+
<div
|
|
276
|
+
key={collection.id}
|
|
277
|
+
role="option"
|
|
278
|
+
aria-selected={activeIndex === itemIndex}
|
|
279
|
+
className={`flex items-center gap-2 px-3 py-2 cursor-pointer text-sm ${
|
|
280
|
+
activeIndex === itemIndex ? 'bg-primary/15' : 'hover:bg-accent/50'
|
|
281
|
+
}`}
|
|
282
|
+
onMouseEnter={() => setActiveIndex(itemIndex)}
|
|
283
|
+
onClick={() => navigateToItem(items[itemIndex])}
|
|
284
|
+
>
|
|
285
|
+
<FolderOpen className="h-3.5 w-3.5 text-muted-foreground flex-shrink-0" />
|
|
286
|
+
<span className={`flex-1 truncate ${activeIndex === itemIndex ? 'text-primary font-medium' : ''}`}>{collection.name}</span>
|
|
287
|
+
<ArrowRight className="h-3.5 w-3.5 text-muted-foreground" />
|
|
288
|
+
</div>
|
|
289
|
+
);
|
|
290
|
+
})}
|
|
291
|
+
</div>
|
|
292
|
+
)}
|
|
293
|
+
|
|
294
|
+
{/* No results */}
|
|
295
|
+
{results.products.length === 0 && collections.length === 0 && (
|
|
296
|
+
<div className="px-3 py-4 text-sm text-muted-foreground text-center">
|
|
297
|
+
No results for “{searchValue.trim()}”
|
|
298
|
+
</div>
|
|
299
|
+
)}
|
|
300
|
+
|
|
301
|
+
{/* View all results footer */}
|
|
302
|
+
{results.totalItems > 0 && (
|
|
303
|
+
<>
|
|
304
|
+
<div className="border-t border-border" />
|
|
305
|
+
{(() => {
|
|
306
|
+
const viewAllIndex = items.length - 1;
|
|
307
|
+
return (
|
|
308
|
+
<div
|
|
309
|
+
role="option"
|
|
310
|
+
aria-selected={activeIndex === viewAllIndex}
|
|
311
|
+
className={`flex items-center justify-center gap-2 px-3 py-2.5 cursor-pointer text-sm font-medium ${
|
|
312
|
+
activeIndex === viewAllIndex
|
|
313
|
+
? 'bg-primary text-primary-foreground'
|
|
314
|
+
: 'text-primary hover:bg-accent/50'
|
|
315
|
+
}`}
|
|
316
|
+
onMouseEnter={() => setActiveIndex(viewAllIndex)}
|
|
317
|
+
onClick={() => navigateToItem(items[viewAllIndex])}
|
|
318
|
+
>
|
|
319
|
+
<Search className="h-3.5 w-3.5" />
|
|
320
|
+
View all {results.totalItems} results
|
|
321
|
+
</div>
|
|
322
|
+
);
|
|
323
|
+
})()}
|
|
324
|
+
</>
|
|
325
|
+
)}
|
|
326
|
+
</>
|
|
327
|
+
)}
|
|
328
|
+
</div>
|
|
329
|
+
)}
|
|
330
|
+
</div>
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// ── Types and helpers for keyboard navigation ────────────────────────
|
|
335
|
+
|
|
336
|
+
type NavItem =
|
|
337
|
+
| { type: 'recent'; term: string }
|
|
338
|
+
| { type: 'collection'; slug: string }
|
|
339
|
+
| { type: 'product'; slug: string }
|
|
340
|
+
| { type: 'view-all' };
|
|
341
|
+
|
|
342
|
+
function buildItemList(
|
|
343
|
+
searchValue: string,
|
|
344
|
+
results: InstantSearchResult | null,
|
|
345
|
+
collections: InstantSearchResult['collections'],
|
|
346
|
+
recentSearches: string[],
|
|
347
|
+
): NavItem[] {
|
|
348
|
+
// Empty input → show recent searches
|
|
349
|
+
if (!searchValue.trim()) {
|
|
350
|
+
return recentSearches.map(term => ({ type: 'recent', term }));
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
if (!results) return [];
|
|
354
|
+
|
|
355
|
+
// Products first, then matching collections, then view-all
|
|
356
|
+
const items: NavItem[] = [];
|
|
357
|
+
for (const p of results.products) {
|
|
358
|
+
items.push({ type: 'product', slug: p.slug });
|
|
359
|
+
}
|
|
360
|
+
for (const c of collections) {
|
|
361
|
+
items.push({ type: 'collection', slug: c.slug });
|
|
362
|
+
}
|
|
363
|
+
if (results.totalItems > 0) {
|
|
364
|
+
items.push({ type: 'view-all' });
|
|
365
|
+
}
|
|
366
|
+
return items;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function formatProductPrice(product: { price: { type: string; value?: number; min?: number; max?: number } }, locale: string): string {
|
|
370
|
+
if (product.price.type === 'single' && product.price.value != null) {
|
|
371
|
+
return formatPrice(product.price.value, locale);
|
|
372
|
+
}
|
|
373
|
+
if (product.price.type === 'range' && product.price.min != null) {
|
|
374
|
+
return `from ${formatPrice(product.price.min, locale)}`;
|
|
375
|
+
}
|
|
376
|
+
return '';
|
|
377
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {Badge} from '@/components/ui/badge';
|
|
2
|
+
import {
|
|
3
|
+
ShoppingCart,
|
|
4
|
+
CreditCard,
|
|
5
|
+
Clock,
|
|
6
|
+
CheckCircle,
|
|
7
|
+
Truck,
|
|
8
|
+
PackageCheck,
|
|
9
|
+
Package,
|
|
10
|
+
XCircle,
|
|
11
|
+
type LucideIcon,
|
|
12
|
+
} from 'lucide-react';
|
|
13
|
+
|
|
14
|
+
const STATUS_CONFIG: Record<string, { color: string; label: string; icon: LucideIcon }> = {
|
|
15
|
+
AddingItems: {color: 'bg-gray-100 text-gray-800', label: 'Adding Items', icon: ShoppingCart},
|
|
16
|
+
ArrangingPayment: {color: 'bg-yellow-100 text-yellow-800', label: 'Arranging Payment', icon: CreditCard},
|
|
17
|
+
PaymentAuthorized: {color: 'bg-blue-100 text-blue-800', label: 'Payment Authorized', icon: Clock},
|
|
18
|
+
PaymentSettled: {color: 'bg-green-100 text-green-800', label: 'Payment Settled', icon: CheckCircle},
|
|
19
|
+
PartiallyShipped: {color: 'bg-indigo-100 text-indigo-800', label: 'Partially Shipped', icon: Package},
|
|
20
|
+
Shipped: {color: 'bg-purple-100 text-purple-800', label: 'Shipped', icon: Truck},
|
|
21
|
+
PartiallyDelivered: {color: 'bg-cyan-100 text-cyan-800', label: 'Partially Delivered', icon: PackageCheck},
|
|
22
|
+
Delivered: {color: 'bg-emerald-100 text-emerald-800', label: 'Delivered', icon: PackageCheck},
|
|
23
|
+
Cancelled: {color: 'bg-red-100 text-red-800', label: 'Cancelled', icon: XCircle},
|
|
24
|
+
AwaitingApproval: {color: 'bg-amber-100 text-amber-800', label: 'Awaiting Approval', icon: Clock},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
interface OrderStatusBadgeProps {
|
|
28
|
+
state: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function OrderStatusBadge({state}: OrderStatusBadgeProps) {
|
|
32
|
+
const config = STATUS_CONFIG[state] || {color: 'bg-gray-100 text-gray-800', label: state, icon: Clock};
|
|
33
|
+
const Icon = config.icon;
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<Badge className={config.color} variant="secondary">
|
|
37
|
+
<Icon className="h-3 w-3 mr-1"/>
|
|
38
|
+
{config.label}
|
|
39
|
+
</Badge>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Label } from '@/components/ui/label';
|
|
4
|
+
import { Price } from '@/components/commerce/price';
|
|
5
|
+
import { Badge } from '@/components/ui/badge';
|
|
6
|
+
import { Package } from 'lucide-react';
|
|
7
|
+
import type { PriceTier } from '@/components/commerce/price-tiers';
|
|
8
|
+
import type { PackagingUnitOption } from '@/lib/vendure/queries';
|
|
9
|
+
|
|
10
|
+
interface PackagingUnitSelectorProps {
|
|
11
|
+
packagingUnits: PackagingUnitOption[];
|
|
12
|
+
selectedId: string | undefined;
|
|
13
|
+
onSelect: (unit: PackagingUnitOption) => void;
|
|
14
|
+
/** The base variant price (excl. tax) for computing derived prices */
|
|
15
|
+
baseVariantPrice: number;
|
|
16
|
+
currencyCode?: string;
|
|
17
|
+
/** Price tiers from volume pricing — used to show tier-adjusted package prices */
|
|
18
|
+
priceTiers?: PriceTier[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Returns the per-piece price for the given effective base-unit quantity.
|
|
23
|
+
* Falls back to basePrice if no tier matches.
|
|
24
|
+
*/
|
|
25
|
+
function getTierAdjustedPiecePrice(basePrice: number, tiers: PriceTier[] | undefined, effectivePieces: number): number {
|
|
26
|
+
if (!tiers || tiers.length === 0) return basePrice;
|
|
27
|
+
let price = basePrice;
|
|
28
|
+
for (const tier of tiers) {
|
|
29
|
+
if (tier.minQuantity != null && effectivePieces >= tier.minQuantity) {
|
|
30
|
+
price = tier.price;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return price;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function PackagingUnitSelector({
|
|
37
|
+
packagingUnits,
|
|
38
|
+
selectedId,
|
|
39
|
+
onSelect,
|
|
40
|
+
baseVariantPrice,
|
|
41
|
+
currencyCode,
|
|
42
|
+
priceTiers,
|
|
43
|
+
}: PackagingUnitSelectorProps) {
|
|
44
|
+
if (packagingUnits.length === 0) return null;
|
|
45
|
+
|
|
46
|
+
const sortedTiers = priceTiers
|
|
47
|
+
? [...priceTiers].filter(t => t.minQuantity != null).sort((a, b) => a.minQuantity! - b.minQuantity!)
|
|
48
|
+
: undefined;
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<div className="space-y-2">
|
|
52
|
+
<Label className="text-sm font-medium flex items-center gap-1.5">
|
|
53
|
+
<Package className="h-4 w-4" />
|
|
54
|
+
Packaging Unit
|
|
55
|
+
</Label>
|
|
56
|
+
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2">
|
|
57
|
+
{packagingUnits.map((pu) => {
|
|
58
|
+
const isSelected = selectedId === pu.packagingUnit.id;
|
|
59
|
+
|
|
60
|
+
// Effective pieces at minQuantity: e.g. 1 box × 50 = 50 pieces
|
|
61
|
+
const effectivePieces = pu.minQuantity * pu.conversionFactor;
|
|
62
|
+
const perPiecePrice = getTierAdjustedPiecePrice(baseVariantPrice, sortedTiers, effectivePieces);
|
|
63
|
+
const displayPrice = Math.round(perPiecePrice * pu.conversionFactor);
|
|
64
|
+
|
|
65
|
+
const stockLevel = pu.effectiveStockLevel;
|
|
66
|
+
const isOutOfStock = stockLevel !== null && stockLevel <= 0;
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<button
|
|
70
|
+
key={pu.id}
|
|
71
|
+
type="button"
|
|
72
|
+
disabled={isOutOfStock}
|
|
73
|
+
onClick={() => onSelect(pu)}
|
|
74
|
+
className={`relative flex flex-col items-start gap-1 rounded-md border-2 p-3 text-left text-sm transition-colors ${
|
|
75
|
+
isSelected
|
|
76
|
+
? 'border-primary bg-primary/5'
|
|
77
|
+
: isOutOfStock
|
|
78
|
+
? 'border-muted opacity-50 cursor-not-allowed'
|
|
79
|
+
: 'border-muted bg-popover hover:bg-accent hover:text-accent-foreground cursor-pointer'
|
|
80
|
+
}`}
|
|
81
|
+
>
|
|
82
|
+
<div className="flex items-center gap-2 w-full">
|
|
83
|
+
<span className="font-medium">
|
|
84
|
+
{pu.conversionFactor === 1
|
|
85
|
+
? pu.packagingUnit.name
|
|
86
|
+
: `${pu.packagingUnit.name} (${pu.conversionFactor} pcs)`}
|
|
87
|
+
</span>
|
|
88
|
+
{pu.isBaseUnit && (
|
|
89
|
+
<Badge
|
|
90
|
+
variant="secondary"
|
|
91
|
+
className="text-[10px] px-1.5 py-0"
|
|
92
|
+
>
|
|
93
|
+
Base
|
|
94
|
+
</Badge>
|
|
95
|
+
)}
|
|
96
|
+
</div>
|
|
97
|
+
|
|
98
|
+
<div className="flex items-center gap-2 text-xs text-muted-foreground">
|
|
99
|
+
<span className="font-medium text-foreground">
|
|
100
|
+
<Price
|
|
101
|
+
value={displayPrice}
|
|
102
|
+
currencyCode={currencyCode}
|
|
103
|
+
/>
|
|
104
|
+
</span>
|
|
105
|
+
{pu.conversionFactor > 1 && (
|
|
106
|
+
<>
|
|
107
|
+
<span>·</span>
|
|
108
|
+
<span>
|
|
109
|
+
<Price value={perPiecePrice} currencyCode={currencyCode} />/pc
|
|
110
|
+
</span>
|
|
111
|
+
</>
|
|
112
|
+
)}
|
|
113
|
+
</div>
|
|
114
|
+
|
|
115
|
+
<div className="flex items-center gap-2 text-xs text-muted-foreground">
|
|
116
|
+
{stockLevel !== null && (
|
|
117
|
+
<span
|
|
118
|
+
className={
|
|
119
|
+
isOutOfStock
|
|
120
|
+
? 'text-red-600'
|
|
121
|
+
: stockLevel < 10
|
|
122
|
+
? 'text-amber-600'
|
|
123
|
+
: 'text-emerald-600'
|
|
124
|
+
}
|
|
125
|
+
>
|
|
126
|
+
{isOutOfStock
|
|
127
|
+
? 'Out of stock'
|
|
128
|
+
: `${stockLevel} available`}
|
|
129
|
+
</span>
|
|
130
|
+
)}
|
|
131
|
+
{pu.minQuantity > 1 && (
|
|
132
|
+
<>
|
|
133
|
+
{stockLevel !== null && (
|
|
134
|
+
<span>·</span>
|
|
135
|
+
)}
|
|
136
|
+
<span>Min. {pu.minQuantity}</span>
|
|
137
|
+
</>
|
|
138
|
+
)}
|
|
139
|
+
</div>
|
|
140
|
+
</button>
|
|
141
|
+
);
|
|
142
|
+
})}
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
);
|
|
146
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type {ReactNode} from 'react';
|
|
2
|
+
import {getCompanyAccount} from '@/lib/vendure/actions';
|
|
3
|
+
|
|
4
|
+
interface PermissionGateProps {
|
|
5
|
+
permission: string | string[];
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
fallback?: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export async function PermissionGate({permission, children, fallback = null}: PermissionGateProps) {
|
|
11
|
+
const companyAccount = await getCompanyAccount();
|
|
12
|
+
|
|
13
|
+
if (!companyAccount) return fallback;
|
|
14
|
+
|
|
15
|
+
const permissions = companyAccount.permissions;
|
|
16
|
+
const required = Array.isArray(permission) ? permission : [permission];
|
|
17
|
+
const hasPermission = required.some(p => permissions.includes(p));
|
|
18
|
+
|
|
19
|
+
return hasPermission ? <>{children}</> : <>{fallback}</>;
|
|
20
|
+
}
|