@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,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import React, {
|
|
3
|
+
import React, {
|
|
4
|
+
createContext,
|
|
5
|
+
useState,
|
|
6
|
+
useEffect,
|
|
7
|
+
useContext,
|
|
8
|
+
MouseEvent,
|
|
9
|
+
ReactNode,
|
|
10
|
+
} from "react";
|
|
4
11
|
import { useRouter } from "next/navigation";
|
|
5
|
-
|
|
6
|
-
// API
|
|
7
|
-
import useUpdateUser from "@/services/user/mutations/update-user";
|
|
8
|
-
import useSessionInit from "@/services/session/mutations/session-init";
|
|
9
|
-
import useSessionLogout from "@/services/session/mutations/session-logout";
|
|
10
|
-
|
|
11
|
-
// UI
|
|
12
|
+
// UI Components
|
|
12
13
|
import {
|
|
13
14
|
Box,
|
|
14
15
|
Button,
|
|
@@ -19,13 +20,16 @@ import {
|
|
|
19
20
|
} from "@mui/material";
|
|
20
21
|
import { MdPersonOutline as PersonOutline } from "react-icons/md";
|
|
21
22
|
import MobileUserIcon from "@evenicanpm/storefront-core/src/components-v2/icons/user";
|
|
22
|
-
import { NavLink } from "@evenicanpm/storefront-core/src/components-v2/nav-link
|
|
23
|
+
import { NavLink } from "@evenicanpm/storefront-core/src/components-v2/nav-link";
|
|
23
24
|
import T from "@evenicanpm/storefront-core/src/components-v2/T";
|
|
24
|
-
|
|
25
|
-
// Auth
|
|
25
|
+
// Auth components
|
|
26
26
|
import { signIn, useSession } from "next-auth/react";
|
|
27
27
|
import { getMsalInstance, initializeMsal } from "@/auth/msal";
|
|
28
|
-
import
|
|
28
|
+
import signOutCustom from "@/auth/signout";
|
|
29
|
+
// API hooks
|
|
30
|
+
import useUpdateUser from "@/services/user/mutations/update-user";
|
|
31
|
+
import useSessionInit from "@/services/session/mutations/session-init";
|
|
32
|
+
import useSessionLogout from "@/services/session/mutations/session-logout";
|
|
29
33
|
|
|
30
34
|
interface IdTokenClaims {
|
|
31
35
|
given_name?: string;
|
|
@@ -39,35 +43,51 @@ const MENU_ITEMS = [
|
|
|
39
43
|
{ href: "/account/wish-lists", label: "Account.Menu.wishlists" },
|
|
40
44
|
];
|
|
41
45
|
|
|
46
|
+
interface UserContextValue {
|
|
47
|
+
isAuthenticated: boolean;
|
|
48
|
+
status: string;
|
|
49
|
+
menuItems: typeof MENU_ITEMS;
|
|
50
|
+
handleLogout: () => void;
|
|
51
|
+
signIn: typeof signIn;
|
|
52
|
+
signOut: () => void;
|
|
53
|
+
anchorEl: HTMLButtonElement | null;
|
|
54
|
+
setAnchorEl: (el: HTMLButtonElement | null) => void;
|
|
55
|
+
open: boolean;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const UserContext = createContext<UserContextValue | undefined>(undefined);
|
|
59
|
+
|
|
60
|
+
const useUserContext = () => {
|
|
61
|
+
const ctx = useContext(UserContext);
|
|
62
|
+
if (!ctx) throw new Error("User subcomponent must be used within <User>");
|
|
63
|
+
return ctx;
|
|
64
|
+
};
|
|
65
|
+
|
|
42
66
|
interface Props {
|
|
43
|
-
|
|
67
|
+
children?: ReactNode;
|
|
44
68
|
}
|
|
45
|
-
|
|
69
|
+
|
|
70
|
+
const User = ({ children }: Props) => {
|
|
46
71
|
const { data: session, status } = useSession();
|
|
47
72
|
|
|
48
73
|
if (session?.error) {
|
|
49
74
|
// Custom error set in server - /api/auth/[...nextauth]
|
|
50
75
|
console.warn("Auth Error", session?.error);
|
|
51
|
-
|
|
76
|
+
signOutCustom();
|
|
52
77
|
}
|
|
53
78
|
|
|
54
79
|
const isAuthenticated = !!session;
|
|
55
|
-
|
|
56
|
-
const router = useRouter();
|
|
57
|
-
|
|
58
80
|
const { mutateAsync: sessionInit } = useSessionInit();
|
|
59
81
|
const { mutateAsync: updateUser } = useUpdateUser();
|
|
60
82
|
const { mutateAsync: sessionLogout } = useSessionLogout();
|
|
61
83
|
|
|
84
|
+
// session init
|
|
62
85
|
useEffect(() => {
|
|
63
86
|
if (isAuthenticated) {
|
|
64
87
|
const { accessToken, user } = session;
|
|
65
88
|
const email = user?.email;
|
|
66
89
|
if (accessToken && email) {
|
|
67
|
-
sessionInit({
|
|
68
|
-
accessToken,
|
|
69
|
-
email,
|
|
70
|
-
});
|
|
90
|
+
sessionInit({ accessToken, email });
|
|
71
91
|
}
|
|
72
92
|
}
|
|
73
93
|
}, [isAuthenticated, session, sessionInit]);
|
|
@@ -77,127 +97,153 @@ const User = ({ mobile = false }: Props) => {
|
|
|
77
97
|
const handleRedirect = async () => {
|
|
78
98
|
try {
|
|
79
99
|
await initializeMsal();
|
|
80
|
-
const
|
|
81
|
-
if (
|
|
82
|
-
// Update the API when profile info is updated through MSAL
|
|
100
|
+
const res = await getMsalInstance().handleRedirectPromise();
|
|
101
|
+
if (res) {
|
|
83
102
|
const { given_name, family_name } =
|
|
84
|
-
|
|
103
|
+
res.idTokenClaims as IdTokenClaims;
|
|
104
|
+
// Update the API when profile info is updated through MSAL
|
|
85
105
|
if (given_name && family_name) {
|
|
86
106
|
updateUser({
|
|
87
107
|
AccountNumber: "",
|
|
88
108
|
FirstName: given_name,
|
|
89
109
|
LastName: family_name,
|
|
90
|
-
}).catch(
|
|
110
|
+
}).catch(console.error);
|
|
91
111
|
}
|
|
92
112
|
}
|
|
93
|
-
} catch (
|
|
94
|
-
console.error("MSAL
|
|
113
|
+
} catch (err) {
|
|
114
|
+
console.error("MSAL redirect error:", err);
|
|
95
115
|
}
|
|
96
116
|
};
|
|
97
|
-
|
|
98
117
|
handleRedirect();
|
|
99
118
|
}, [updateUser]);
|
|
100
119
|
|
|
101
120
|
const handleLogout = async () => {
|
|
102
121
|
try {
|
|
103
122
|
await sessionLogout({});
|
|
104
|
-
|
|
105
|
-
} catch (
|
|
106
|
-
console.error("Logout Error:",
|
|
123
|
+
signOutCustom();
|
|
124
|
+
} catch (err) {
|
|
125
|
+
console.error("Logout Error:", err);
|
|
107
126
|
}
|
|
108
127
|
};
|
|
109
128
|
|
|
110
129
|
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null);
|
|
111
|
-
|
|
112
130
|
const open = Boolean(anchorEl);
|
|
113
|
-
const id = open ? "account-popover" : undefined;
|
|
114
131
|
|
|
115
|
-
const
|
|
132
|
+
const value: UserContextValue = {
|
|
133
|
+
isAuthenticated,
|
|
134
|
+
status,
|
|
135
|
+
menuItems: MENU_ITEMS,
|
|
136
|
+
handleLogout,
|
|
137
|
+
signIn,
|
|
138
|
+
signOut: signOutCustom,
|
|
139
|
+
anchorEl,
|
|
140
|
+
setAnchorEl,
|
|
141
|
+
open,
|
|
142
|
+
};
|
|
116
143
|
|
|
117
|
-
if (status === "loading") return
|
|
144
|
+
if (status === "loading") return null;
|
|
118
145
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
146
|
+
return <UserContext.Provider value={value}>{children}</UserContext.Provider>;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// Subcomponents
|
|
150
|
+
User.MobileTrigger = function MobileTrigger() {
|
|
151
|
+
const { isAuthenticated, signIn } = useUserContext();
|
|
152
|
+
const router = useRouter();
|
|
153
|
+
return (
|
|
154
|
+
<IconButton
|
|
155
|
+
aria-label="User Menu"
|
|
156
|
+
onClick={() => {
|
|
157
|
+
if (!isAuthenticated) signIn();
|
|
158
|
+
else router.push("/account/profile");
|
|
159
|
+
}}
|
|
160
|
+
>
|
|
161
|
+
<MobileUserIcon style={{ fontSize: "1.25rem" }} />
|
|
162
|
+
</IconButton>
|
|
163
|
+
);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
User.DesktopTrigger = function DesktopTrigger() {
|
|
167
|
+
const { setAnchorEl } = useUserContext();
|
|
168
|
+
return (
|
|
169
|
+
<IconButton
|
|
170
|
+
aria-label="User Menu"
|
|
171
|
+
onClick={(e: MouseEvent<HTMLButtonElement>) =>
|
|
172
|
+
setAnchorEl(e.currentTarget)
|
|
173
|
+
}
|
|
174
|
+
>
|
|
175
|
+
<PersonOutline />
|
|
176
|
+
</IconButton>
|
|
177
|
+
);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
User.Menu = function Menu({
|
|
181
|
+
children,
|
|
182
|
+
}: {
|
|
183
|
+
children?: (items: typeof MENU_ITEMS) => React.ReactNode;
|
|
184
|
+
}) {
|
|
185
|
+
const { anchorEl, open, setAnchorEl, menuItems, handleLogout } =
|
|
186
|
+
useUserContext();
|
|
187
|
+
const id = open ? "account-popover" : undefined;
|
|
188
|
+
|
|
189
|
+
return (
|
|
190
|
+
<Popover
|
|
191
|
+
id={id}
|
|
192
|
+
open={open}
|
|
193
|
+
anchorEl={anchorEl}
|
|
194
|
+
onClose={() => setAnchorEl(null)}
|
|
195
|
+
anchorOrigin={{ vertical: "bottom", horizontal: "right" }}
|
|
196
|
+
transformOrigin={{ vertical: "top", horizontal: "right" }}
|
|
197
|
+
>
|
|
198
|
+
<List sx={{ p: 1 }} onClick={() => setAnchorEl(null)}>
|
|
199
|
+
{children
|
|
200
|
+
? children(menuItems) // Allow caller to control what gets rendered
|
|
201
|
+
: menuItems.map(({ href, label }) => (
|
|
202
|
+
<User.MenuItem key={href} href={href} label={label} />
|
|
203
|
+
))}
|
|
204
|
+
<Box p={1}>
|
|
205
|
+
<Button
|
|
206
|
+
fullWidth
|
|
207
|
+
size="small"
|
|
208
|
+
color="primary"
|
|
209
|
+
variant="outlined"
|
|
210
|
+
onClick={handleLogout}
|
|
211
|
+
>
|
|
212
|
+
<T path="Account.Menu.btnLogout" />
|
|
213
|
+
</Button>
|
|
214
|
+
</Box>
|
|
215
|
+
</List>
|
|
216
|
+
</Popover>
|
|
217
|
+
);
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
User.MenuItem = function MenuItem({
|
|
221
|
+
href,
|
|
222
|
+
label,
|
|
223
|
+
}: {
|
|
224
|
+
href: string;
|
|
225
|
+
label: string;
|
|
226
|
+
}) {
|
|
227
|
+
return (
|
|
228
|
+
<NavLink href={href} style={{ color: "inherit" }}>
|
|
229
|
+
<ListItemButton>
|
|
230
|
+
<T path={label} />
|
|
231
|
+
</ListItemButton>
|
|
232
|
+
</NavLink>
|
|
233
|
+
);
|
|
234
|
+
};
|
|
135
235
|
|
|
236
|
+
User.LoginButton = function LoginButton() {
|
|
237
|
+
const { signIn } = useUserContext();
|
|
136
238
|
return (
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
>
|
|
147
|
-
<PersonOutline />
|
|
148
|
-
</IconButton>
|
|
149
|
-
<Popover
|
|
150
|
-
id={id}
|
|
151
|
-
open={open}
|
|
152
|
-
anchorEl={anchorEl}
|
|
153
|
-
anchorOrigin={{ vertical: "bottom", horizontal: "right" }}
|
|
154
|
-
transformOrigin={{
|
|
155
|
-
vertical: "top",
|
|
156
|
-
horizontal: "right",
|
|
157
|
-
}}
|
|
158
|
-
onClose={() => setAnchorElNull()}
|
|
159
|
-
>
|
|
160
|
-
<List
|
|
161
|
-
component="nav"
|
|
162
|
-
aria-label="mailbox folders"
|
|
163
|
-
disablePadding
|
|
164
|
-
onClick={() => setAnchorElNull()}
|
|
165
|
-
sx={{ p: 1 }}
|
|
166
|
-
>
|
|
167
|
-
{MENU_ITEMS.map(({ href, label }) => (
|
|
168
|
-
<NavLink key={href} href={href} style={{ color: "inherit" }}>
|
|
169
|
-
<ListItemButton>
|
|
170
|
-
<T path={label} />
|
|
171
|
-
</ListItemButton>
|
|
172
|
-
</NavLink>
|
|
173
|
-
))}
|
|
174
|
-
<Box p={1}>
|
|
175
|
-
<Button
|
|
176
|
-
fullWidth
|
|
177
|
-
size="small"
|
|
178
|
-
color="primary"
|
|
179
|
-
variant="outlined"
|
|
180
|
-
onClick={() => handleLogout()}
|
|
181
|
-
>
|
|
182
|
-
<T path="Account.Menu.btnLogout" />
|
|
183
|
-
</Button>
|
|
184
|
-
</Box>
|
|
185
|
-
</List>
|
|
186
|
-
</Popover>
|
|
187
|
-
</Box>
|
|
188
|
-
</>
|
|
189
|
-
) : (
|
|
190
|
-
<Button
|
|
191
|
-
size="small"
|
|
192
|
-
variant="contained"
|
|
193
|
-
color="primary"
|
|
194
|
-
onClick={() => signIn()}
|
|
195
|
-
sx={{ mr: 2 }}
|
|
196
|
-
>
|
|
197
|
-
<T path="Account.Menu.btnLogin" />
|
|
198
|
-
</Button>
|
|
199
|
-
)}
|
|
200
|
-
</>
|
|
239
|
+
<Button
|
|
240
|
+
size="small"
|
|
241
|
+
variant="contained"
|
|
242
|
+
color="primary"
|
|
243
|
+
onClick={() => signIn()}
|
|
244
|
+
>
|
|
245
|
+
<T path="Account.Menu.btnLogin" />
|
|
246
|
+
</Button>
|
|
201
247
|
);
|
|
202
248
|
};
|
|
203
249
|
|
|
@@ -1,63 +1,83 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import useTheme from "@mui/material/styles/useTheme";
|
|
5
|
-
import useMediaQuery from "@mui/material/useMediaQuery";
|
|
3
|
+
import { ReactNode } from "react";
|
|
6
4
|
import clsx from "clsx";
|
|
5
|
+
import { MdOutlineShoppingBag } from "react-icons/md";
|
|
7
6
|
// GLOBAL CUSTOM COMPONENTS
|
|
8
7
|
import FlexBox from "@evenicanpm/storefront-core/src/components-v2/flex-box/flex-box";
|
|
9
8
|
import SiteLogo from "@evenicanpm/storefront-core/src/components-v2/site-logo";
|
|
10
9
|
// LOCAL CUSTOM COMPONENTS
|
|
11
|
-
import MobileHeader from "./components/mobile-header";
|
|
12
10
|
import CategoriesMenu from "./components/categories-menu";
|
|
13
11
|
import User from "./components/user";
|
|
14
|
-
import
|
|
12
|
+
import MiniCartTrigger from "../mini-cart/mini-cart-trigger";
|
|
15
13
|
// STYLED COMPONENTS
|
|
16
14
|
import { HeaderWrapper, StyledContainer } from "./styles/index";
|
|
17
15
|
// API
|
|
18
16
|
import getCart from "@/api-manager/services/cart/queries/get-cart";
|
|
19
|
-
import { Cart } from "@/schemas/cart.schema";
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
interface Props {
|
|
23
|
-
isFixed?: boolean;
|
|
24
|
-
className?: string;
|
|
25
|
-
midSlot: ReactNode;
|
|
26
|
-
}
|
|
27
|
-
// ==============================================================
|
|
18
|
+
import { useSession } from "next-auth/react";
|
|
28
19
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
type HeaderRootProps = {
|
|
21
|
+
className?: string;
|
|
22
|
+
children: ReactNode;
|
|
23
|
+
};
|
|
32
24
|
|
|
33
|
-
|
|
25
|
+
const Header = ({ className, children }: HeaderRootProps) => {
|
|
26
|
+
return (
|
|
27
|
+
<HeaderWrapper className={clsx(className)}>
|
|
28
|
+
<StyledContainer>{children}</StyledContainer>
|
|
29
|
+
</HeaderWrapper>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
34
32
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
{isFixed ? <CategoriesMenu /> : null}
|
|
41
|
-
</FlexBox>
|
|
42
|
-
|
|
43
|
-
{/* Center content - search form | navigation */}
|
|
44
|
-
{midSlot}
|
|
45
|
-
|
|
46
|
-
{/* login / account and cart buttons */}
|
|
47
|
-
<User />
|
|
48
|
-
{cart && <MiniCartClient cart={cart} />}
|
|
49
|
-
</Fragment>
|
|
33
|
+
Header.LeftSlot = ({ children }: { children: ReactNode }) => {
|
|
34
|
+
return (
|
|
35
|
+
<FlexBox minWidth={100} alignItems="center">
|
|
36
|
+
{children}
|
|
37
|
+
</FlexBox>
|
|
50
38
|
);
|
|
39
|
+
};
|
|
40
|
+
Header.Logo = () => {
|
|
41
|
+
return <SiteLogo />;
|
|
42
|
+
};
|
|
51
43
|
|
|
44
|
+
Header.Categories = () => {
|
|
45
|
+
return <CategoriesMenu />;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
Header.MidSlot = ({ children }: { children: ReactNode }) => {
|
|
49
|
+
return <>{children}</>;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
Header.User = () => {
|
|
53
|
+
const { data: session } = useSession();
|
|
54
|
+
const isAuthenticated = !!session;
|
|
52
55
|
return (
|
|
53
|
-
<
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
<
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
<User>
|
|
57
|
+
{isAuthenticated ? (
|
|
58
|
+
<>
|
|
59
|
+
<User.DesktopTrigger />
|
|
60
|
+
<User.Menu />
|
|
61
|
+
</>
|
|
62
|
+
) : (
|
|
63
|
+
<User.LoginButton />
|
|
64
|
+
)}
|
|
65
|
+
</User>
|
|
62
66
|
);
|
|
63
|
-
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
Header.Cart = () => {
|
|
70
|
+
const { data: cart } = getCart.useData();
|
|
71
|
+
return cart ? (
|
|
72
|
+
<MiniCartTrigger cart={cart}>
|
|
73
|
+
<MiniCartTrigger.Badge>
|
|
74
|
+
<MiniCartTrigger.Button>
|
|
75
|
+
<MdOutlineShoppingBag />
|
|
76
|
+
</MiniCartTrigger.Button>
|
|
77
|
+
</MiniCartTrigger.Badge>
|
|
78
|
+
<MiniCartTrigger.Drawer />
|
|
79
|
+
</MiniCartTrigger>
|
|
80
|
+
) : null;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export default Header;
|
|
@@ -1,17 +1,49 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import Header from "@evenicanpm/storefront-core/src/components-v2/header/index";
|
|
4
|
-
import
|
|
4
|
+
import { SearchBarViewLg as SearchBar } from "@evenicanpm/storefront-core/src/components-v2/search-bar";
|
|
5
5
|
import Sticky from "@evenicanpm/storefront-core/src/components-v2/sticky/index";
|
|
6
6
|
import { useCallback, useState } from "react";
|
|
7
7
|
|
|
8
|
+
import useTheme from "@mui/material/styles/useTheme";
|
|
9
|
+
import useMediaQuery from "@mui/material/useMediaQuery";
|
|
10
|
+
import MobileHeader from "./components/mobile-header";
|
|
11
|
+
|
|
8
12
|
export default function StickyHeader() {
|
|
9
13
|
const [isFixed, setIsFixed] = useState(false);
|
|
10
14
|
const toggleIsFixed = useCallback((fixed: boolean) => setIsFixed(fixed), []);
|
|
11
15
|
|
|
16
|
+
const theme = useTheme();
|
|
17
|
+
const downMd = useMediaQuery(theme.breakpoints.down(1150));
|
|
18
|
+
|
|
19
|
+
if (downMd) {
|
|
20
|
+
return (
|
|
21
|
+
<MobileHeader>
|
|
22
|
+
<MobileHeader.Menu />
|
|
23
|
+
<MobileHeader.Logo />
|
|
24
|
+
<MobileHeader.Icons>
|
|
25
|
+
<MobileHeader.Search />
|
|
26
|
+
<MobileHeader.User />
|
|
27
|
+
<MobileHeader.Cart />
|
|
28
|
+
</MobileHeader.Icons>
|
|
29
|
+
<MobileHeader.SearchDrawer />
|
|
30
|
+
</MobileHeader>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
12
34
|
return (
|
|
13
35
|
<Sticky fixedOn={0} onSticky={toggleIsFixed} scrollDistance={300}>
|
|
14
|
-
<Header
|
|
36
|
+
<Header>
|
|
37
|
+
<Header.LeftSlot>
|
|
38
|
+
<Header.Logo />
|
|
39
|
+
{isFixed && <Header.Categories />}
|
|
40
|
+
</Header.LeftSlot>
|
|
41
|
+
<Header.MidSlot>
|
|
42
|
+
<SearchBar />
|
|
43
|
+
</Header.MidSlot>
|
|
44
|
+
<Header.User />
|
|
45
|
+
<Header.Cart />
|
|
46
|
+
</Header>
|
|
15
47
|
</Sticky>
|
|
16
48
|
);
|
|
17
49
|
}
|
|
@@ -1,27 +1,81 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React, { createContext, useContext } from "react";
|
|
1
4
|
import Box from "@mui/material/Box";
|
|
2
|
-
import Button from "@mui/material/Button";
|
|
5
|
+
import Button, { ButtonProps } from "@mui/material/Button";
|
|
3
6
|
import { useTranslations } from "next-intl";
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
interface BottomActionsContextValue {
|
|
9
|
+
total: string;
|
|
10
|
+
handleNavigate: (path: string) => () => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const BottomActionsContext = createContext<BottomActionsContextValue | null>(
|
|
14
|
+
null,
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
export interface BottomActionsProps {
|
|
7
18
|
total: string;
|
|
8
19
|
handleNavigate: (path: string) => () => void;
|
|
20
|
+
children: React.ReactNode;
|
|
9
21
|
}
|
|
10
|
-
// ==============================================================
|
|
11
22
|
|
|
12
|
-
|
|
23
|
+
const BottomActions = ({
|
|
24
|
+
total,
|
|
25
|
+
handleNavigate,
|
|
26
|
+
children,
|
|
27
|
+
}: BottomActionsProps) => {
|
|
28
|
+
return (
|
|
29
|
+
<BottomActionsContext.Provider value={{ total, handleNavigate }}>
|
|
30
|
+
<Box p={2.5} display="flex" flexDirection="column" gap={1}>
|
|
31
|
+
{children}
|
|
32
|
+
</Box>
|
|
33
|
+
</BottomActionsContext.Provider>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/* ---------- Subcomponents ---------- */
|
|
38
|
+
|
|
39
|
+
BottomActions.ViewCartButton = function ViewCartButton(
|
|
40
|
+
props: Omit<ButtonProps, "onClick" | "children">,
|
|
41
|
+
) {
|
|
42
|
+
const ctx = useContext(BottomActionsContext);
|
|
43
|
+
if (!ctx) return null;
|
|
44
|
+
const { total, handleNavigate } = ctx;
|
|
13
45
|
const t = useTranslations("Cart");
|
|
14
46
|
return (
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
</Box>
|
|
47
|
+
<Button
|
|
48
|
+
fullWidth
|
|
49
|
+
color="primary"
|
|
50
|
+
variant="outlined"
|
|
51
|
+
sx={{ height: 40 }}
|
|
52
|
+
onClick={handleNavigate("/cart")}
|
|
53
|
+
{...props}
|
|
54
|
+
>
|
|
55
|
+
{t("viewCartBtn", { total })}
|
|
56
|
+
</Button>
|
|
26
57
|
);
|
|
27
|
-
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
BottomActions.CustomButton = function CustomButton({
|
|
61
|
+
path,
|
|
62
|
+
children,
|
|
63
|
+
...props
|
|
64
|
+
}: { path: string } & Omit<ButtonProps, "onClick">) {
|
|
65
|
+
const ctx = useContext(BottomActionsContext);
|
|
66
|
+
if (!ctx) return null;
|
|
67
|
+
const { handleNavigate } = ctx;
|
|
68
|
+
return (
|
|
69
|
+
<Button
|
|
70
|
+
fullWidth
|
|
71
|
+
variant="contained"
|
|
72
|
+
sx={{ height: 40 }}
|
|
73
|
+
onClick={handleNavigate(path)}
|
|
74
|
+
{...props}
|
|
75
|
+
>
|
|
76
|
+
{children}
|
|
77
|
+
</Button>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export default BottomActions;
|