@vendure-platform/create 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +39 -39
- package/dist/add-to-existing.js +1 -1
- package/dist/assets/demo-data/initial-data.json +663 -663
- package/dist/assets/storefront/components.json +20 -20
- package/dist/assets/storefront/eslint.config.mjs +10 -10
- package/dist/assets/storefront/graphql.config.yml +1 -1
- package/dist/assets/storefront/messages/de.json +2 -0
- package/dist/assets/storefront/messages/en.json +2 -0
- package/dist/assets/storefront/next.config.ts +5 -4
- package/dist/assets/storefront/package.json +1 -1
- package/dist/assets/storefront/postcss.config.mjs +1 -1
- package/dist/assets/storefront/src/app/[locale]/(catalog)/catalog/page.tsx +17 -21
- package/dist/assets/storefront/src/app/[locale]/(catalog)/collection/[slug]/page.tsx +64 -42
- package/dist/assets/storefront/src/app/[locale]/(catalog)/layout.tsx +1 -5
- package/dist/assets/storefront/src/app/[locale]/(catalog)/product/[slug]/actions.ts +69 -65
- package/dist/assets/storefront/src/app/[locale]/(catalog)/product/[slug]/page.tsx +68 -37
- package/dist/assets/storefront/src/app/[locale]/(catalog)/search/page.tsx +24 -27
- package/dist/assets/storefront/src/app/[locale]/(catalog)/search/search-results.tsx +11 -9
- package/dist/assets/storefront/src/app/[locale]/(catalog)/search/search-term.tsx +4 -4
- package/dist/assets/storefront/src/app/[locale]/(scenario)/[...path]/page.tsx +1 -1
- package/dist/assets/storefront/src/app/[locale]/accept-invitation/[token]/accept-invitation-client.tsx +8 -13
- package/dist/assets/storefront/src/app/[locale]/accept-invitation/[token]/actions.ts +11 -14
- package/dist/assets/storefront/src/app/[locale]/accept-invitation/[token]/page.tsx +30 -33
- package/dist/assets/storefront/src/app/[locale]/accept-invitation/[token]/sign-out-and-retry.tsx +6 -6
- package/dist/assets/storefront/src/app/[locale]/account/addresses/actions.ts +30 -45
- package/dist/assets/storefront/src/app/[locale]/account/addresses/address-form.tsx +166 -159
- package/dist/assets/storefront/src/app/[locale]/account/addresses/addresses-client.tsx +35 -26
- package/dist/assets/storefront/src/app/[locale]/account/addresses/loading.tsx +1 -3
- package/dist/assets/storefront/src/app/[locale]/account/addresses/page.tsx +16 -18
- package/dist/assets/storefront/src/app/[locale]/account/approvals/actions.ts +5 -8
- package/dist/assets/storefront/src/app/[locale]/account/approvals/page.tsx +77 -69
- package/dist/assets/storefront/src/app/[locale]/account/company/actions.ts +10 -11
- package/dist/assets/storefront/src/app/[locale]/account/company/addresses/actions.ts +6 -15
- package/dist/assets/storefront/src/app/[locale]/account/company/addresses/address-form.tsx +57 -49
- package/dist/assets/storefront/src/app/[locale]/account/company/addresses/addresses-client.tsx +23 -25
- package/dist/assets/storefront/src/app/[locale]/account/company/addresses/page.tsx +30 -30
- package/dist/assets/storefront/src/app/[locale]/account/company/business-units/actions.ts +20 -29
- package/dist/assets/storefront/src/app/[locale]/account/company/business-units/business-unit-form.tsx +32 -37
- package/dist/assets/storefront/src/app/[locale]/account/company/business-units/business-units-client.tsx +32 -25
- package/dist/assets/storefront/src/app/[locale]/account/company/business-units/page.tsx +24 -24
- package/dist/assets/storefront/src/app/[locale]/account/company/business-units/types.ts +7 -4
- package/dist/assets/storefront/src/app/[locale]/account/company/edit-company-form.tsx +11 -21
- package/dist/assets/storefront/src/app/[locale]/account/company/page.tsx +23 -28
- package/dist/assets/storefront/src/app/[locale]/account/company/payment-methods/page.tsx +24 -24
- package/dist/assets/storefront/src/app/[locale]/account/company/payment-methods/payment-methods-client.tsx +5 -7
- package/dist/assets/storefront/src/app/[locale]/account/company/roles/page.tsx +22 -25
- package/dist/assets/storefront/src/app/[locale]/account/company/roles/roles-client.tsx +11 -26
- package/dist/assets/storefront/src/app/[locale]/account/company/tax-ids/actions.ts +6 -10
- package/dist/assets/storefront/src/app/[locale]/account/company/tax-ids/page.tsx +18 -16
- package/dist/assets/storefront/src/app/[locale]/account/company/tax-ids/tax-ids-client.tsx +74 -67
- package/dist/assets/storefront/src/app/[locale]/account/company/users/actions.ts +16 -25
- package/dist/assets/storefront/src/app/[locale]/account/company/users/edit-user-form.tsx +27 -25
- package/dist/assets/storefront/src/app/[locale]/account/company/users/invite-user-form.tsx +27 -19
- package/dist/assets/storefront/src/app/[locale]/account/company/users/page.tsx +32 -29
- package/dist/assets/storefront/src/app/[locale]/account/company/users/users-client.tsx +35 -38
- package/dist/assets/storefront/src/app/[locale]/account/error.tsx +1 -3
- package/dist/assets/storefront/src/app/[locale]/account/layout.tsx +16 -22
- package/dist/assets/storefront/src/app/[locale]/account/orders/[code]/page.tsx +151 -103
- package/dist/assets/storefront/src/app/[locale]/account/orders/[code]/reorder-actions.ts +6 -7
- package/dist/assets/storefront/src/app/[locale]/account/orders/[code]/reorder-dialog.tsx +22 -48
- package/dist/assets/storefront/src/app/[locale]/account/orders/loading.tsx +8 -8
- package/dist/assets/storefront/src/app/[locale]/account/orders/page.tsx +101 -61
- package/dist/assets/storefront/src/app/[locale]/account/profile/actions.ts +32 -23
- package/dist/assets/storefront/src/app/[locale]/account/profile/change-password-form.tsx +6 -16
- package/dist/assets/storefront/src/app/[locale]/account/profile/edit-email-form.tsx +7 -17
- package/dist/assets/storefront/src/app/[locale]/account/profile/edit-profile-form.tsx +6 -16
- package/dist/assets/storefront/src/app/[locale]/account/profile/loading.tsx +12 -18
- package/dist/assets/storefront/src/app/[locale]/account/profile/page.tsx +15 -15
- package/dist/assets/storefront/src/app/[locale]/account/quick-order/file-upload-tab.tsx +2 -6
- package/dist/assets/storefront/src/app/[locale]/account/quick-order/manual-entry-tab.tsx +18 -15
- package/dist/assets/storefront/src/app/[locale]/account/quick-order/page.tsx +3 -6
- package/dist/assets/storefront/src/app/[locale]/account/quick-order/preview-table.tsx +10 -2
- package/dist/assets/storefront/src/app/[locale]/account/quick-order/save-to-list-dialog.tsx +24 -26
- package/dist/assets/storefront/src/app/[locale]/account/quick-order/sku-autocomplete.tsx +19 -10
- package/dist/assets/storefront/src/app/[locale]/account/quick-order/text-input-tab.tsx +3 -8
- package/dist/assets/storefront/src/app/[locale]/account/quotes/[id]/page.tsx +86 -59
- package/dist/assets/storefront/src/app/[locale]/account/quotes/actions.ts +38 -45
- package/dist/assets/storefront/src/app/[locale]/account/quotes/new/new-quote-form.tsx +3 -5
- package/dist/assets/storefront/src/app/[locale]/account/quotes/new/page.tsx +6 -6
- package/dist/assets/storefront/src/app/[locale]/account/quotes/page.tsx +92 -59
- package/dist/assets/storefront/src/app/[locale]/account/shared-carts/[id]/activity-feed.tsx +152 -0
- package/dist/assets/storefront/src/app/[locale]/account/shared-carts/[id]/add-item-search.tsx +132 -0
- package/dist/assets/storefront/src/app/[locale]/account/shared-carts/[id]/add-member-form.tsx +140 -0
- package/dist/assets/storefront/src/app/[locale]/account/shared-carts/[id]/members-panel.tsx +259 -0
- package/dist/assets/storefront/src/app/[locale]/account/shared-carts/[id]/page.tsx +55 -0
- package/dist/assets/storefront/src/app/[locale]/account/shared-carts/[id]/rename-dialog.tsx +117 -0
- package/dist/assets/storefront/src/app/[locale]/account/shared-carts/[id]/shared-cart-detail-client.tsx +555 -0
- package/dist/assets/storefront/src/app/[locale]/account/shared-carts/actions.ts +305 -0
- package/dist/assets/storefront/src/app/[locale]/account/shared-carts/new/new-shared-cart-form.tsx +84 -0
- package/dist/assets/storefront/src/app/[locale]/account/shared-carts/new/page.tsx +47 -0
- package/dist/assets/storefront/src/app/[locale]/account/shared-carts/page.tsx +276 -0
- package/dist/assets/storefront/src/app/[locale]/account/shopping-lists/[id]/page.tsx +22 -8
- package/dist/assets/storefront/src/app/[locale]/account/shopping-lists/[id]/shopping-list-detail-client.tsx +62 -49
- package/dist/assets/storefront/src/app/[locale]/account/shopping-lists/actions.ts +9 -4
- package/dist/assets/storefront/src/app/[locale]/account/shopping-lists/create-shopping-list-form.tsx +5 -11
- package/dist/assets/storefront/src/app/[locale]/account/shopping-lists/loading.tsx +1 -1
- package/dist/assets/storefront/src/app/[locale]/account/shopping-lists/page.tsx +32 -42
- package/dist/assets/storefront/src/app/[locale]/account/store-credits/actions.ts +8 -8
- package/dist/assets/storefront/src/app/[locale]/account/store-credits/claim-form.tsx +6 -10
- package/dist/assets/storefront/src/app/[locale]/account/store-credits/page.tsx +76 -55
- package/dist/assets/storefront/src/app/[locale]/account/store-credits/reveal-code.tsx +10 -6
- package/dist/assets/storefront/src/app/[locale]/account/verify-email/page.tsx +32 -39
- package/dist/assets/storefront/src/app/[locale]/cart/actions.ts +29 -23
- package/dist/assets/storefront/src/app/[locale]/cart/cart-items.tsx +111 -40
- package/dist/assets/storefront/src/app/[locale]/cart/cart-line-actions.tsx +9 -9
- package/dist/assets/storefront/src/app/[locale]/cart/cart-quantity-control.tsx +61 -48
- package/dist/assets/storefront/src/app/[locale]/cart/cart-remove-button.tsx +15 -9
- package/dist/assets/storefront/src/app/[locale]/cart/cart.tsx +38 -41
- package/dist/assets/storefront/src/app/[locale]/cart/code-input.tsx +8 -8
- package/dist/assets/storefront/src/app/[locale]/cart/order-summary.tsx +70 -29
- package/dist/assets/storefront/src/app/[locale]/cart/page.tsx +11 -11
- package/dist/assets/storefront/src/app/[locale]/cart/promotion-code.tsx +48 -42
- package/dist/assets/storefront/src/app/[locale]/cart/reapproval-confirm.tsx +22 -20
- package/dist/assets/storefront/src/app/[locale]/cart/request-quote-button.tsx +7 -16
- package/dist/assets/storefront/src/app/[locale]/checkout/actions.ts +39 -65
- package/dist/assets/storefront/src/app/[locale]/checkout/cancel-quote-checkout-button.tsx +5 -5
- package/dist/assets/storefront/src/app/[locale]/checkout/checkout-flow.tsx +202 -202
- package/dist/assets/storefront/src/app/[locale]/checkout/checkout-provider.tsx +142 -142
- package/dist/assets/storefront/src/app/[locale]/checkout/order-summary.tsx +158 -139
- package/dist/assets/storefront/src/app/[locale]/checkout/page.tsx +56 -47
- package/dist/assets/storefront/src/app/[locale]/checkout/steps/delivery-step.tsx +86 -88
- package/dist/assets/storefront/src/app/[locale]/checkout/steps/payment-step.tsx +90 -91
- package/dist/assets/storefront/src/app/[locale]/checkout/steps/review-step.tsx +166 -161
- package/dist/assets/storefront/src/app/[locale]/checkout/steps/shipping-address-step.tsx +573 -494
- package/dist/assets/storefront/src/app/[locale]/error.tsx +3 -5
- package/dist/assets/storefront/src/app/[locale]/forgot-password/actions.ts +10 -7
- package/dist/assets/storefront/src/app/[locale]/forgot-password/forgot-password-form.tsx +10 -25
- package/dist/assets/storefront/src/app/[locale]/forgot-password/page.tsx +5 -5
- package/dist/assets/storefront/src/app/[locale]/globals.css +48 -48
- package/dist/assets/storefront/src/app/[locale]/layout.tsx +53 -47
- package/dist/assets/storefront/src/app/[locale]/not-found.tsx +3 -5
- package/dist/assets/storefront/src/app/[locale]/order-confirmation/[code]/order-confirmation.tsx +71 -44
- package/dist/assets/storefront/src/app/[locale]/order-confirmation/[code]/page.tsx +7 -5
- package/dist/assets/storefront/src/app/[locale]/page.tsx +33 -35
- package/dist/assets/storefront/src/app/[locale]/register/actions.ts +7 -7
- package/dist/assets/storefront/src/app/[locale]/register/page.tsx +22 -16
- package/dist/assets/storefront/src/app/[locale]/register/registration-form.tsx +22 -34
- package/dist/assets/storefront/src/app/[locale]/register-company/actions.ts +15 -19
- package/dist/assets/storefront/src/app/[locale]/register-company/page.tsx +17 -15
- package/dist/assets/storefront/src/app/[locale]/register-company/registration-form.tsx +9 -15
- package/dist/assets/storefront/src/app/[locale]/reset-password/actions.ts +7 -8
- package/dist/assets/storefront/src/app/[locale]/reset-password/page.tsx +18 -12
- package/dist/assets/storefront/src/app/[locale]/reset-password/reset-password-form.tsx +8 -16
- package/dist/assets/storefront/src/app/[locale]/shopping-list/[code]/add-to-cart-button.tsx +10 -4
- package/dist/assets/storefront/src/app/[locale]/shopping-list/[code]/page.tsx +62 -30
- package/dist/assets/storefront/src/app/[locale]/sign-in/actions.ts +14 -16
- package/dist/assets/storefront/src/app/[locale]/sign-in/login-form.tsx +17 -30
- package/dist/assets/storefront/src/app/[locale]/sign-in/page.tsx +35 -30
- package/dist/assets/storefront/src/app/[locale]/verify/actions.ts +8 -8
- package/dist/assets/storefront/src/app/[locale]/verify/page.tsx +18 -14
- package/dist/assets/storefront/src/app/[locale]/verify/verify-content.tsx +25 -27
- package/dist/assets/storefront/src/app/[locale]/verify-pending/page.tsx +23 -23
- package/dist/assets/storefront/src/app/api/clear-company-context/route.ts +6 -3
- package/dist/assets/storefront/src/app/api/revalidate/route.ts +19 -28
- package/dist/assets/storefront/src/app/api/search-analytics/route.ts +1 -1
- package/dist/assets/storefront/src/components/commerce/account-nav-items.ts +44 -17
- package/dist/assets/storefront/src/components/commerce/account-sidebar.tsx +30 -22
- package/dist/assets/storefront/src/components/commerce/active-filters.tsx +1 -1
- package/dist/assets/storefront/src/components/commerce/add-to-shared-cart.tsx +247 -0
- package/dist/assets/storefront/src/components/commerce/approval-decision-form.tsx +9 -13
- package/dist/assets/storefront/src/components/commerce/approval-status-badge.tsx +23 -15
- package/dist/assets/storefront/src/components/commerce/business-unit-switcher.tsx +11 -11
- package/dist/assets/storefront/src/components/commerce/catalog-search-bar.tsx +2 -2
- package/dist/assets/storefront/src/components/commerce/category-product-section.tsx +28 -16
- package/dist/assets/storefront/src/components/commerce/category-sidebar.tsx +31 -18
- package/dist/assets/storefront/src/components/commerce/collection-hero-banner.tsx +2 -4
- package/dist/assets/storefront/src/components/commerce/company-state-badge.tsx +10 -16
- package/dist/assets/storefront/src/components/commerce/company-switcher.tsx +12 -12
- package/dist/assets/storefront/src/components/commerce/configurator-form.tsx +188 -79
- package/dist/assets/storefront/src/components/commerce/facet-filters.tsx +29 -49
- package/dist/assets/storefront/src/components/commerce/gift-card-pdp.tsx +4 -4
- package/dist/assets/storefront/src/components/commerce/gift-card-product-info.tsx +20 -30
- package/dist/assets/storefront/src/components/commerce/instant-search-dropdown.tsx +258 -227
- package/dist/assets/storefront/src/components/commerce/order-status-badge.tsx +27 -19
- package/dist/assets/storefront/src/components/commerce/packaging-unit-selector.tsx +27 -26
- package/dist/assets/storefront/src/components/commerce/permission-gate.tsx +4 -4
- package/dist/assets/storefront/src/components/commerce/price-range-filter.tsx +5 -5
- package/dist/assets/storefront/src/components/commerce/price-tiers.tsx +38 -21
- package/dist/assets/storefront/src/components/commerce/price.tsx +3 -3
- package/dist/assets/storefront/src/components/commerce/product-card-list.tsx +35 -14
- package/dist/assets/storefront/src/components/commerce/product-card.tsx +31 -16
- package/dist/assets/storefront/src/components/commerce/product-carousel.tsx +20 -12
- package/dist/assets/storefront/src/components/commerce/product-grid.tsx +14 -13
- package/dist/assets/storefront/src/components/commerce/product-image-carousel.tsx +10 -8
- package/dist/assets/storefront/src/components/commerce/product-info.tsx +129 -72
- package/dist/assets/storefront/src/components/commerce/product-list-expansion.tsx +102 -74
- package/dist/assets/storefront/src/components/commerce/product-list-view.tsx +1 -1
- package/dist/assets/storefront/src/components/commerce/product-sidebar.tsx +36 -11
- package/dist/assets/storefront/src/components/commerce/product-view-switcher.tsx +33 -21
- package/dist/assets/storefront/src/components/commerce/quote-action-buttons.tsx +54 -36
- package/dist/assets/storefront/src/components/commerce/quote-activity-timeline.tsx +126 -50
- package/dist/assets/storefront/src/components/commerce/quote-comment-form.tsx +9 -13
- package/dist/assets/storefront/src/components/commerce/quote-csv-export-button.tsx +6 -6
- package/dist/assets/storefront/src/components/commerce/quote-product-search.tsx +22 -18
- package/dist/assets/storefront/src/components/commerce/quote-request-form.tsx +28 -27
- package/dist/assets/storefront/src/components/commerce/quote-status-badge.tsx +26 -18
- package/dist/assets/storefront/src/components/commerce/quote-validity-indicator.tsx +7 -7
- package/dist/assets/storefront/src/components/commerce/quote-version-comparison.tsx +50 -30
- package/dist/assets/storefront/src/components/commerce/related-products.tsx +37 -28
- package/dist/assets/storefront/src/components/commerce/shared-cart-role.ts +39 -0
- package/dist/assets/storefront/src/components/commerce/shared-cart-status-badge.tsx +28 -0
- package/dist/assets/storefront/src/components/commerce/shop-by-category.tsx +8 -7
- package/dist/assets/storefront/src/components/commerce/shopping-list-toggle.tsx +14 -20
- package/dist/assets/storefront/src/components/commerce/sort-dropdown.tsx +9 -16
- package/dist/assets/storefront/src/components/commerce/store-credit-summary.tsx +30 -32
- package/dist/assets/storefront/src/components/commerce/subcollection-tiles.tsx +11 -13
- package/dist/assets/storefront/src/components/layout/auth-page-shell.tsx +2 -2
- package/dist/assets/storefront/src/components/layout/draft-mode-indicator.tsx +2 -7
- package/dist/assets/storefront/src/components/layout/draft-mode-link.tsx +4 -2
- package/dist/assets/storefront/src/components/layout/footer.tsx +70 -28
- package/dist/assets/storefront/src/components/layout/navbar/actions.ts +9 -12
- package/dist/assets/storefront/src/components/layout/navbar/cart-icon.tsx +9 -9
- package/dist/assets/storefront/src/components/layout/navbar/channel-picker-wrapper.tsx +4 -9
- package/dist/assets/storefront/src/components/layout/navbar/channel-picker.tsx +13 -8
- package/dist/assets/storefront/src/components/layout/navbar/currency-picker-wrapper.tsx +4 -4
- package/dist/assets/storefront/src/components/layout/navbar/currency-picker.tsx +11 -6
- package/dist/assets/storefront/src/components/layout/navbar/language-picker.tsx +7 -7
- package/dist/assets/storefront/src/components/layout/navbar/login-button.tsx +24 -21
- package/dist/assets/storefront/src/components/layout/navbar/mobile-nav.tsx +8 -8
- package/dist/assets/storefront/src/components/layout/navbar/nav-menu-items.tsx +4 -6
- package/dist/assets/storefront/src/components/layout/navbar/navbar-cart.tsx +1 -1
- package/dist/assets/storefront/src/components/layout/navbar/navbar-collections.tsx +41 -42
- package/dist/assets/storefront/src/components/layout/navbar/navbar-link.tsx +7 -10
- package/dist/assets/storefront/src/components/layout/navbar/navbar-user.tsx +18 -23
- package/dist/assets/storefront/src/components/layout/navbar/theme-switcher.tsx +9 -9
- package/dist/assets/storefront/src/components/layout/navbar.tsx +36 -31
- package/dist/assets/storefront/src/components/layout/search-input.tsx +35 -32
- package/dist/assets/storefront/src/components/providers/awaiting-approval-banner.tsx +12 -10
- package/dist/assets/storefront/src/components/providers/cart-count-server.tsx +14 -12
- package/dist/assets/storefront/src/components/providers/company-context-guard.tsx +4 -4
- package/dist/assets/storefront/src/components/providers/company-permissions-server.tsx +2 -6
- package/dist/assets/storefront/src/components/providers/theme-provider.tsx +3 -3
- package/dist/assets/storefront/src/components/shared/breadcrumbs.tsx +4 -1
- package/dist/assets/storefront/src/components/shared/country-select.tsx +63 -67
- package/dist/assets/storefront/src/components/shared/pagination.tsx +15 -28
- package/dist/assets/storefront/src/components/shared/prefetch-link.tsx +1 -1
- package/dist/assets/storefront/src/components/shared/skeletons/search-input-skeleton.tsx +1 -3
- package/dist/assets/storefront/src/components/ui/accordion.tsx +46 -51
- package/dist/assets/storefront/src/components/ui/alert-dialog.tsx +94 -121
- package/dist/assets/storefront/src/components/ui/alert.tsx +48 -54
- package/dist/assets/storefront/src/components/ui/aspect-ratio.tsx +5 -7
- package/dist/assets/storefront/src/components/ui/avatar.tsx +29 -44
- package/dist/assets/storefront/src/components/ui/badge.tsx +28 -37
- package/dist/assets/storefront/src/components/ui/breadcrumb.tsx +82 -89
- package/dist/assets/storefront/src/components/ui/button.tsx +43 -49
- package/dist/assets/storefront/src/components/ui/calendar.tsx +157 -198
- package/dist/assets/storefront/src/components/ui/card.tsx +53 -76
- package/dist/assets/storefront/src/components/ui/carousel.tsx +194 -212
- package/dist/assets/storefront/src/components/ui/chart.tsx +274 -317
- package/dist/assets/storefront/src/components/ui/checkbox.tsx +24 -27
- package/dist/assets/storefront/src/components/ui/collapsible.tsx +9 -21
- package/dist/assets/storefront/src/components/ui/command.tsx +114 -159
- package/dist/assets/storefront/src/components/ui/context-menu.tsx +167 -199
- package/dist/assets/storefront/src/components/ui/dialog.tsx +97 -114
- package/dist/assets/storefront/src/components/ui/drawer.tsx +93 -107
- package/dist/assets/storefront/src/components/ui/dropdown-menu.tsx +171 -206
- package/dist/assets/storefront/src/components/ui/empty-state.tsx +5 -5
- package/dist/assets/storefront/src/components/ui/field.tsx +196 -208
- package/dist/assets/storefront/src/components/ui/form.tsx +115 -139
- package/dist/assets/storefront/src/components/ui/hover-card.tsx +27 -33
- package/dist/assets/storefront/src/components/ui/input-otp.tsx +50 -59
- package/dist/assets/storefront/src/components/ui/input.tsx +17 -17
- package/dist/assets/storefront/src/components/ui/kbd-shortcut.tsx +3 -1
- package/dist/assets/storefront/src/components/ui/label.tsx +16 -19
- package/dist/assets/storefront/src/components/ui/menubar.tsx +193 -223
- package/dist/assets/storefront/src/components/ui/navigation-menu.tsx +123 -130
- package/dist/assets/storefront/src/components/ui/pagination.tsx +87 -108
- package/dist/assets/storefront/src/components/ui/popover.tsx +29 -35
- package/dist/assets/storefront/src/components/ui/progress.tsx +19 -26
- package/dist/assets/storefront/src/components/ui/radio-group.tsx +32 -38
- package/dist/assets/storefront/src/components/ui/resizable.tsx +37 -42
- package/dist/assets/storefront/src/components/ui/scroll-area.tsx +41 -47
- package/dist/assets/storefront/src/components/ui/select.tsx +130 -152
- package/dist/assets/storefront/src/components/ui/separator.tsx +21 -21
- package/dist/assets/storefront/src/components/ui/sheet.tsx +90 -111
- package/dist/assets/storefront/src/components/ui/sidebar.tsx +611 -649
- package/dist/assets/storefront/src/components/ui/skeleton.tsx +10 -10
- package/dist/assets/storefront/src/components/ui/slider.tsx +50 -55
- package/dist/assets/storefront/src/components/ui/sonner.tsx +20 -20
- package/dist/assets/storefront/src/components/ui/switch.tsx +23 -26
- package/dist/assets/storefront/src/components/ui/table.tsx +65 -97
- package/dist/assets/storefront/src/components/ui/tabs.tsx +39 -55
- package/dist/assets/storefront/src/components/ui/textarea.tsx +14 -14
- package/dist/assets/storefront/src/components/ui/toggle-group.tsx +56 -62
- package/dist/assets/storefront/src/components/ui/toggle.tsx +37 -38
- package/dist/assets/storefront/src/components/ui/tooltip.tsx +38 -46
- package/dist/assets/storefront/src/config/scenario-meta.ts +2 -2
- package/dist/assets/storefront/src/config/scenario.ts +14 -16
- package/dist/assets/storefront/src/contexts/auth-context.tsx +5 -6
- package/dist/assets/storefront/src/graphql-env.d.ts +18 -5
- package/dist/assets/storefront/src/graphql.ts +5 -5
- package/dist/assets/storefront/src/hooks/use-mobile.ts +13 -13
- package/dist/assets/storefront/src/i18n/locale-utils.ts +3 -3
- package/dist/assets/storefront/src/i18n/navigation.ts +4 -4
- package/dist/assets/storefront/src/i18n/request.ts +4 -4
- package/dist/assets/storefront/src/i18n/routing.ts +5 -5
- package/dist/assets/storefront/src/i18n/server.ts +3 -3
- package/dist/assets/storefront/src/lib/actions/switch-channel.ts +9 -9
- package/dist/assets/storefront/src/lib/actions/switch-currency.ts +7 -7
- package/dist/assets/storefront/src/lib/auth.ts +1 -1
- package/dist/assets/storefront/src/lib/backend-health.ts +3 -3
- package/dist/assets/storefront/src/lib/cart-count-context.tsx +10 -4
- package/dist/assets/storefront/src/lib/cart-guard-utils.ts +2 -1
- package/dist/assets/storefront/src/lib/cart-guard.ts +7 -6
- package/dist/assets/storefront/src/lib/channel-server.ts +4 -4
- package/dist/assets/storefront/src/lib/company-context.ts +1 -1
- package/dist/assets/storefront/src/lib/company-permissions-context.tsx +1 -5
- package/dist/assets/storefront/src/lib/currency-server.ts +4 -4
- package/dist/assets/storefront/src/lib/format.ts +16 -7
- package/dist/assets/storefront/src/lib/metadata.ts +39 -44
- package/dist/assets/storefront/src/lib/quantity.ts +2 -4
- package/dist/assets/storefront/src/lib/search-bar-context.tsx +7 -4
- package/dist/assets/storefront/src/lib/use-recent-searches.ts +8 -6
- package/dist/assets/storefront/src/lib/utils.ts +3 -3
- package/dist/assets/storefront/src/lib/vendure/actions.ts +18 -16
- package/dist/assets/storefront/src/lib/vendure/api.ts +44 -27
- package/dist/assets/storefront/src/lib/vendure/approval-utils.ts +9 -8
- package/dist/assets/storefront/src/lib/vendure/cached.ts +20 -15
- package/dist/assets/storefront/src/lib/vendure/mutations.ts +96 -0
- package/dist/assets/storefront/src/lib/vendure/queries.ts +157 -5
- package/dist/assets/storefront/src/middleware.ts +1 -1
- package/dist/assets/storefront/src/scenarios/customer/hero.tsx +2 -2
- package/dist/assets/storefront/src/scenarios/customer/meta.ts +1 -1
- package/dist/assets/storefront/src/schema.graphql +134 -0
- package/dist/bin/run.js +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1 -1
- package/dist/plugin-registry.js +1 -1
- package/dist/scaffold-storefront-only.js +1 -1
- package/dist/scaffolder.js +1 -1
- package/dist/template-renderer.js +1 -1
- package/package.json +2 -2
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
SelectValue,
|
|
13
|
-
} from '@/components/ui/select';
|
|
14
|
-
import {useForm, Controller} from 'react-hook-form';
|
|
15
|
-
import {Loader2} from 'lucide-react';
|
|
16
|
-
import {CountrySelect} from '@/components/shared/country-select';
|
|
17
|
-
import {useTranslations} from 'next-intl';
|
|
3
|
+
import { CountrySelect } from '@/components/shared/country-select';
|
|
4
|
+
import { Button } from '@/components/ui/button';
|
|
5
|
+
import { Checkbox } from '@/components/ui/checkbox';
|
|
6
|
+
import { Field, FieldError, FieldGroup, FieldLabel } from '@/components/ui/field';
|
|
7
|
+
import { Input } from '@/components/ui/input';
|
|
8
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
|
9
|
+
import { Loader2 } from 'lucide-react';
|
|
10
|
+
import { useTranslations } from 'next-intl';
|
|
11
|
+
import { Controller, useForm } from 'react-hook-form';
|
|
18
12
|
|
|
19
13
|
interface Country {
|
|
20
14
|
id: string;
|
|
@@ -49,43 +43,57 @@ interface CompanyAddress {
|
|
|
49
43
|
city?: string | null;
|
|
50
44
|
province?: string | null;
|
|
51
45
|
postalCode?: string | null;
|
|
52
|
-
country: {id: string; code: string; name: string};
|
|
46
|
+
country: { id: string; code: string; name: string };
|
|
53
47
|
phoneNumber?: string | null;
|
|
54
48
|
defaultShippingAddress: boolean;
|
|
55
49
|
defaultBillingAddress: boolean;
|
|
56
|
-
businessUnit?: {id: string; name: string} | null;
|
|
50
|
+
businessUnit?: { id: string; name: string } | null;
|
|
57
51
|
}
|
|
58
52
|
|
|
59
53
|
interface AddressFormProps {
|
|
60
54
|
countries: Country[];
|
|
61
55
|
businessUnits: BusinessUnit[];
|
|
62
56
|
address?: CompanyAddress;
|
|
63
|
-
onSubmit: (data: CompanyAddressFormData & {id?: string}) => Promise<void>;
|
|
57
|
+
onSubmit: (data: CompanyAddressFormData & { id?: string }) => Promise<void>;
|
|
64
58
|
onCancel: () => void;
|
|
65
59
|
isSubmitting: boolean;
|
|
66
60
|
}
|
|
67
61
|
|
|
68
|
-
export function AddressForm({
|
|
62
|
+
export function AddressForm({
|
|
63
|
+
countries,
|
|
64
|
+
businessUnits,
|
|
65
|
+
address,
|
|
66
|
+
onSubmit,
|
|
67
|
+
onCancel,
|
|
68
|
+
isSubmitting,
|
|
69
|
+
}: AddressFormProps) {
|
|
69
70
|
const t = useTranslations('Company.addresses.form');
|
|
70
|
-
const {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
71
|
+
const {
|
|
72
|
+
register,
|
|
73
|
+
handleSubmit,
|
|
74
|
+
formState: { errors },
|
|
75
|
+
control,
|
|
76
|
+
} = useForm<CompanyAddressFormData>({
|
|
77
|
+
defaultValues: address
|
|
78
|
+
? {
|
|
79
|
+
fullName: address.fullName || '',
|
|
80
|
+
streetLine1: address.streetLine1,
|
|
81
|
+
streetLine2: address.streetLine2 || '',
|
|
82
|
+
city: address.city || '',
|
|
83
|
+
province: address.province || '',
|
|
84
|
+
postalCode: address.postalCode || '',
|
|
85
|
+
countryCode: address.country.code,
|
|
86
|
+
phoneNumber: address.phoneNumber || '',
|
|
87
|
+
defaultShippingAddress: address.defaultShippingAddress,
|
|
88
|
+
defaultBillingAddress: address.defaultBillingAddress,
|
|
89
|
+
businessUnitId: address.businessUnit?.id || '',
|
|
90
|
+
}
|
|
91
|
+
: {
|
|
92
|
+
countryCode: countries[0]?.code || 'US',
|
|
93
|
+
defaultShippingAddress: false,
|
|
94
|
+
defaultBillingAddress: false,
|
|
95
|
+
businessUnitId: '',
|
|
96
|
+
},
|
|
89
97
|
});
|
|
90
98
|
|
|
91
99
|
const handleFormSubmit = async (data: CompanyAddressFormData) => {
|
|
@@ -93,7 +101,7 @@ export function AddressForm({countries, businessUnits, address, onSubmit, onCanc
|
|
|
93
101
|
...data,
|
|
94
102
|
businessUnitId: data.businessUnitId || undefined,
|
|
95
103
|
};
|
|
96
|
-
await onSubmit(address ? {...submitData, id: address.id} : submitData);
|
|
104
|
+
await onSubmit(address ? { ...submitData, id: address.id } : submitData);
|
|
97
105
|
};
|
|
98
106
|
|
|
99
107
|
return (
|
|
@@ -104,7 +112,7 @@ export function AddressForm({countries, businessUnits, address, onSubmit, onCanc
|
|
|
104
112
|
<FieldLabel htmlFor="fullName">{t('fullNameLabel')}</FieldLabel>
|
|
105
113
|
<Input
|
|
106
114
|
id="fullName"
|
|
107
|
-
{...register('fullName', {required: t('fullNameRequired')})}
|
|
115
|
+
{...register('fullName', { required: t('fullNameRequired') })}
|
|
108
116
|
disabled={isSubmitting}
|
|
109
117
|
/>
|
|
110
118
|
<FieldError>{errors.fullName?.message}</FieldError>
|
|
@@ -114,7 +122,7 @@ export function AddressForm({countries, businessUnits, address, onSubmit, onCanc
|
|
|
114
122
|
<FieldLabel htmlFor="streetLine1">{t('streetLine1Label')}</FieldLabel>
|
|
115
123
|
<Input
|
|
116
124
|
id="streetLine1"
|
|
117
|
-
{...register('streetLine1', {required: t('streetLine1Required')})}
|
|
125
|
+
{...register('streetLine1', { required: t('streetLine1Required') })}
|
|
118
126
|
disabled={isSubmitting}
|
|
119
127
|
/>
|
|
120
128
|
<FieldError>{errors.streetLine1?.message}</FieldError>
|
|
@@ -129,7 +137,7 @@ export function AddressForm({countries, businessUnits, address, onSubmit, onCanc
|
|
|
129
137
|
<FieldLabel htmlFor="city">{t('cityLabel')}</FieldLabel>
|
|
130
138
|
<Input
|
|
131
139
|
id="city"
|
|
132
|
-
{...register('city', {required: t('cityRequired')})}
|
|
140
|
+
{...register('city', { required: t('cityRequired') })}
|
|
133
141
|
disabled={isSubmitting}
|
|
134
142
|
/>
|
|
135
143
|
<FieldError>{errors.city?.message}</FieldError>
|
|
@@ -139,7 +147,7 @@ export function AddressForm({countries, businessUnits, address, onSubmit, onCanc
|
|
|
139
147
|
<FieldLabel htmlFor="province">{t('provinceLabel')}</FieldLabel>
|
|
140
148
|
<Input
|
|
141
149
|
id="province"
|
|
142
|
-
{...register('province', {required: t('provinceRequired')})}
|
|
150
|
+
{...register('province', { required: t('provinceRequired') })}
|
|
143
151
|
disabled={isSubmitting}
|
|
144
152
|
/>
|
|
145
153
|
<FieldError>{errors.province?.message}</FieldError>
|
|
@@ -149,7 +157,7 @@ export function AddressForm({countries, businessUnits, address, onSubmit, onCanc
|
|
|
149
157
|
<FieldLabel htmlFor="postalCode">{t('postalCodeLabel')}</FieldLabel>
|
|
150
158
|
<Input
|
|
151
159
|
id="postalCode"
|
|
152
|
-
{...register('postalCode', {required: t('postalCodeRequired')})}
|
|
160
|
+
{...register('postalCode', { required: t('postalCodeRequired') })}
|
|
153
161
|
disabled={isSubmitting}
|
|
154
162
|
/>
|
|
155
163
|
<FieldError>{errors.postalCode?.message}</FieldError>
|
|
@@ -160,8 +168,8 @@ export function AddressForm({countries, businessUnits, address, onSubmit, onCanc
|
|
|
160
168
|
<Controller
|
|
161
169
|
name="countryCode"
|
|
162
170
|
control={control}
|
|
163
|
-
rules={{required: t('countryRequired')}}
|
|
164
|
-
render={({field}) => (
|
|
171
|
+
rules={{ required: t('countryRequired') }}
|
|
172
|
+
render={({ field }) => (
|
|
165
173
|
<CountrySelect
|
|
166
174
|
countries={countries}
|
|
167
175
|
value={field.value}
|
|
@@ -189,7 +197,7 @@ export function AddressForm({countries, businessUnits, address, onSubmit, onCanc
|
|
|
189
197
|
<Controller
|
|
190
198
|
name="businessUnitId"
|
|
191
199
|
control={control}
|
|
192
|
-
render={({field}) => (
|
|
200
|
+
render={({ field }) => (
|
|
193
201
|
<Select
|
|
194
202
|
value={field.value}
|
|
195
203
|
onValueChange={field.onChange}
|
|
@@ -216,7 +224,7 @@ export function AddressForm({countries, businessUnits, address, onSubmit, onCanc
|
|
|
216
224
|
<Controller
|
|
217
225
|
name="defaultShippingAddress"
|
|
218
226
|
control={control}
|
|
219
|
-
render={({field}) => (
|
|
227
|
+
render={({ field }) => (
|
|
220
228
|
<Checkbox
|
|
221
229
|
id="defaultShippingAddress"
|
|
222
230
|
checked={field.value}
|
|
@@ -236,7 +244,7 @@ export function AddressForm({countries, businessUnits, address, onSubmit, onCanc
|
|
|
236
244
|
<Controller
|
|
237
245
|
name="defaultBillingAddress"
|
|
238
246
|
control={control}
|
|
239
|
-
render={({field}) => (
|
|
247
|
+
render={({ field }) => (
|
|
240
248
|
<Checkbox
|
|
241
249
|
id="defaultBillingAddress"
|
|
242
250
|
checked={field.value}
|
package/dist/assets/storefront/src/app/[locale]/account/company/addresses/addresses-client.tsx
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import {useState} from 'react';
|
|
4
|
-
import {useTranslations} from 'next-intl';
|
|
5
|
-
import {Card, CardContent, CardHeader, CardTitle} from '@/components/ui/card';
|
|
6
|
-
import {Button} from '@/components/ui/button';
|
|
7
|
-
import {Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle} from '@/components/ui/dialog';
|
|
8
3
|
import {
|
|
9
4
|
AlertDialog,
|
|
10
5
|
AlertDialogAction,
|
|
@@ -15,7 +10,10 @@ import {
|
|
|
15
10
|
AlertDialogHeader,
|
|
16
11
|
AlertDialogTitle,
|
|
17
12
|
} from '@/components/ui/alert-dialog';
|
|
18
|
-
import {Badge} from '@/components/ui/badge';
|
|
13
|
+
import { Badge } from '@/components/ui/badge';
|
|
14
|
+
import { Button } from '@/components/ui/button';
|
|
15
|
+
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
|
16
|
+
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@/components/ui/dialog';
|
|
19
17
|
import {
|
|
20
18
|
DropdownMenu,
|
|
21
19
|
DropdownMenuContent,
|
|
@@ -23,10 +21,16 @@ import {
|
|
|
23
21
|
DropdownMenuSeparator,
|
|
24
22
|
DropdownMenuTrigger,
|
|
25
23
|
} from '@/components/ui/dropdown-menu';
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
24
|
+
import { useRouter } from '@/i18n/navigation';
|
|
25
|
+
import { Edit2, MoreVertical, Plus, Trash2 } from 'lucide-react';
|
|
26
|
+
import { useTranslations } from 'next-intl';
|
|
27
|
+
import { useState } from 'react';
|
|
28
|
+
import {
|
|
29
|
+
createCompanyAddressAction,
|
|
30
|
+
deleteCompanyAddressAction,
|
|
31
|
+
updateCompanyAddressAction,
|
|
32
|
+
} from './actions';
|
|
33
|
+
import { AddressForm } from './address-form';
|
|
30
34
|
|
|
31
35
|
interface Country {
|
|
32
36
|
id: string;
|
|
@@ -47,11 +51,11 @@ interface CompanyAddress {
|
|
|
47
51
|
city?: string | null;
|
|
48
52
|
province?: string | null;
|
|
49
53
|
postalCode?: string | null;
|
|
50
|
-
country: {id: string; code: string; name: string};
|
|
54
|
+
country: { id: string; code: string; name: string };
|
|
51
55
|
phoneNumber?: string | null;
|
|
52
56
|
defaultShippingAddress: boolean;
|
|
53
57
|
defaultBillingAddress: boolean;
|
|
54
|
-
businessUnit?: {id: string; name: string} | null;
|
|
58
|
+
businessUnit?: { id: string; name: string } | null;
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
interface AddressesClientProps {
|
|
@@ -60,7 +64,7 @@ interface AddressesClientProps {
|
|
|
60
64
|
businessUnits: BusinessUnit[];
|
|
61
65
|
}
|
|
62
66
|
|
|
63
|
-
export function AddressesClient({addresses, countries, businessUnits}: AddressesClientProps) {
|
|
67
|
+
export function AddressesClient({ addresses, countries, businessUnits }: AddressesClientProps) {
|
|
64
68
|
const t = useTranslations('Company.addresses');
|
|
65
69
|
const router = useRouter();
|
|
66
70
|
const [dialogOpen, setDialogOpen] = useState(false);
|
|
@@ -163,11 +167,7 @@ export function AddressesClient({addresses, countries, businessUnits}: Addresses
|
|
|
163
167
|
</div>
|
|
164
168
|
<DropdownMenu>
|
|
165
169
|
<DropdownMenuTrigger asChild>
|
|
166
|
-
<Button
|
|
167
|
-
variant="ghost"
|
|
168
|
-
size="icon"
|
|
169
|
-
aria-label="Address actions"
|
|
170
|
-
>
|
|
170
|
+
<Button variant="ghost" size="icon" aria-label="Address actions">
|
|
171
171
|
<MoreVertical className="h-4 w-4" />
|
|
172
172
|
</Button>
|
|
173
173
|
</DropdownMenuTrigger>
|
|
@@ -211,11 +211,11 @@ export function AddressesClient({addresses, countries, businessUnits}: Addresses
|
|
|
211
211
|
<Dialog open={dialogOpen} onOpenChange={setDialogOpen}>
|
|
212
212
|
<DialogContent className="max-w-2xl max-h-[90vh] overflow-y-auto">
|
|
213
213
|
<DialogHeader>
|
|
214
|
-
<DialogTitle>
|
|
214
|
+
<DialogTitle>
|
|
215
|
+
{editingAddress ? t('editDialogTitle') : t('addDialogTitle')}
|
|
216
|
+
</DialogTitle>
|
|
215
217
|
<DialogDescription>
|
|
216
|
-
{editingAddress
|
|
217
|
-
? t('editDialogDescription')
|
|
218
|
-
: t('addDialogDescription')}
|
|
218
|
+
{editingAddress ? t('editDialogDescription') : t('addDialogDescription')}
|
|
219
219
|
</DialogDescription>
|
|
220
220
|
</DialogHeader>
|
|
221
221
|
<AddressForm
|
|
@@ -236,9 +236,7 @@ export function AddressesClient({addresses, countries, businessUnits}: Addresses
|
|
|
236
236
|
<AlertDialogContent>
|
|
237
237
|
<AlertDialogHeader>
|
|
238
238
|
<AlertDialogTitle>{t('deleteDialogTitle')}</AlertDialogTitle>
|
|
239
|
-
<AlertDialogDescription>
|
|
240
|
-
{t('deleteDialogDescription')}
|
|
241
|
-
</AlertDialogDescription>
|
|
239
|
+
<AlertDialogDescription>{t('deleteDialogDescription')}</AlertDialogDescription>
|
|
242
240
|
</AlertDialogHeader>
|
|
243
241
|
<AlertDialogFooter>
|
|
244
242
|
<AlertDialogCancel disabled={isDeleting}>{t('cancelButton')}</AlertDialogCancel>
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {GetCompanyAddressesQuery, GetCompanyBusinessUnitsQuery} from '@/lib/vendure/queries';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {AddressesClient} from './addresses-client';
|
|
1
|
+
import { readFragment } from '@/graphql';
|
|
2
|
+
import { redirect } from '@/i18n/navigation';
|
|
3
|
+
import { getCompanyAccount } from '@/lib/vendure/actions';
|
|
4
|
+
import { client } from '@/lib/vendure/api';
|
|
5
|
+
import { getAvailableCountriesCached } from '@/lib/vendure/cached';
|
|
6
|
+
import { CompanyAddressFragment, CompanyBusinessUnitFragment } from '@/lib/vendure/fragments';
|
|
7
|
+
import { GetCompanyAddressesQuery, GetCompanyBusinessUnitsQuery } from '@/lib/vendure/queries';
|
|
8
|
+
import type { Metadata } from 'next';
|
|
9
|
+
import { getTranslations, setRequestLocale } from 'next-intl/server';
|
|
10
|
+
import { Suspense } from 'react';
|
|
11
|
+
import { AddressesClient } from './addresses-client';
|
|
12
12
|
|
|
13
13
|
export const metadata: Metadata = {
|
|
14
14
|
title: 'Company Addresses',
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
async function CompanyAddressesContent({params}: {params: Promise<{locale: string}>}) {
|
|
18
|
-
const {locale} = await params;
|
|
17
|
+
async function CompanyAddressesContent({ params }: { params: Promise<{ locale: string }> }) {
|
|
18
|
+
const { locale } = await params;
|
|
19
19
|
setRequestLocale(locale);
|
|
20
20
|
const companyAccount = await getCompanyAccount();
|
|
21
21
|
|
|
@@ -24,7 +24,7 @@ async function CompanyAddressesContent({params}: {params: Promise<{locale: strin
|
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
const {permissions} = companyAccount;
|
|
27
|
+
const { permissions } = companyAccount;
|
|
28
28
|
if (!permissions.includes('ManageAddresses')) {
|
|
29
29
|
await redirect('/account/orders');
|
|
30
30
|
}
|
|
@@ -39,8 +39,12 @@ async function CompanyAddressesContent({params}: {params: Promise<{locale: strin
|
|
|
39
39
|
const [businessUnitsResult, businessUnitsError] = businessUnitsRes;
|
|
40
40
|
if (businessUnitsError) throw businessUnitsError;
|
|
41
41
|
|
|
42
|
-
const addresses = (addressesResult.data.companyAddresses ?? []).map(a =>
|
|
43
|
-
|
|
42
|
+
const addresses = (addressesResult.data.companyAddresses ?? []).map((a) =>
|
|
43
|
+
readFragment(CompanyAddressFragment, a),
|
|
44
|
+
);
|
|
45
|
+
const businessUnits = (businessUnitsResult.data.companyBusinessUnits ?? []).map((bu) =>
|
|
46
|
+
readFragment(CompanyBusinessUnitFragment, bu),
|
|
47
|
+
);
|
|
44
48
|
|
|
45
49
|
const t = await getTranslations('Company.addresses');
|
|
46
50
|
|
|
@@ -48,27 +52,23 @@ async function CompanyAddressesContent({params}: {params: Promise<{locale: strin
|
|
|
48
52
|
<div className="space-y-6">
|
|
49
53
|
<div>
|
|
50
54
|
<h1 className="text-3xl font-bold">{t('pageTitle')}</h1>
|
|
51
|
-
<p className="text-muted-foreground mt-2">
|
|
52
|
-
{t('pageDescription')}
|
|
53
|
-
</p>
|
|
55
|
+
<p className="text-muted-foreground mt-2">{t('pageDescription')}</p>
|
|
54
56
|
</div>
|
|
55
57
|
|
|
56
|
-
<AddressesClient
|
|
57
|
-
addresses={addresses}
|
|
58
|
-
countries={countries}
|
|
59
|
-
businessUnits={businessUnits}
|
|
60
|
-
/>
|
|
58
|
+
<AddressesClient addresses={addresses} countries={countries} businessUnits={businessUnits} />
|
|
61
59
|
</div>
|
|
62
60
|
);
|
|
63
61
|
}
|
|
64
62
|
|
|
65
|
-
export default function CompanyAddressesPage({params}: {params: Promise<{locale: string}>}) {
|
|
63
|
+
export default function CompanyAddressesPage({ params }: { params: Promise<{ locale: string }> }) {
|
|
66
64
|
return (
|
|
67
|
-
<Suspense
|
|
68
|
-
|
|
69
|
-
<
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
<Suspense
|
|
66
|
+
fallback={
|
|
67
|
+
<div className="text-center py-12">
|
|
68
|
+
<p className="text-sm text-muted-foreground">Loading...</p>
|
|
69
|
+
</div>
|
|
70
|
+
}
|
|
71
|
+
>
|
|
72
72
|
<CompanyAddressesContent params={params} />
|
|
73
73
|
</Suspense>
|
|
74
74
|
);
|
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
'use server';
|
|
2
2
|
|
|
3
|
-
import {client} from '@/lib/vendure/api';
|
|
3
|
+
import { client } from '@/lib/vendure/api';
|
|
4
4
|
import {
|
|
5
5
|
CreateCompanyBusinessUnitMutation,
|
|
6
|
-
UpdateCompanyBusinessUnitMutation,
|
|
7
6
|
DeleteCompanyBusinessUnitMutation,
|
|
7
|
+
UpdateCompanyBusinessUnitMutation,
|
|
8
8
|
} from '@/lib/vendure/mutations';
|
|
9
|
-
import {revalidatePath} from 'next/cache';
|
|
10
|
-
import type {CreateBUInput, UpdateBUInput} from './types';
|
|
9
|
+
import { revalidatePath } from 'next/cache';
|
|
10
|
+
import type { CreateBUInput, UpdateBUInput } from './types';
|
|
11
11
|
|
|
12
12
|
export async function createBusinessUnitAction(data: CreateBUInput) {
|
|
13
|
-
const [result, error] = await client.mutate(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
phone: data.phone,
|
|
20
|
-
parentId: data.parentId,
|
|
21
|
-
},
|
|
13
|
+
const [result, error] = await client.mutate(CreateCompanyBusinessUnitMutation, {
|
|
14
|
+
input: {
|
|
15
|
+
name: data.name,
|
|
16
|
+
email: data.email,
|
|
17
|
+
phone: data.phone,
|
|
18
|
+
parentId: data.parentId,
|
|
22
19
|
},
|
|
23
|
-
);
|
|
20
|
+
});
|
|
24
21
|
if (error) throw error;
|
|
25
22
|
|
|
26
23
|
if (!result.data.createCompanyBusinessUnit) {
|
|
@@ -32,18 +29,15 @@ export async function createBusinessUnitAction(data: CreateBUInput) {
|
|
|
32
29
|
}
|
|
33
30
|
|
|
34
31
|
export async function updateBusinessUnitAction(data: UpdateBUInput) {
|
|
35
|
-
const [result, error] = await client.mutate(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
phone: data.phone,
|
|
43
|
-
parentId: data.parentId,
|
|
44
|
-
},
|
|
32
|
+
const [result, error] = await client.mutate(UpdateCompanyBusinessUnitMutation, {
|
|
33
|
+
input: {
|
|
34
|
+
id: data.id,
|
|
35
|
+
name: data.name,
|
|
36
|
+
email: data.email,
|
|
37
|
+
phone: data.phone,
|
|
38
|
+
parentId: data.parentId,
|
|
45
39
|
},
|
|
46
|
-
);
|
|
40
|
+
});
|
|
47
41
|
if (error) throw error;
|
|
48
42
|
|
|
49
43
|
if (!result.data.updateCompanyBusinessUnit) {
|
|
@@ -55,10 +49,7 @@ export async function updateBusinessUnitAction(data: UpdateBUInput) {
|
|
|
55
49
|
}
|
|
56
50
|
|
|
57
51
|
export async function deleteBusinessUnitAction(id: string) {
|
|
58
|
-
const [result, error] = await client.mutate(
|
|
59
|
-
DeleteCompanyBusinessUnitMutation,
|
|
60
|
-
{id},
|
|
61
|
-
);
|
|
52
|
+
const [result, error] = await client.mutate(DeleteCompanyBusinessUnitMutation, { id });
|
|
62
53
|
if (error) throw error;
|
|
63
54
|
|
|
64
55
|
if (result.data.deleteCompanyBusinessUnit.result !== 'DELETED') {
|
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import {Button} from '@/components/ui/button';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
SelectValue,
|
|
12
|
-
} from '@/components/ui/select';
|
|
13
|
-
import {useForm, Controller} from 'react-hook-form';
|
|
14
|
-
import {Loader2} from 'lucide-react';
|
|
15
|
-
import type {CompanyBusinessUnit, BUFormSubmitData} from './types';
|
|
16
|
-
import {useTranslations} from 'next-intl';
|
|
3
|
+
import { Button } from '@/components/ui/button';
|
|
4
|
+
import { Field, FieldError, FieldGroup, FieldLabel } from '@/components/ui/field';
|
|
5
|
+
import { Input } from '@/components/ui/input';
|
|
6
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
|
7
|
+
import { Loader2 } from 'lucide-react';
|
|
8
|
+
import { useTranslations } from 'next-intl';
|
|
9
|
+
import { Controller, useForm } from 'react-hook-form';
|
|
10
|
+
import type { BUFormSubmitData, CompanyBusinessUnit } from './types';
|
|
17
11
|
|
|
18
12
|
interface BusinessUnitFormData {
|
|
19
13
|
name: string;
|
|
@@ -34,7 +28,7 @@ function getDepth(buId: string, allBus: CompanyBusinessUnit[]): number {
|
|
|
34
28
|
let depth = 0;
|
|
35
29
|
let currentId = buId;
|
|
36
30
|
while (true) {
|
|
37
|
-
const bu = allBus.find(b => b.id === currentId);
|
|
31
|
+
const bu = allBus.find((b) => b.id === currentId);
|
|
38
32
|
if (!bu?.parent) break;
|
|
39
33
|
depth++;
|
|
40
34
|
currentId = bu.parent.id;
|
|
@@ -43,15 +37,26 @@ function getDepth(buId: string, allBus: CompanyBusinessUnit[]): number {
|
|
|
43
37
|
}
|
|
44
38
|
|
|
45
39
|
function isDescendant(ancestorId: string, targetId: string, allBus: CompanyBusinessUnit[]): boolean {
|
|
46
|
-
const bu = allBus.find(b => b.id === targetId);
|
|
40
|
+
const bu = allBus.find((b) => b.id === targetId);
|
|
47
41
|
if (!bu) return false;
|
|
48
|
-
if (bu.children?.some(c => c.id === ancestorId)) return true;
|
|
49
|
-
return bu.children?.some(c => isDescendant(ancestorId, c.id, allBus)) ?? false;
|
|
42
|
+
if (bu.children?.some((c) => c.id === ancestorId)) return true;
|
|
43
|
+
return bu.children?.some((c) => isDescendant(ancestorId, c.id, allBus)) ?? false;
|
|
50
44
|
}
|
|
51
45
|
|
|
52
|
-
export function BusinessUnitForm({
|
|
46
|
+
export function BusinessUnitForm({
|
|
47
|
+
businessUnit,
|
|
48
|
+
allBusinessUnits,
|
|
49
|
+
onSubmit,
|
|
50
|
+
onCancel,
|
|
51
|
+
isSubmitting,
|
|
52
|
+
}: BusinessUnitFormProps) {
|
|
53
53
|
const t = useTranslations('Company.businessUnits.form');
|
|
54
|
-
const {
|
|
54
|
+
const {
|
|
55
|
+
register,
|
|
56
|
+
handleSubmit,
|
|
57
|
+
formState: { errors },
|
|
58
|
+
control,
|
|
59
|
+
} = useForm<BusinessUnitFormData>({
|
|
55
60
|
defaultValues: {
|
|
56
61
|
name: businessUnit?.name || '',
|
|
57
62
|
email: businessUnit?.email || '',
|
|
@@ -60,7 +65,7 @@ export function BusinessUnitForm({businessUnit, allBusinessUnits, onSubmit, onCa
|
|
|
60
65
|
},
|
|
61
66
|
});
|
|
62
67
|
|
|
63
|
-
const availableParents = allBusinessUnits.filter(bu => {
|
|
68
|
+
const availableParents = allBusinessUnits.filter((bu) => {
|
|
64
69
|
if (businessUnit && bu.id === businessUnit.id) return false;
|
|
65
70
|
if (businessUnit && isDescendant(bu.id, businessUnit.id, allBusinessUnits)) return false;
|
|
66
71
|
const parentDepth = getDepth(bu.id, allBusinessUnits);
|
|
@@ -70,7 +75,7 @@ export function BusinessUnitForm({businessUnit, allBusinessUnits, onSubmit, onCa
|
|
|
70
75
|
|
|
71
76
|
const handleFormSubmit = async (data: BusinessUnitFormData) => {
|
|
72
77
|
await onSubmit({
|
|
73
|
-
...(businessUnit && {id: businessUnit.id}),
|
|
78
|
+
...(businessUnit && { id: businessUnit.id }),
|
|
74
79
|
name: data.name,
|
|
75
80
|
email: data.email || undefined,
|
|
76
81
|
phone: data.phone || undefined,
|
|
@@ -85,7 +90,7 @@ export function BusinessUnitForm({businessUnit, allBusinessUnits, onSubmit, onCa
|
|
|
85
90
|
<FieldLabel htmlFor="name">{t('nameLabel')}</FieldLabel>
|
|
86
91
|
<Input
|
|
87
92
|
id="name"
|
|
88
|
-
{...register('name', {required: t('nameRequired')})}
|
|
93
|
+
{...register('name', { required: t('nameRequired') })}
|
|
89
94
|
disabled={isSubmitting}
|
|
90
95
|
/>
|
|
91
96
|
<FieldError>{errors.name?.message}</FieldError>
|
|
@@ -93,22 +98,12 @@ export function BusinessUnitForm({businessUnit, allBusinessUnits, onSubmit, onCa
|
|
|
93
98
|
|
|
94
99
|
<Field>
|
|
95
100
|
<FieldLabel htmlFor="email">{t('emailLabel')}</FieldLabel>
|
|
96
|
-
<Input
|
|
97
|
-
id="email"
|
|
98
|
-
type="email"
|
|
99
|
-
{...register('email')}
|
|
100
|
-
disabled={isSubmitting}
|
|
101
|
-
/>
|
|
101
|
+
<Input id="email" type="email" {...register('email')} disabled={isSubmitting} />
|
|
102
102
|
</Field>
|
|
103
103
|
|
|
104
104
|
<Field>
|
|
105
105
|
<FieldLabel htmlFor="phone">{t('phoneLabel')}</FieldLabel>
|
|
106
|
-
<Input
|
|
107
|
-
id="phone"
|
|
108
|
-
type="tel"
|
|
109
|
-
{...register('phone')}
|
|
110
|
-
disabled={isSubmitting}
|
|
111
|
-
/>
|
|
106
|
+
<Input id="phone" type="tel" {...register('phone')} disabled={isSubmitting} />
|
|
112
107
|
</Field>
|
|
113
108
|
|
|
114
109
|
<Field>
|
|
@@ -116,7 +111,7 @@ export function BusinessUnitForm({businessUnit, allBusinessUnits, onSubmit, onCa
|
|
|
116
111
|
<Controller
|
|
117
112
|
name="parentId"
|
|
118
113
|
control={control}
|
|
119
|
-
render={({field}) => (
|
|
114
|
+
render={({ field }) => (
|
|
120
115
|
<Select
|
|
121
116
|
value={field.value}
|
|
122
117
|
onValueChange={field.onChange}
|
|
@@ -127,7 +122,7 @@ export function BusinessUnitForm({businessUnit, allBusinessUnits, onSubmit, onCa
|
|
|
127
122
|
</SelectTrigger>
|
|
128
123
|
<SelectContent>
|
|
129
124
|
<SelectItem value="__none__">{t('parentNone')}</SelectItem>
|
|
130
|
-
{availableParents.map(bu => (
|
|
125
|
+
{availableParents.map((bu) => (
|
|
131
126
|
<SelectItem key={bu.id} value={bu.id}>
|
|
132
127
|
{bu.name}
|
|
133
128
|
</SelectItem>
|