@evenicanpm/storefront-core 1.0.3 → 1.0.4
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/docs.tsconfig.json +35 -0
- package/package.json +6 -3
- package/src/api-manager/schemas/product.schema.ts +0 -1
- package/src/api-manager/services/create-query.ts +10 -0
- package/src/api-manager/services/product/queries/get-product-availability.ts +1 -1
- package/src/api-manager/services/user/mutations/add-to-wishlist.ts +23 -3
- package/src/api-manager/services/user/mutations/remove-from-wishlist.ts +23 -0
- package/src/cms/blocks/Components/CategoryCarousel/index.tsx +6 -7
- package/src/cms/blocks/Components/HeroCarousel/index.tsx +25 -19
- package/src/cms/blocks/Components/ProductCarousel/index.tsx +44 -38
- package/src/cms/blocks/Components/ProductSectionFullWidth/index.tsx +7 -3
- package/src/cms/blocks/Components/shared/product-grid.tsx +38 -23
- package/src/components/_components/wishlist/add-to-wishlist-dialog.tsx +1 -1
- package/src/components/_components/wishlist/remove-from-wishlist-dialog.tsx +1 -1
- package/src/components/_components/wishlist-modal/add-to-wishlist-dialog.tsx +1 -1
- package/src/components/_components/wishlist-modal/remove-from-wishlist-dialog.tsx +1 -1
- package/src/components-v2/carousel/carousel.tsx +69 -35
- package/src/components-v2/carousel/components/carousel-arrows.tsx +40 -46
- package/src/components-v2/carousel/components/carousel-dots.tsx +10 -13
- package/src/components-v2/carousel/index.ts +0 -2
- package/src/components-v2/carousel-cards/carousel-card-1/carousel-card-1.tsx +68 -49
- package/src/components-v2/categories/category-list/category-list.tsx +83 -41
- package/src/components-v2/categories/category-list/styles.ts +7 -1
- package/src/components-v2/categories/category-menu.tsx +2 -0
- package/src/components-v2/categories/mega-menu/banner.tsx +68 -37
- package/src/components-v2/categories/mega-menu/column-list.tsx +59 -52
- package/src/components-v2/categories/mega-menu/mega-menu-1.tsx +19 -1
- package/src/components-v2/categories/mega-menu/mega-menu-2.tsx +32 -2
- package/src/components-v2/header/components/mobile-header.tsx +119 -46
- package/src/components-v2/header/components/user.tsx +163 -117
- package/src/components-v2/header/header.tsx +62 -42
- package/src/components-v2/header/sticky-header.tsx +34 -2
- package/src/components-v2/mini-cart/components/bottom-actions.tsx +71 -17
- package/src/components-v2/mini-cart/components/cart-item.tsx +159 -101
- package/src/components-v2/mini-cart/components/empty-view.tsx +59 -19
- package/src/components-v2/mini-cart/components/top-header.tsx +61 -22
- package/src/components-v2/mini-cart/mini-cart-trigger.tsx +99 -0
- package/src/components-v2/mini-cart/mini-cart.tsx +111 -43
- package/src/components-v2/mobile-navigation/mobile-navigation-bar.tsx +93 -48
- package/src/components-v2/navbar/categories.tsx +70 -16
- package/src/components-v2/navbar/category-based-menu/category-based-menu.tsx +135 -41
- package/src/components-v2/navbar/mega-menu/mega-menu.tsx +115 -48
- package/src/components-v2/navbar/mobile-menu/mobile-menu.test.tsx +111 -0
- package/src/components-v2/navbar/mobile-menu/mobile-menu.tsx +127 -56
- package/src/components-v2/navbar/nav-list/nav-list.tsx +125 -103
- package/src/components-v2/navbar/navbar.tsx +72 -20
- package/src/components-v2/product-cards/{product-card-1 → product-card}/components/quantity-buttons.tsx +1 -1
- package/src/components-v2/product-cards/product-card/product-card.tsx +410 -0
- package/src/components-v2/product-cards/{product-card-1 → product-card}/styles/index.ts +6 -0
- package/src/components-v2/product-cards/product-card-plp/product-card.tsx +161 -0
- package/src/components-v2/product-cards/product-card-plp-list/index.ts +1 -0
- package/src/components-v2/product-cards/product-card-plp-list/product-card.tsx +219 -0
- package/src/components-v2/product-cards/product-card-search/product-card.tsx +166 -0
- package/src/components-v2/product-dialog/compound/product-dialog.tsx +225 -0
- package/src/components-v2/product-dialog/index.tsx +29 -0
- package/src/components-v2/product-dimensions/{components → compound}/dimensions-group-error.tsx +1 -1
- package/src/components-v2/product-dimensions/{components → compound}/dimensions-group-label.tsx +1 -1
- package/src/components-v2/product-dimensions/{components → compound}/dimensions-group-list-chip.tsx +1 -1
- package/src/components-v2/product-dimensions/{components → compound}/dimensions-group-list.tsx +1 -1
- package/src/components-v2/product-dimensions/{components → compound}/dimensions-group.tsx +1 -1
- package/src/components-v2/product-dimensions/{components → compound}/dimensions.tsx +0 -3
- package/src/components-v2/product-dimensions/index.tsx +1 -1
- package/src/components-v2/product-quantity-buttons/compound/quantity-buttons-root.tsx +181 -0
- package/src/components-v2/product-quantity-buttons/index.tsx +22 -0
- package/src/components-v2/product-quantity-variants/index.tsx +90 -0
- package/src/components-v2/products-view/compound/context.ts +25 -0
- package/src/components-v2/products-view/compound/products-grid-view.tsx +109 -0
- package/src/components-v2/products-view/compound/products-list-view.tsx +98 -0
- package/src/components-v2/products-view/compound/types.ts +12 -0
- package/src/components-v2/products-view/index.tsx +45 -0
- package/src/components-v2/products-view/products-grid-view.tsx +24 -11
- package/src/components-v2/products-view/products-list-view.tsx +29 -12
- package/src/components-v2/search-bar/compound/context.ts +31 -0
- package/src/components-v2/search-bar/compound/results-item-lg.tsx +43 -0
- package/src/components-v2/search-bar/compound/results-item-sm.tsx +48 -0
- package/src/components-v2/search-bar/compound/results-suspense.tsx +49 -0
- package/src/components-v2/search-bar/compound/results.tsx +42 -0
- package/src/components-v2/search-bar/compound/search-bar-root.tsx +64 -0
- package/src/components-v2/search-bar/compound/textfield-adornment-button.tsx +22 -0
- package/src/components-v2/{search-box/components/category-dropdown.tsx → search-bar/compound/textfield-adornment-category.tsx} +29 -7
- package/src/components-v2/search-bar/compound/textfield-adornment-search-icon.tsx +34 -0
- package/src/components-v2/search-bar/compound/textfield.tsx +58 -0
- package/src/components-v2/search-bar/hooks/use-click-outside.ts +20 -0
- package/src/components-v2/search-bar/hooks/use-search.ts +63 -0
- package/src/components-v2/search-bar/index.tsx +36 -0
- package/src/components-v2/{search-box → search-bar}/styles/index.ts +5 -3
- package/src/components-v2/search-bar/utils/findCategoryNameById.ts +18 -0
- package/src/components-v2/section/compound/section-header.tsx +63 -0
- package/src/components-v2/section/compound/section.tsx +26 -0
- package/src/components-v2/section/index.ts +1 -0
- package/src/components-v2/side-nav/side-nav.tsx +4 -5
- package/src/components-v2/sticky/index.ts +1 -1
- package/src/components-v2/{wishlist-modal → wishlist-dialogs/add-to-wishlist}/add-to-wishlist-button.tsx +1 -1
- package/src/components-v2/wishlist-dialogs/add-to-wishlist/compound/add-to-wishlist-bottom-ui.tsx +35 -0
- package/src/components-v2/wishlist-dialogs/add-to-wishlist/compound/add-to-wishlist-dialog.tsx +79 -0
- package/src/components-v2/wishlist-dialogs/add-to-wishlist/compound/add-to-wishlist-list.tsx +41 -0
- package/src/components-v2/wishlist-dialogs/add-to-wishlist/compound/context.ts +29 -0
- package/src/components-v2/wishlist-dialogs/add-to-wishlist/compound/wishlist-dialog-header.tsx +74 -0
- package/src/components-v2/wishlist-dialogs/add-to-wishlist/compound/wishlist-dialog-item.tsx +82 -0
- package/src/components-v2/wishlist-dialogs/add-to-wishlist/hooks/use-add-to-wishlist.ts +152 -0
- package/src/components-v2/wishlist-dialogs/add-to-wishlist/index.tsx +39 -0
- package/src/components-v2/wishlist-dialogs/create-wishlist/compound/context.ts +2 -0
- package/src/components-v2/wishlist-dialogs/create-wishlist/compound/create-wishlist-bottom-ui.tsx +42 -0
- package/src/components-v2/wishlist-dialogs/create-wishlist/compound/create-wishlist-dialog.tsx +92 -0
- package/src/components-v2/wishlist-dialogs/create-wishlist/compound/create-wishlist-form.tsx +96 -0
- package/src/components-v2/{wishlist/components → wishlist-dialogs/create-wishlist}/create-wishlist-button.tsx +5 -3
- package/src/components-v2/wishlist-dialogs/create-wishlist/index.tsx +22 -0
- package/src/hooks/use-cart.ts +29 -23
- package/src/hooks/use-variants.ts +106 -53
- package/src/lib/build-detail-url.ts +2 -1
- package/src/pages/product-details/product-intro/product-intro.tsx +26 -23
- package/src/pages/product-list/quick-view-dialog-content.tsx +18 -9
- package/src/pages-v2/product-details/bopis/find-in-store-button.tsx +9 -8
- package/src/pages-v2/product-details/bopis/find-in-store-modal.tsx +2 -2
- package/src/{components-v2/shop-card → pages-v2/product-details/bopis/store-card}/shop-card.tsx +17 -48
- package/src/pages-v2/product-details/bopis/store-card/utils/convertSecondsToTime.ts +8 -0
- package/src/pages-v2/product-details/bopis/store-card/utils/getDaysResources.ts +25 -0
- package/src/pages-v2/product-details/product-intro/compound/context.ts +52 -0
- package/src/pages-v2/product-details/product-intro/compound/product-info.tsx +231 -0
- package/src/pages-v2/product-details/product-intro/compound/product-intro-images.tsx +124 -0
- package/src/pages-v2/product-details/product-intro/compound/product-intro.tsx +49 -0
- package/src/pages-v2/product-details/product-intro/compound/thumbnail-with-skeleton.tsx +28 -0
- package/src/pages-v2/product-details/product-intro/utils.ts +42 -0
- package/src/pages-v2/product-details/product-tabs.tsx +87 -21
- package/src/pages-v2/product-details/related-products.tsx +26 -12
- package/src/pages-v2/product-list/quick-view-dialog-content.tsx +17 -10
- package/typedoc.js +3 -1
- package/src/components-v2/MiniCartClient.tsx +0 -65
- package/src/components-v2/carousel-cards/carousel-card-2/carousel-card-2.tsx +0 -78
- package/src/components-v2/carousel-cards/carousel-card-2/index.ts +0 -1
- package/src/components-v2/carousel-cards/carousel-card-2/styles.ts +0 -26
- package/src/components-v2/carousel-cards/carousel-card-3/carousel-card-3.tsx +0 -37
- package/src/components-v2/carousel-cards/carousel-card-3/index.ts +0 -1
- package/src/components-v2/carousel-cards/carousel-card-3/styles.ts +0 -28
- package/src/components-v2/carousel-cards/carousel-card-4/carousel-card-4.tsx +0 -81
- package/src/components-v2/carousel-cards/carousel-card-4/index.ts +0 -1
- package/src/components-v2/carousel-cards/carousel-card-4/styles.ts +0 -27
- package/src/components-v2/category-cards/category-card-1/category-card-1.tsx +0 -21
- package/src/components-v2/category-cards/category-card-1/index.ts +0 -1
- package/src/components-v2/category-cards/category-card-1/styles.ts +0 -37
- package/src/components-v2/countdown/count-box.tsx +0 -19
- package/src/components-v2/countdown/count-down.tsx +0 -24
- package/src/components-v2/countdown/index.tsx +0 -2
- package/src/components-v2/countdown/useCountDown.ts +0 -41
- package/src/components-v2/data-table/index.ts +0 -2
- package/src/components-v2/data-table/table-header.tsx +0 -91
- package/src/components-v2/data-table/table-pagination.tsx +0 -36
- package/src/components-v2/footer/components/about-links.tsx +0 -23
- package/src/components-v2/footer/components/app-store.tsx +0 -38
- package/src/components-v2/footer/components/customer-care-links.tsx +0 -21
- package/src/components-v2/footer/components/logo.tsx +0 -23
- package/src/components-v2/footer/components/social-links.tsx +0 -43
- package/src/components-v2/footer/data/index.ts +0 -54
- package/src/components-v2/footer/footer-1.tsx +0 -62
- package/src/components-v2/footer/footer-2.tsx +0 -57
- package/src/components-v2/footer/footer-3.tsx +0 -53
- package/src/components-v2/footer/footer-4.tsx +0 -71
- package/src/components-v2/footer/index.ts +0 -4
- package/src/components-v2/footer/styles/index.ts +0 -42
- package/src/components-v2/navbar/category-based-menu/components/categories.tsx +0 -44
- package/src/components-v2/navbar/category-based-menu/components/category-item.tsx +0 -31
- package/src/components-v2/navbar/category-based-menu/components/child-categories.tsx +0 -38
- package/src/components-v2/navbar/mega-menu/category-list.tsx +0 -29
- package/src/components-v2/navbar/mobile-menu/render-levels.test.tsx +0 -71
- package/src/components-v2/navbar/mobile-menu/render-levels.tsx +0 -62
- package/src/components-v2/newsletter/index.ts +0 -1
- package/src/components-v2/newsletter/newsletter.tsx +0 -112
- package/src/components-v2/newsletter/social-icons.tsx +0 -35
- package/src/components-v2/newsletter/styles.ts +0 -65
- package/src/components-v2/page-sidenav/grocery-side-nav/components/link-item.tsx +0 -21
- package/src/components-v2/page-sidenav/grocery-side-nav/components/list-item.tsx +0 -27
- package/src/components-v2/page-sidenav/grocery-side-nav/components/nav-accordion.tsx +0 -36
- package/src/components-v2/page-sidenav/grocery-side-nav/components/render-child.tsx +0 -26
- package/src/components-v2/page-sidenav/grocery-side-nav/grocery-side-nav.tsx +0 -32
- package/src/components-v2/page-sidenav/grocery-side-nav/index.ts +0 -1
- package/src/components-v2/page-sidenav/grocery-side-nav/styles/index.ts +0 -11
- package/src/components-v2/page-sidenav/health-beauty-side-nav/components/list-item.tsx +0 -27
- package/src/components-v2/page-sidenav/health-beauty-side-nav/components/nav-accordion.tsx +0 -44
- package/src/components-v2/page-sidenav/health-beauty-side-nav/components/render-child.tsx +0 -20
- package/src/components-v2/page-sidenav/health-beauty-side-nav/health-beauty-side-nav.tsx +0 -43
- package/src/components-v2/page-sidenav/health-beauty-side-nav/index.ts +0 -1
- package/src/components-v2/page-sidenav/health-beauty-side-nav/styles/index.ts +0 -27
- package/src/components-v2/page-sidenav/side-navbar/components/list-item.tsx +0 -25
- package/src/components-v2/page-sidenav/side-navbar/components/nav-accordion.tsx +0 -46
- package/src/components-v2/page-sidenav/side-navbar/components/render-child.tsx +0 -20
- package/src/components-v2/page-sidenav/side-navbar/index.ts +0 -1
- package/src/components-v2/page-sidenav/side-navbar/side-nav-bar.tsx +0 -77
- package/src/components-v2/page-sidenav/side-navbar/styles/index.ts +0 -73
- package/src/components-v2/page-sidenav/side-navbar-2/components/button-content.tsx +0 -32
- package/src/components-v2/page-sidenav/side-navbar-2/components/sidebar-accordion.tsx +0 -66
- package/src/components-v2/page-sidenav/side-navbar-2/index.ts +0 -1
- package/src/components-v2/page-sidenav/side-navbar-2/side-navbar-2.tsx +0 -63
- package/src/components-v2/page-sidenav/side-navbar-2/styles/index.ts +0 -68
- package/src/components-v2/product-cards/product-card-1/index.ts +0 -1
- package/src/components-v2/product-cards/product-card-1/product-card-1-wrapper.tsx +0 -304
- package/src/components-v2/product-cards/product-card-1/product-card.tsx +0 -107
- package/src/components-v2/product-cards/product-card-10/index.ts +0 -1
- package/src/components-v2/product-cards/product-card-10/product-card.tsx +0 -128
- package/src/components-v2/product-cards/product-card-10/styles/index.ts +0 -38
- package/src/components-v2/product-cards/product-card-11/index.ts +0 -1
- package/src/components-v2/product-cards/product-card-11/product-card.tsx +0 -66
- package/src/components-v2/product-cards/product-card-11/styles/index.ts +0 -16
- package/src/components-v2/product-cards/product-card-12/index.ts +0 -1
- package/src/components-v2/product-cards/product-card-12/product-card.tsx +0 -42
- package/src/components-v2/product-cards/product-card-12/styles/index.ts +0 -16
- package/src/components-v2/product-cards/product-card-13/index.ts +0 -1
- package/src/components-v2/product-cards/product-card-13/product-card.tsx +0 -48
- package/src/components-v2/product-cards/product-card-13/styles/index.ts +0 -25
- package/src/components-v2/product-cards/product-card-14/index.ts +0 -1
- package/src/components-v2/product-cards/product-card-14/product-card.tsx +0 -125
- package/src/components-v2/product-cards/product-card-14/styles/index.ts +0 -40
- package/src/components-v2/product-cards/product-card-15/index.ts +0 -1
- package/src/components-v2/product-cards/product-card-15/product-card.tsx +0 -121
- package/src/components-v2/product-cards/product-card-15/styles/index.ts +0 -57
- package/src/components-v2/product-cards/product-card-16/product-card.tsx +0 -116
- package/src/components-v2/product-cards/product-card-2/components/favorite-button.tsx +0 -29
- package/src/components-v2/product-cards/product-card-2/components/product-price.tsx +0 -26
- package/src/components-v2/product-cards/product-card-2/index.ts +0 -1
- package/src/components-v2/product-cards/product-card-2/product-card.tsx +0 -70
- package/src/components-v2/product-cards/product-card-3/components/hover-actions.tsx +0 -83
- package/src/components-v2/product-cards/product-card-3/index.ts +0 -1
- package/src/components-v2/product-cards/product-card-3/product-card.tsx +0 -110
- package/src/components-v2/product-cards/product-card-3/styles/index.ts +0 -89
- package/src/components-v2/product-cards/product-card-4/components/hover-actions.tsx +0 -50
- package/src/components-v2/product-cards/product-card-4/index.ts +0 -1
- package/src/components-v2/product-cards/product-card-4/product-card.tsx +0 -128
- package/src/components-v2/product-cards/product-card-4/styles/index.ts +0 -66
- package/src/components-v2/product-cards/product-card-5/components/button-actions.tsx +0 -49
- package/src/components-v2/product-cards/product-card-5/components/hover-actions.tsx +0 -50
- package/src/components-v2/product-cards/product-card-5/index.ts +0 -1
- package/src/components-v2/product-cards/product-card-5/product-card.tsx +0 -137
- package/src/components-v2/product-cards/product-card-5/styles/index.ts +0 -94
- package/src/components-v2/product-cards/product-card-6/components/hover-actions.tsx +0 -50
- package/src/components-v2/product-cards/product-card-6/index.ts +0 -1
- package/src/components-v2/product-cards/product-card-6/product-card.tsx +0 -121
- package/src/components-v2/product-cards/product-card-6/styles/index.ts +0 -63
- package/src/components-v2/product-cards/product-card-7/components/product-status.tsx +0 -18
- package/src/components-v2/product-cards/product-card-7/components/quantity-buttons.tsx +0 -47
- package/src/components-v2/product-cards/product-card-7/index.ts +0 -1
- package/src/components-v2/product-cards/product-card-7/product-card.tsx +0 -139
- package/src/components-v2/product-cards/product-card-7/styles/index.ts +0 -98
- package/src/components-v2/product-cards/product-card-8/product-card.tsx +0 -151
- package/src/components-v2/product-cards/product-card-9/index.ts +0 -1
- package/src/components-v2/product-cards/product-card-9/product-card.tsx +0 -169
- package/src/components-v2/product-cards/product-card-wishlist/components/hover-actions.tsx +0 -37
- package/src/components-v2/product-cards/product-card-wishlist/product-card.tsx +0 -118
- package/src/components-v2/product-cards/product-card-wishlist/styles/index.ts +0 -53
- package/src/components-v2/product-quantity-buttons/product-quantity-buttons.tsx +0 -88
- package/src/components-v2/products-view/product-view-dialog.tsx +0 -218
- package/src/components-v2/search-box/__test__/search-input-category.test.tsx +0 -110
- package/src/components-v2/search-box/__test__/search-input.test.tsx +0 -137
- package/src/components-v2/search-box/__test__/search-results.json +0 -165
- package/src/components-v2/search-box/components/search-result.tsx +0 -86
- package/src/components-v2/search-box/hooks/use-search.ts +0 -63
- package/src/components-v2/search-box/index.ts +0 -2
- package/src/components-v2/search-box/search-input-category.test.tsx +0 -110
- package/src/components-v2/search-box/search-input-category.tsx +0 -203
- package/src/components-v2/search-box/search-input.test.tsx +0 -41
- package/src/components-v2/search-box/search-input.tsx +0 -66
- package/src/components-v2/section-header/index.ts +0 -2
- package/src/components-v2/section-header/section-creator.tsx +0 -29
- package/src/components-v2/section-header/section-header.tsx +0 -44
- package/src/components-v2/service-cards/icon-component.tsx +0 -18
- package/src/components-v2/service-cards/service-card-1/index.ts +0 -1
- package/src/components-v2/service-cards/service-card-1/service-card-1.tsx +0 -42
- package/src/components-v2/service-cards/service-card-2/index.ts +0 -1
- package/src/components-v2/service-cards/service-card-2/service-card-2.tsx +0 -37
- package/src/components-v2/service-cards/service-card-3/index.ts +0 -1
- package/src/components-v2/service-cards/service-card-3/service-card-3.tsx +0 -28
- package/src/components-v2/service-cards/service-card-3/styles.ts +0 -23
- package/src/components-v2/settings/index.ts +0 -1
- package/src/components-v2/settings/setting.tsx +0 -141
- package/src/components-v2/settings/styles.ts +0 -57
- package/src/components-v2/sticky-wrapper/index.ts +0 -1
- package/src/components-v2/sticky-wrapper/sticky-wrapper.tsx +0 -21
- package/src/components-v2/sticky-wrapper/styles.ts +0 -25
- package/src/components-v2/stories/story-content/index.ts +0 -1
- package/src/components-v2/stories/story-content/story-content.tsx +0 -28
- package/src/components-v2/stories/story-content/styles.ts +0 -22
- package/src/components-v2/stories/story-item/index.ts +0 -1
- package/src/components-v2/stories/story-item/story-item.tsx +0 -24
- package/src/components-v2/stories/story-item/styles.ts +0 -11
- package/src/components-v2/stories/story-viewer/index.ts +0 -1
- package/src/components-v2/stories/story-viewer/story-viewer.tsx +0 -44
- package/src/components-v2/stories/story-viewer/styles.ts +0 -15
- package/src/components-v2/subscribe-input/index.ts +0 -1
- package/src/components-v2/subscribe-input/styles.ts +0 -14
- package/src/components-v2/subscribe-input/subscribe-input.tsx +0 -43
- package/src/components-v2/topbar/index.ts +0 -1
- package/src/components-v2/topbar/styles.ts +0 -55
- package/src/components-v2/topbar/top-bar.tsx +0 -115
- package/src/components-v2/wishlist/add-to-wishlist-dialog.tsx +0 -161
- package/src/components-v2/wishlist/components/create-new-list.tsx +0 -167
- package/src/components-v2/wishlist/components/dashboard-header.tsx +0 -123
- package/src/components-v2/wishlist/components/navigation.tsx +0 -87
- package/src/components-v2/wishlist/components/no-records.tsx +0 -20
- package/src/components-v2/wishlist/components/wishlist-modal-item.tsx +0 -66
- package/src/components-v2/wishlist/remove-from-wishlist-dialog.tsx +0 -175
- package/src/components-v2/wishlist-modal/TODO.md +0 -10
- package/src/components-v2/wishlist-modal/add-to-wishlist-dialog.tsx +0 -161
- package/src/components-v2/wishlist-modal/remove-from-wishlist-dialog.tsx +0 -174
- package/src/components-v2/wishlist-modal/wishlist-modal-item.tsx +0 -65
- package/src/pages-v2/product-details/product-intro/product-intro-images.tsx +0 -90
- package/src/pages-v2/product-details/product-intro/product-intro.tsx +0 -256
- /package/src/{pages-v2/account → components-v2}/no-records.tsx +0 -0
- /package/src/components-v2/product-cards/{product-card-1 → product-card}/components/hover-actions.tsx +0 -0
- /package/src/components-v2/product-cards/{product-card-16 → product-card}/index.ts +0 -0
- /package/src/components-v2/product-cards/{product-card-16 → product-card-plp}/components/quantity-buttons.tsx +0 -0
- /package/src/components-v2/product-cards/{product-card-wishlist → product-card-plp}/index.ts +0 -0
- /package/src/components-v2/product-cards/{product-card-16 → product-card-plp}/styles/index.ts +0 -0
- /package/src/components-v2/product-cards/{product-card-9 → product-card-plp-list}/components/add-to-cart.tsx +0 -0
- /package/src/components-v2/product-cards/{product-card-9 → product-card-plp-list}/components/favorite-button.tsx +0 -0
- /package/src/components-v2/product-cards/{product-card-9 → product-card-plp-list}/components/tags.tsx +0 -0
- /package/src/components-v2/product-cards/{product-card-8 → product-card-search}/index.ts +0 -0
- /package/src/components-v2/product-cards/{product-card-8 → product-card-search}/styles/index.ts +0 -0
- /package/src/components-v2/sticky/{Sticky.tsx → sticky.tsx} +0 -0
- /package/src/components-v2/{wishlist → wishlist-dialogs}/styles.ts +0 -0
- /package/src/{components-v2/shop-card → pages-v2/product-details/bopis/store-card}/index.ts +0 -0
- /package/src/{components-v2/shop-card → pages-v2/product-details/bopis/store-card}/styles.ts +0 -0
|
@@ -1,14 +1,16 @@
|
|
|
1
|
+
// @refresh reset
|
|
1
2
|
"use client";
|
|
3
|
+
|
|
4
|
+
import React, { createContext, useContext } from "react";
|
|
2
5
|
import Link from "next/link";
|
|
3
6
|
import Box from "@mui/material/Box";
|
|
4
7
|
import Button from "@mui/material/Button";
|
|
5
8
|
import Avatar from "@mui/material/Avatar";
|
|
6
9
|
import IconButton from "@mui/material/IconButton";
|
|
7
|
-
|
|
10
|
+
import { CircularProgress } from "@mui/material";
|
|
8
11
|
import Add from "@mui/icons-material/Add";
|
|
9
12
|
import Close from "@mui/icons-material/Close";
|
|
10
13
|
import Remove from "@mui/icons-material/Remove";
|
|
11
|
-
// GLOBAL CUSTOM COMPONENTS
|
|
12
14
|
import { FlexBox } from "@evenicanpm/storefront-core/src/components-v2/flex-box/index";
|
|
13
15
|
import {
|
|
14
16
|
H6,
|
|
@@ -16,132 +18,188 @@ import {
|
|
|
16
18
|
} from "@evenicanpm/storefront-core/src/components-v2/Typography";
|
|
17
19
|
import { CartLine } from "@/schemas/cart.schema";
|
|
18
20
|
import { useFormatter, useTranslations } from "next-intl";
|
|
19
|
-
import { CircularProgress } from "@mui/material";
|
|
20
21
|
import { getProductDetailUrl } from "@/lib/build-product-detail-url";
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
interface Props {
|
|
23
|
+
interface MiniCartItemContextValue {
|
|
24
24
|
item: CartLine;
|
|
25
25
|
handleCartAmountChange: (cartLine: CartLine) => void;
|
|
26
26
|
isLineUpdating: boolean;
|
|
27
27
|
closeDrawer: () => void;
|
|
28
28
|
}
|
|
29
|
-
// ==============================================================
|
|
30
29
|
|
|
31
|
-
const
|
|
32
|
-
|
|
30
|
+
const MiniCartItemContext = createContext<MiniCartItemContextValue | null>(
|
|
31
|
+
null,
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
export interface MiniCartItemProps {
|
|
35
|
+
item: CartLine;
|
|
36
|
+
handleCartAmountChange: (cartLine: CartLine) => void;
|
|
37
|
+
isLineUpdating: boolean;
|
|
38
|
+
closeDrawer: () => void;
|
|
39
|
+
children: React.ReactNode;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const MiniCartItem = ({
|
|
43
|
+
item,
|
|
33
44
|
handleCartAmountChange,
|
|
34
45
|
isLineUpdating,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const t = useTranslations("Cart.CartLine");
|
|
39
|
-
const currency = (value: number) =>
|
|
40
|
-
number(value, { style: "currency", currency: "USD" });
|
|
41
|
-
const quantity = item.Quantity || 0;
|
|
42
|
-
const onIncreaseClick = () => {
|
|
43
|
-
const qty = item.Quantity || 0;
|
|
44
|
-
handleCartAmountChange({ ...item, Quantity: qty + 1 });
|
|
45
|
-
};
|
|
46
|
+
closeDrawer,
|
|
47
|
+
children,
|
|
48
|
+
}: MiniCartItemProps) => {
|
|
46
49
|
return (
|
|
47
|
-
<
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
<MiniCartItemContext.Provider
|
|
51
|
+
value={{
|
|
52
|
+
item,
|
|
53
|
+
handleCartAmountChange,
|
|
54
|
+
isLineUpdating,
|
|
55
|
+
closeDrawer,
|
|
56
|
+
}}
|
|
54
57
|
>
|
|
58
|
+
<FlexBox
|
|
59
|
+
py={2}
|
|
60
|
+
px={2.5}
|
|
61
|
+
key={item.LineId}
|
|
62
|
+
alignItems="center"
|
|
63
|
+
borderBottom="1px solid"
|
|
64
|
+
borderColor="divider"
|
|
65
|
+
>
|
|
66
|
+
{children}
|
|
67
|
+
</FlexBox>
|
|
68
|
+
</MiniCartItemContext.Provider>
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/* ---------- Subcomponents ---------- */
|
|
73
|
+
|
|
74
|
+
MiniCartItem.QuantityControls = () => {
|
|
75
|
+
const ctx = useContext(MiniCartItemContext);
|
|
76
|
+
if (!ctx) return null;
|
|
77
|
+
const { item, handleCartAmountChange, isLineUpdating } = ctx;
|
|
78
|
+
const t = useTranslations("Cart.CartLine");
|
|
79
|
+
const quantity = item?.Quantity || 0;
|
|
80
|
+
|
|
81
|
+
if (isLineUpdating) {
|
|
82
|
+
return (
|
|
55
83
|
<FlexBox
|
|
56
84
|
minWidth={30}
|
|
57
85
|
minHeight={85}
|
|
58
86
|
alignItems="center"
|
|
59
87
|
justifyContent="center"
|
|
60
88
|
>
|
|
61
|
-
{
|
|
62
|
-
<FlexBox alignItems="center" flexDirection="column">
|
|
63
|
-
<Button
|
|
64
|
-
size="small"
|
|
65
|
-
color="primary"
|
|
66
|
-
variant="outlined"
|
|
67
|
-
onClick={onIncreaseClick}
|
|
68
|
-
title={t("increaseQuantity")}
|
|
69
|
-
sx={{ height: 28, width: 28, borderRadius: 50 }}
|
|
70
|
-
>
|
|
71
|
-
<Add fontSize="small" />
|
|
72
|
-
</Button>
|
|
73
|
-
|
|
74
|
-
<H6 my="3px">{item.Quantity}</H6>
|
|
75
|
-
|
|
76
|
-
<Button
|
|
77
|
-
data-testid={"decreaseQuantity"}
|
|
78
|
-
size="small"
|
|
79
|
-
color="primary"
|
|
80
|
-
variant="outlined"
|
|
81
|
-
title={t("decreaseQuantity")}
|
|
82
|
-
disabled={item.Quantity === 1}
|
|
83
|
-
onClick={() =>
|
|
84
|
-
handleCartAmountChange({ ...item, Quantity: quantity - 1 })
|
|
85
|
-
}
|
|
86
|
-
sx={{ height: 28, width: 28, borderRadius: 50 }}
|
|
87
|
-
>
|
|
88
|
-
<Remove fontSize="small" />
|
|
89
|
-
</Button>
|
|
90
|
-
</FlexBox>
|
|
91
|
-
) : (
|
|
92
|
-
<CircularProgress size={"10px"} color={"primary"} />
|
|
93
|
-
)}
|
|
89
|
+
<CircularProgress size={"10px"} color={"primary"} />
|
|
94
90
|
</FlexBox>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
95
93
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
94
|
+
return (
|
|
95
|
+
<FlexBox
|
|
96
|
+
minWidth={30}
|
|
97
|
+
minHeight={85}
|
|
98
|
+
alignItems="center"
|
|
99
|
+
justifyContent="center"
|
|
100
|
+
flexDirection="column"
|
|
101
|
+
>
|
|
102
|
+
<Button
|
|
103
|
+
size="small"
|
|
104
|
+
color="primary"
|
|
105
|
+
variant="outlined"
|
|
106
|
+
onClick={() =>
|
|
107
|
+
handleCartAmountChange({ ...item, Quantity: quantity + 1 })
|
|
108
|
+
}
|
|
109
|
+
title={t("increaseQuantity")}
|
|
110
|
+
sx={{ height: 28, width: 28, borderRadius: 50 }}
|
|
112
111
|
>
|
|
113
|
-
<
|
|
114
|
-
|
|
115
|
-
onClick={() => closeDrawer()}
|
|
116
|
-
>
|
|
117
|
-
<H6 ellipsis className="title">
|
|
118
|
-
{item.Product?.Name}
|
|
119
|
-
</H6>
|
|
120
|
-
</Link>
|
|
121
|
-
<H6 color="grey.600" mt={0.5}>
|
|
122
|
-
{item?.Product?.Dimensions?.map((d, i) => (
|
|
123
|
-
<span key={i}>{d?.DimensionValue?.Value + " "}</span>
|
|
124
|
-
))}
|
|
125
|
-
</H6>
|
|
126
|
-
<Tiny color="grey.600">
|
|
127
|
-
{currency(item.Price || 0)} x {quantity}
|
|
128
|
-
</Tiny>
|
|
112
|
+
<Add fontSize="small" />
|
|
113
|
+
</Button>
|
|
129
114
|
|
|
130
|
-
|
|
131
|
-
{currency(item.TotalAmount || 0)}
|
|
132
|
-
</H6>
|
|
133
|
-
</Box>
|
|
115
|
+
<H6 my="3px">{quantity}</H6>
|
|
134
116
|
|
|
135
|
-
<
|
|
117
|
+
<Button
|
|
118
|
+
data-testid={"decreaseQuantity"}
|
|
136
119
|
size="small"
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
title={t("
|
|
120
|
+
color="primary"
|
|
121
|
+
variant="outlined"
|
|
122
|
+
title={t("decreaseQuantity")}
|
|
123
|
+
disabled={quantity === 1}
|
|
124
|
+
onClick={() =>
|
|
125
|
+
handleCartAmountChange({ ...item, Quantity: quantity - 1 })
|
|
126
|
+
}
|
|
127
|
+
sx={{ height: 28, width: 28, borderRadius: 50 }}
|
|
140
128
|
>
|
|
141
|
-
<
|
|
142
|
-
</
|
|
129
|
+
<Remove fontSize="small" />
|
|
130
|
+
</Button>
|
|
143
131
|
</FlexBox>
|
|
144
132
|
);
|
|
145
133
|
};
|
|
146
134
|
|
|
135
|
+
MiniCartItem.ProductImage = () => {
|
|
136
|
+
const ctx = useContext(MiniCartItemContext);
|
|
137
|
+
if (!ctx) return null;
|
|
138
|
+
const { item, closeDrawer } = ctx;
|
|
139
|
+
return (
|
|
140
|
+
<Link
|
|
141
|
+
href={item?.Product ? getProductDetailUrl(item?.Product) : ""}
|
|
142
|
+
onClick={closeDrawer}
|
|
143
|
+
>
|
|
144
|
+
<Avatar
|
|
145
|
+
alt={item?.Product?.Name}
|
|
146
|
+
src={item?.Product?.PrimaryImageUrl}
|
|
147
|
+
sx={{ mx: 1, width: 75, height: 75 }}
|
|
148
|
+
/>
|
|
149
|
+
</Link>
|
|
150
|
+
);
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
MiniCartItem.ProductDetails = () => {
|
|
154
|
+
const { number } = useFormatter();
|
|
155
|
+
const currency = (value: number) =>
|
|
156
|
+
number(value, { style: "currency", currency: "USD" });
|
|
157
|
+
|
|
158
|
+
const ctx = useContext(MiniCartItemContext);
|
|
159
|
+
if (!ctx) return null;
|
|
160
|
+
const { item, closeDrawer } = ctx;
|
|
161
|
+
const quantity = item?.Quantity || 0;
|
|
162
|
+
|
|
163
|
+
return (
|
|
164
|
+
<Box flex="1" textOverflow="ellipsis" whiteSpace="nowrap" overflow="hidden">
|
|
165
|
+
<Link
|
|
166
|
+
href={item?.Product ? getProductDetailUrl(item?.Product) : ""}
|
|
167
|
+
onClick={closeDrawer}
|
|
168
|
+
>
|
|
169
|
+
<H6 ellipsis className="title">
|
|
170
|
+
{item?.Product?.Name}
|
|
171
|
+
</H6>
|
|
172
|
+
</Link>
|
|
173
|
+
<H6 color="grey.600" mt={0.5}>
|
|
174
|
+
{item?.Product?.Dimensions?.map((d, i) => (
|
|
175
|
+
<span key={i}>{d?.DimensionValue?.Value + " "}</span>
|
|
176
|
+
))}
|
|
177
|
+
</H6>
|
|
178
|
+
<Tiny color="grey.600">
|
|
179
|
+
{currency(item?.Price || 0)} x {quantity}
|
|
180
|
+
</Tiny>
|
|
181
|
+
<H6 color="primary.main" mt={0.5}>
|
|
182
|
+
{currency(item?.TotalAmount || 0)}
|
|
183
|
+
</H6>
|
|
184
|
+
</Box>
|
|
185
|
+
);
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
MiniCartItem.RemoveButton = () => {
|
|
189
|
+
const ctx = useContext(MiniCartItemContext);
|
|
190
|
+
if (!ctx) return null;
|
|
191
|
+
const { item, handleCartAmountChange } = ctx;
|
|
192
|
+
const t = useTranslations("Cart.CartLine");
|
|
193
|
+
return (
|
|
194
|
+
<IconButton
|
|
195
|
+
size="small"
|
|
196
|
+
onClick={() => handleCartAmountChange({ ...item, Quantity: 0 })}
|
|
197
|
+
sx={{ marginLeft: 2.5 }}
|
|
198
|
+
title={t("removeItem")}
|
|
199
|
+
>
|
|
200
|
+
<Close fontSize="small" />
|
|
201
|
+
</IconButton>
|
|
202
|
+
);
|
|
203
|
+
};
|
|
204
|
+
|
|
147
205
|
export default MiniCartItem;
|
|
@@ -1,29 +1,69 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React, { createContext, useContext } from "react";
|
|
2
4
|
import { FlexBox } from "@evenicanpm/storefront-core/src/components-v2/flex-box/index";
|
|
3
5
|
import { Paragraph } from "@evenicanpm/storefront-core/src/components-v2/Typography";
|
|
4
6
|
import { useTranslations } from "next-intl";
|
|
7
|
+
import { MdShoppingBag as ShoppingBagIcon } from "react-icons/md";
|
|
8
|
+
|
|
9
|
+
interface EmptyCartContextValue {
|
|
10
|
+
message: string;
|
|
11
|
+
}
|
|
5
12
|
|
|
6
|
-
|
|
13
|
+
const EmptyCartContext = createContext<EmptyCartContextValue | null>(null);
|
|
7
14
|
|
|
8
|
-
export
|
|
15
|
+
export interface EmptyCartProps {
|
|
16
|
+
message?: string;
|
|
17
|
+
children: React.ReactNode;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const EmptyCart = ({ message, children }: EmptyCartProps) => {
|
|
9
21
|
const t = useTranslations("Cart");
|
|
10
22
|
return (
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
flexDirection="column"
|
|
14
|
-
justifyContent="center"
|
|
15
|
-
height="calc(100% - 74px)"
|
|
23
|
+
<EmptyCartContext.Provider
|
|
24
|
+
value={{ message: message || t("emptyCartMsg") }}
|
|
16
25
|
>
|
|
17
|
-
<
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
textAlign="center"
|
|
23
|
-
maxWidth={200}
|
|
26
|
+
<FlexBox
|
|
27
|
+
alignItems="center"
|
|
28
|
+
flexDirection="column"
|
|
29
|
+
justifyContent="center"
|
|
30
|
+
height="calc(100% - 74px)"
|
|
24
31
|
>
|
|
25
|
-
{
|
|
26
|
-
</
|
|
27
|
-
</
|
|
32
|
+
{children}
|
|
33
|
+
</FlexBox>
|
|
34
|
+
</EmptyCartContext.Provider>
|
|
28
35
|
);
|
|
29
|
-
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/* ---------- Subcomponents ---------- */
|
|
39
|
+
|
|
40
|
+
EmptyCart.Icon = ({ size = "3rem" }: { size?: string }) => {
|
|
41
|
+
return <ShoppingBagIcon style={{ fontSize: size }} />;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
EmptyCart.Message = ({
|
|
45
|
+
fontSize = 15,
|
|
46
|
+
color = "grey.600",
|
|
47
|
+
maxWidth = 200,
|
|
48
|
+
}: {
|
|
49
|
+
fontSize?: number;
|
|
50
|
+
color?: string;
|
|
51
|
+
maxWidth?: number;
|
|
52
|
+
}) => {
|
|
53
|
+
const ctx = useContext(EmptyCartContext);
|
|
54
|
+
if (!ctx) return null;
|
|
55
|
+
const { message } = ctx;
|
|
56
|
+
return (
|
|
57
|
+
<Paragraph
|
|
58
|
+
fontSize={fontSize}
|
|
59
|
+
mt={2}
|
|
60
|
+
color={color}
|
|
61
|
+
textAlign="center"
|
|
62
|
+
maxWidth={maxWidth}
|
|
63
|
+
>
|
|
64
|
+
{message}
|
|
65
|
+
</Paragraph>
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export default EmptyCart;
|
|
@@ -1,37 +1,76 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React, { createContext, useContext } from "react";
|
|
1
4
|
import IconButton from "@mui/material/IconButton";
|
|
2
|
-
import
|
|
3
|
-
// LOCAL CUSTOM COMPONENTS
|
|
5
|
+
import ClearIcon from "@mui/icons-material/Clear";
|
|
4
6
|
import { Paragraph } from "@evenicanpm/storefront-core/src/components-v2/Typography";
|
|
5
7
|
import {
|
|
6
8
|
FlexBetween,
|
|
7
9
|
FlexBox,
|
|
8
10
|
} from "@evenicanpm/storefront-core/src/components-v2/flex-box/index";
|
|
9
|
-
|
|
10
|
-
import { MdOutlineShoppingBag as CartBag } from "react-icons/md";
|
|
11
|
+
import { MdOutlineShoppingBag as CartBagIcon } from "react-icons/md";
|
|
11
12
|
import { useTranslations } from "next-intl";
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
interface Props {
|
|
14
|
+
interface TopHeaderContextValue {
|
|
15
15
|
total: number;
|
|
16
16
|
toggle: () => void;
|
|
17
17
|
}
|
|
18
|
-
// ==============================================================
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
const TopHeaderContext = createContext<TopHeaderContextValue | null>(null);
|
|
20
|
+
|
|
21
|
+
export interface TopHeaderProps {
|
|
22
|
+
total: number;
|
|
23
|
+
toggle: () => void;
|
|
24
|
+
children: React.ReactNode;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const TopHeader = ({ total, toggle, children }: TopHeaderProps) => {
|
|
28
|
+
return (
|
|
29
|
+
<TopHeaderContext.Provider value={{ total, toggle }}>
|
|
30
|
+
<FlexBetween mx={3} height={74}>
|
|
31
|
+
{children}
|
|
32
|
+
</FlexBetween>
|
|
33
|
+
</TopHeaderContext.Provider>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/* ---------- Subcomponents ---------- */
|
|
38
|
+
|
|
39
|
+
TopHeader.Heading = ({
|
|
40
|
+
icon = <CartBagIcon color="inherit" />,
|
|
41
|
+
}: {
|
|
42
|
+
icon?: React.ReactNode;
|
|
43
|
+
}) => {
|
|
44
|
+
const ctx = useContext(TopHeaderContext);
|
|
45
|
+
if (!ctx) return null;
|
|
46
|
+
const { total } = ctx;
|
|
21
47
|
const t = useTranslations("Cart");
|
|
48
|
+
|
|
22
49
|
return (
|
|
23
|
-
<
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
</Paragraph>
|
|
30
|
-
</FlexBox>
|
|
31
|
-
|
|
32
|
-
<IconButton onClick={toggle} title={t("closeMiniCart")}>
|
|
33
|
-
<Clear />
|
|
34
|
-
</IconButton>
|
|
35
|
-
</FlexBetween>
|
|
50
|
+
<FlexBox gap={1} alignItems="center" color="secondary.main">
|
|
51
|
+
{icon}
|
|
52
|
+
<Paragraph lineHeight={0} fontWeight={600}>
|
|
53
|
+
{t("count", { count: total })}
|
|
54
|
+
</Paragraph>
|
|
55
|
+
</FlexBox>
|
|
36
56
|
);
|
|
37
|
-
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
TopHeader.CloseButton = ({
|
|
60
|
+
icon = <ClearIcon />,
|
|
61
|
+
}: {
|
|
62
|
+
icon?: React.ReactNode;
|
|
63
|
+
}) => {
|
|
64
|
+
const ctx = useContext(TopHeaderContext);
|
|
65
|
+
if (!ctx) return null;
|
|
66
|
+
const { toggle } = ctx;
|
|
67
|
+
const t = useTranslations("Cart");
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<IconButton onClick={toggle} title={t("closeMiniCart")}>
|
|
71
|
+
{icon}
|
|
72
|
+
</IconButton>
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export default TopHeader;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React, { useState, useContext, createContext } from "react";
|
|
4
|
+
import { Badge, Drawer, IconButton } from "@mui/material";
|
|
5
|
+
import { Cart } from "@/schemas/cart.schema";
|
|
6
|
+
import { useNotification } from "@evenicanpm/storefront-core/src/providers/notifications/use-notification";
|
|
7
|
+
import { MiniCart } from "@evenicanpm/storefront-core/src/components-v2/mini-cart/index";
|
|
8
|
+
|
|
9
|
+
const BADGE_STYLES = {
|
|
10
|
+
"& .MuiBadge-badge": {
|
|
11
|
+
fontSize: { xs: "0.625rem", md: "0.75rem" }, // ~10px, 12px
|
|
12
|
+
minWidth: { xs: "1rem", md: "1.25rem" }, // ~16px, 20px
|
|
13
|
+
height: { xs: "1rem", md: "1.25rem" }, // ~16px, 20px
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const ICON_BUTTON_STYLES = {
|
|
18
|
+
minWidth: { xs: "2.25rem", md: "2.5rem" }, // 36px, 40px
|
|
19
|
+
minHeight: { xs: "2.25rem", md: "2.5rem" },
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
interface MiniCartTriggerContextValue {
|
|
23
|
+
cart: Cart;
|
|
24
|
+
open: boolean;
|
|
25
|
+
setOpen: (open: boolean) => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const MiniCartTriggerContext =
|
|
29
|
+
createContext<MiniCartTriggerContextValue | null>(null);
|
|
30
|
+
|
|
31
|
+
interface MiniCartTriggerProps {
|
|
32
|
+
cart: Cart;
|
|
33
|
+
children: React.ReactNode;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const MiniCartTrigger = ({ cart, children }: MiniCartTriggerProps) => {
|
|
37
|
+
const [open, setOpen] = useState(false);
|
|
38
|
+
const { alert } = useNotification();
|
|
39
|
+
|
|
40
|
+
const SHOULD_OPEN_MINICART_ON_ADD = true; // Move to config
|
|
41
|
+
|
|
42
|
+
React.useEffect(() => {
|
|
43
|
+
if (alert?.type === "cart" && SHOULD_OPEN_MINICART_ON_ADD) {
|
|
44
|
+
setOpen(true);
|
|
45
|
+
}
|
|
46
|
+
}, [alert, SHOULD_OPEN_MINICART_ON_ADD]);
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<MiniCartTriggerContext.Provider value={{ cart, open, setOpen }}>
|
|
50
|
+
{children}
|
|
51
|
+
</MiniCartTriggerContext.Provider>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/* ---------- Subcomponents ---------- */
|
|
56
|
+
|
|
57
|
+
MiniCartTrigger.Badge = ({ children }: { children: React.ReactNode }) => {
|
|
58
|
+
const ctx = useContext(MiniCartTriggerContext);
|
|
59
|
+
if (!ctx) return null;
|
|
60
|
+
const { cart } = ctx;
|
|
61
|
+
return (
|
|
62
|
+
<Badge
|
|
63
|
+
badgeContent={cart?.TotalItems || 0}
|
|
64
|
+
color="primary"
|
|
65
|
+
sx={BADGE_STYLES}
|
|
66
|
+
>
|
|
67
|
+
{children}
|
|
68
|
+
</Badge>
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
MiniCartTrigger.Button = ({ children }: { children: React.ReactNode }) => {
|
|
73
|
+
const ctx = useContext(MiniCartTriggerContext);
|
|
74
|
+
if (!ctx) return null;
|
|
75
|
+
const { setOpen } = ctx;
|
|
76
|
+
return (
|
|
77
|
+
<IconButton sx={ICON_BUTTON_STYLES} onClick={() => setOpen(true)}>
|
|
78
|
+
{children}
|
|
79
|
+
</IconButton>
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
MiniCartTrigger.Drawer = () => {
|
|
84
|
+
const ctx = useContext(MiniCartTriggerContext);
|
|
85
|
+
if (!ctx) return null;
|
|
86
|
+
const { cart, open, setOpen } = ctx;
|
|
87
|
+
return (
|
|
88
|
+
<Drawer anchor="right" open={open} onClose={() => setOpen(false)}>
|
|
89
|
+
<MiniCart cart={cart} closeDrawer={() => setOpen(false)}>
|
|
90
|
+
<MiniCart.Header />
|
|
91
|
+
<MiniCart.Divider />
|
|
92
|
+
<MiniCart.Items />
|
|
93
|
+
<MiniCart.Actions />
|
|
94
|
+
</MiniCart>
|
|
95
|
+
</Drawer>
|
|
96
|
+
);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export default MiniCartTrigger;
|