diff --git a/packages/api-client/src/types/GraphQL.ts b/packages/api-client/src/types/GraphQL.ts index c4b78fc00..91f401bf7 100644 --- a/packages/api-client/src/types/GraphQL.ts +++ b/packages/api-client/src/types/GraphQL.ts @@ -660,13 +660,13 @@ export interface Cart { /** The entered gift message for the cart */ gift_message?: Maybe; /** The unique ID for a `Cart` object */ - id: Scalars['ID']; - is_virtual: Scalars['Boolean']; + id?: Maybe; + is_virtual: Maybe; items?: Maybe>>; prices?: Maybe; selected_payment_method?: Maybe; - shipping_addresses: Array>; - total_quantity: Scalars['Float']; + shipping_addresses?: Maybe>>; + total_quantity?: Maybe; } export interface CartAddressCountry { diff --git a/packages/composables/nuxt/plugin.js b/packages/composables/nuxt/plugin.js index 00a24f3f1..0a9fc943f 100644 --- a/packages/composables/nuxt/plugin.js +++ b/packages/composables/nuxt/plugin.js @@ -5,6 +5,7 @@ import cookie from '@vue-storefront/magento/nuxt/cookie'; const moduleOptions = JSON.parse('<%= JSON.stringify(options) %>'); +// TODO should be moved to THEME and expose consistent cookie management API export default integrationPlugin(({ app, res, req, integration }) => { const cartCookieName = moduleOptions.cookies?.cartCookieName || defaultConfig.cookies.cartCookieName; const customerCookieName = moduleOptions.cookies?.customerCookieName || defaultConfig.cookies.customerCookieName; diff --git a/packages/composables/src/composables/useCart/index.ts b/packages/composables/src/composables/useCart/index.ts index 414ff787d..34466777f 100644 --- a/packages/composables/src/composables/useCart/index.ts +++ b/packages/composables/src/composables/useCart/index.ts @@ -1,5 +1,6 @@ -/* istanbul ignore file */ -/* eslint-disable no-param-reassign */ +/** + * @deprecated since version 1.0.0 + */ import { ComposableFunctionArgs, Context, diff --git a/packages/composables/src/composables/useCategorySearch/index.ts b/packages/composables/src/composables/useCategorySearch/index.ts index f023ff9b8..146ab3ef7 100644 --- a/packages/composables/src/composables/useCategorySearch/index.ts +++ b/packages/composables/src/composables/useCategorySearch/index.ts @@ -5,6 +5,9 @@ import { Category, CategorySearchQueryVariables } from '@vue-storefront/magento- import { UseCategorySearchFactory, useCategorySearchFactory } from '../../factories/useCategorySearchFactory'; import { UseCategorySearch } from '../../types/composables'; +/** + * @deprecated since version 1.0.0 + */ const factoryParams: UseCategorySearchFactory = { search: async (context: Context, params): Promise => { Logger.debug('[Magento]: Search for category using', { params }); diff --git a/packages/composables/src/composables/useConfig/index.ts b/packages/composables/src/composables/useConfig/index.ts index 8e8af7a1b..6772402be 100644 --- a/packages/composables/src/composables/useConfig/index.ts +++ b/packages/composables/src/composables/useConfig/index.ts @@ -1,4 +1,7 @@ -import {Context, Logger} from '@vue-storefront/core'; +/** + * @deprecated since version 1.0.0 + */ +import { Context, Logger } from '@vue-storefront/core'; import { StoreConfig } from '@vue-storefront/magento-api'; import { useConfigFactory, UseConfigFactoryParams } from '../../factories/useConfigFactory'; import { UseConfig } from '../../types/composables'; diff --git a/packages/composables/src/composables/useContent/index.ts b/packages/composables/src/composables/useContent/index.ts index 2de6bb29c..e1fe69146 100644 --- a/packages/composables/src/composables/useContent/index.ts +++ b/packages/composables/src/composables/useContent/index.ts @@ -1,3 +1,6 @@ +/** + * @deprecated since version 1.0.0 + */ import { Context, Logger } from '@vue-storefront/core'; import { Page, CmsBlock } from '@vue-storefront/magento-api'; import { useContentFactory, UseContentFactoryParams } from '../../factories/useContentFactory'; diff --git a/packages/composables/src/composables/useCurrency/index.ts b/packages/composables/src/composables/useCurrency/index.ts index f117b04fe..e3016cd72 100644 --- a/packages/composables/src/composables/useCurrency/index.ts +++ b/packages/composables/src/composables/useCurrency/index.ts @@ -1,3 +1,6 @@ +/** + * @deprecated since version1.0.0 + */ import { Context } from '@vue-storefront/core'; import { Currency } from '@vue-storefront/magento-api'; import { useCurrencyFactory, UseCurrencyFactoryParams } from '../../factories/useCurrencyFactory'; diff --git a/packages/composables/src/composables/useExternalCheckout/index.ts b/packages/composables/src/composables/useExternalCheckout/index.ts index f96c4b6b8..a96a215ac 100644 --- a/packages/composables/src/composables/useExternalCheckout/index.ts +++ b/packages/composables/src/composables/useExternalCheckout/index.ts @@ -3,6 +3,9 @@ import { useExternalCheckoutFactory, UseExternalCheckoutFactoryParams } from '.. import useCart from '../useCart'; // import useConfig from '../useConfig'; +/** + * @deprecated since version1.0.0 + */ const factoryParams: UseExternalCheckoutFactoryParams = { provide() { return { diff --git a/packages/composables/src/composables/useFacet/_utils.ts b/packages/composables/src/composables/useFacet/_utils.ts index 83a4441e4..9d8297f2a 100644 --- a/packages/composables/src/composables/useFacet/_utils.ts +++ b/packages/composables/src/composables/useFacet/_utils.ts @@ -1,3 +1,5 @@ +// @depracated - moved to theme + import { SearchData } from '../../types'; const buildBreadcrumbsList = (rootCat, bc) => { diff --git a/packages/composables/src/composables/useFacet/index.ts b/packages/composables/src/composables/useFacet/index.ts index ea6fb2581..1444d5534 100644 --- a/packages/composables/src/composables/useFacet/index.ts +++ b/packages/composables/src/composables/useFacet/index.ts @@ -1,3 +1,6 @@ +/** + * @deprecated since version1.0.0 + */ import { ComposableFunctionArgs, Context, @@ -58,6 +61,9 @@ const constructSortObject = (sortData: string) => { return baseData.length > 0 ? Object.fromEntries([baseData]) : {}; }; +/** + * @deprecated since version1.0.0 + */ const factoryParams = { // eslint-disable-next-line @typescript-eslint/no-unused-vars search: async (context: Context, params: ComposableFunctionArgs>) => { diff --git a/packages/composables/src/composables/useForgotPassword/index.ts b/packages/composables/src/composables/useForgotPassword/index.ts index 8dba9e13c..1bb3ea8bd 100644 --- a/packages/composables/src/composables/useForgotPassword/index.ts +++ b/packages/composables/src/composables/useForgotPassword/index.ts @@ -4,6 +4,9 @@ import { } from '@vue-storefront/core'; import { UseForgotPasswordFactoryParams } from '../../factories/useForgotPasswordFactory'; +/** + * @deprecated since version1.0.0 + */ const factoryParams: UseForgotPasswordFactoryParams = { // eslint-disable-next-line @typescript-eslint/no-unused-vars resetPassword: async (context: Context, params) => { diff --git a/packages/composables/src/composables/useGuestUser/index.ts b/packages/composables/src/composables/useGuestUser/index.ts index 7074561fd..46da8066e 100644 --- a/packages/composables/src/composables/useGuestUser/index.ts +++ b/packages/composables/src/composables/useGuestUser/index.ts @@ -1,3 +1,6 @@ +/** + * @deprecated since version1.0.0 + */ import { SetGuestEmailOnCartInput } from '@vue-storefront/magento-api'; import { Logger } from '@vue-storefront/core'; import { useGuestUserFactory, UseGuestUserFactoryParams } from '../../factories/useGuestUserFactory'; diff --git a/packages/composables/src/composables/useStore/index.ts b/packages/composables/src/composables/useStore/index.ts index 34b8a99b9..4294f0cbb 100644 --- a/packages/composables/src/composables/useStore/index.ts +++ b/packages/composables/src/composables/useStore/index.ts @@ -1,3 +1,6 @@ +/** + * @deprecated since version1.0.0 + */ import { Context } from '@vue-storefront/core'; import { AvailableStores, StoreConfig } from '@vue-storefront/magento-api'; import { useStoreFactory, UseStoreFactoryParams } from '../../factories/useStoreFactory'; diff --git a/packages/composables/src/composables/useUser/index.ts b/packages/composables/src/composables/useUser/index.ts index 1c49c47fe..2c6625233 100644 --- a/packages/composables/src/composables/useUser/index.ts +++ b/packages/composables/src/composables/useUser/index.ts @@ -25,6 +25,9 @@ interface UseUserFactoryParams }) => Promise; } +/** + * @deprecated since version1.0.0 + */ const factoryParams: UseUserFactoryParams< any, UpdateCustomerEmailMutationVariables, @@ -175,6 +178,7 @@ CustomerCreateInput return factoryParams.load(context); }, + changePassword: async (context: Context, params) => { Logger.debug('[Magento] changing user password'); const { data, errors } = await context.$magento.api.changeCustomerPassword(params); diff --git a/packages/composables/src/composables/useWishlist/index.ts b/packages/composables/src/composables/useWishlist/index.ts index f657abb7a..071c03d21 100644 --- a/packages/composables/src/composables/useWishlist/index.ts +++ b/packages/composables/src/composables/useWishlist/index.ts @@ -8,6 +8,9 @@ import useUser from '../useUser'; import { findItemOnWishlist } from '../../helpers/findItemOnWishlist'; import { useWishlistFactory, UseWishlistFactoryParams } from '../../factories/useWishlistFactory'; +/** + * @deprecated since version1.0.0 + */ // @ts-ignore const factoryParams: UseWishlistFactoryParams = { provide() { diff --git a/packages/composables/src/factories/useCartFactory.ts b/packages/composables/src/factories/useCartFactory.ts index 452f39b57..104e02ae1 100644 --- a/packages/composables/src/factories/useCartFactory.ts +++ b/packages/composables/src/factories/useCartFactory.ts @@ -1,3 +1,6 @@ +/** + * @deprecated since version1.0.0 + */ import { UseCart as UseCartCore, Context, diff --git a/packages/composables/src/factories/useCategorySearchFactory.ts b/packages/composables/src/factories/useCategorySearchFactory.ts index 9e1d06d8f..f146d786b 100644 --- a/packages/composables/src/factories/useCategorySearchFactory.ts +++ b/packages/composables/src/factories/useCategorySearchFactory.ts @@ -13,7 +13,9 @@ import { UseCategorySearch, UseCategorySearchErrors } from '../types/composables export interface UseCategorySearchFactory extends FactoryParams { search: (context: Context, params: ComposableFunctionArgs) => Promise; } - +/** + * @deprecated since version1.0.0 + */ export function useCategorySearchFactory( factoryParams: UseCategorySearchFactory, ) { diff --git a/packages/composables/src/factories/useConfigFactory.ts b/packages/composables/src/factories/useConfigFactory.ts index 5c57cecd3..a754c3ba6 100644 --- a/packages/composables/src/factories/useConfigFactory.ts +++ b/packages/composables/src/factories/useConfigFactory.ts @@ -1,3 +1,6 @@ +/** + * @deprecated since version1.0.0 + */ import { computed } from '@vue/composition-api'; import { Context, diff --git a/packages/composables/src/factories/useContentFactory.ts b/packages/composables/src/factories/useContentFactory.ts index e3ffae419..ba1004ec0 100644 --- a/packages/composables/src/factories/useContentFactory.ts +++ b/packages/composables/src/factories/useContentFactory.ts @@ -1,3 +1,6 @@ +/** + * @deprecated since version1.0.0 + */ import { computed, Ref } from '@vue/composition-api'; import { ComposableFunctionArgs, diff --git a/packages/composables/src/factories/useCurrencyFactory.ts b/packages/composables/src/factories/useCurrencyFactory.ts index 8bb9699e2..032afcfbb 100644 --- a/packages/composables/src/factories/useCurrencyFactory.ts +++ b/packages/composables/src/factories/useCurrencyFactory.ts @@ -1,3 +1,6 @@ +/** + * @deprecated since version1.0.0 + */ import { computed } from '@vue/composition-api'; import { Context, diff --git a/packages/composables/src/factories/useExternalCheckoutFactory.ts b/packages/composables/src/factories/useExternalCheckoutFactory.ts index 6f4f89951..8d4c651a3 100644 --- a/packages/composables/src/factories/useExternalCheckoutFactory.ts +++ b/packages/composables/src/factories/useExternalCheckoutFactory.ts @@ -14,6 +14,9 @@ export interface UseExternalCheckoutFactoryParams initializeCheckout: (context: Context, params: ComposableFunctionArgs<{ baseUrl: string }>) => Promise; } +/** + * @deprecated since version1.0.0 + */ export const useExternalCheckoutFactory = ( factoryParams: UseExternalCheckoutFactoryParams, ) => { diff --git a/packages/composables/src/factories/useForgotPasswordFactory.ts b/packages/composables/src/factories/useForgotPasswordFactory.ts index ae2c50954..18e3961a1 100644 --- a/packages/composables/src/factories/useForgotPasswordFactory.ts +++ b/packages/composables/src/factories/useForgotPasswordFactory.ts @@ -27,6 +27,9 @@ export interface UseForgotPasswordFactoryParams extends FactoryParams { setNewPassword: (context: Context, params: ComposableFunctionArgs) => Promise; } +/** + * @deprecated since version1.0.0 + */ export function useForgotPasswordFactory( factoryParams: UseForgotPasswordFactoryParams, ) { diff --git a/packages/composables/src/factories/useGuestUserFactory.ts b/packages/composables/src/factories/useGuestUserFactory.ts index a70b4d3f5..1b0c2fb48 100644 --- a/packages/composables/src/factories/useGuestUserFactory.ts +++ b/packages/composables/src/factories/useGuestUserFactory.ts @@ -1,3 +1,6 @@ +/** + * @deprecated since version1.0.0 + */ import { Ref, computed } from '@vue/composition-api'; import { Context, diff --git a/packages/composables/src/factories/useStoreFactory.ts b/packages/composables/src/factories/useStoreFactory.ts index 56cda6527..591a42e11 100644 --- a/packages/composables/src/factories/useStoreFactory.ts +++ b/packages/composables/src/factories/useStoreFactory.ts @@ -1,3 +1,6 @@ +/** + * @deprecated since version1.0.0 + */ import { computed } from '@vue/composition-api'; import { Context, diff --git a/packages/composables/src/factories/useWishlistFactory.ts b/packages/composables/src/factories/useWishlistFactory.ts index 52e42c1e0..5daf9c4b8 100644 --- a/packages/composables/src/factories/useWishlistFactory.ts +++ b/packages/composables/src/factories/useWishlistFactory.ts @@ -43,6 +43,9 @@ export interface UseWishlistFactoryParams boolean; } +/** + * @deprecated since version1.0.0 + */ export const useWishlistFactory = ( factoryParams: UseWishlistFactoryParams, ) => { diff --git a/packages/composables/src/getters/cartGetters.ts b/packages/composables/src/getters/cartGetters.ts index caeb221c8..c32e46f31 100644 --- a/packages/composables/src/getters/cartGetters.ts +++ b/packages/composables/src/getters/cartGetters.ts @@ -13,6 +13,7 @@ import { Product, SelectedShippingMethod, ConfigurableCartItem, ProductInterface, } from '@vue-storefront/magento-api'; + import productGetters from './productGetters'; import { AgnosticPaymentMethod } from '../types'; @@ -145,7 +146,7 @@ export const getCoupons = (cart: Cart): AgnosticCoupon[] => (Array.isArray(cart? code: c.code, } as AgnosticCoupon)) : []); -export const getDiscounts = (cart: Cart): AgnosticDiscount[] => (Array.isArray(cart?.prices.discounts) ? cart.prices.discounts.map((d) => ({ +export const getDiscounts = (cart: Cart): AgnosticDiscount[] => (Array.isArray(cart?.prices?.discounts) ? cart.prices.discounts.map((d) => ({ id: d.label, name: d.label, description: '', diff --git a/packages/composables/src/helpers/userDataGenerator.ts b/packages/composables/src/helpers/userDataGenerator.ts index 5d9830de1..d9446bd41 100644 --- a/packages/composables/src/helpers/userDataGenerator.ts +++ b/packages/composables/src/helpers/userDataGenerator.ts @@ -1,5 +1,9 @@ import { CustomerUpdateParameters } from '@vue-storefront/magento-api'; +/** + * @deprecated + * @use packages/theme/helpers/customer/userDataGenerator.ts + */ export const generateUserData = (userData): CustomerUpdateParameters => { const baseData = { email: userData.email, diff --git a/packages/theme/components/AppHeader.vue b/packages/theme/components/AppHeader.vue index 28ca3a381..efb6530c5 100644 --- a/packages/theme/components/AppHeader.vue +++ b/packages/theme/components/AppHeader.vue @@ -120,12 +120,7 @@ import { SfBadge, } from '@storefront-ui/vue'; -import { - categoryGetters, - useCart, - useCategory, - useUser, useWishlist, -} from '@vue-storefront/magento'; +import { categoryGetters } from '@vue-storefront/magento'; import { computed, ref, @@ -137,9 +132,14 @@ import { } from '@nuxtjs/composition-api'; import HeaderNavigationItem from '~/components/Header/Navigation/HeaderNavigationItem.vue'; import { + useCart, + useCategory, useUiHelpers, useUiState, + useWishlist, + useUser, } from '~/composables'; + import CurrencySelector from '~/components/CurrencySelector.vue'; import HeaderLogo from '~/components/HeaderLogo.vue'; import SvgImage from '~/components/General/SvgImage.vue'; @@ -165,8 +165,8 @@ export default defineComponent({ const { toggleCartSidebar, toggleWishlistSidebar, toggleLoginModal } = useUiState(); const { setTermForUrl, getAgnosticCatLink } = useUiHelpers(); const { isAuthenticated } = useUser(); - const { totalQuantity: cartTotalItems, loadTotalQty: loadCartTotalQty } = useCart(); - const { itemsCount: wishlistItemsQty, loadItemsCount: loadWishlistItemsCount } = useWishlist('GlobalWishlist'); + const { loadTotalQty: loadCartTotalQty, cart } = useCart(); + const { loadItemsCount: loadWishlistItemsCount, wishlist } = useWishlist(); const { categories: categoryList, @@ -176,9 +176,9 @@ export default defineComponent({ const isSearchOpen = ref(false); const result = ref(null); - const wishlistHasProducts = computed(() => wishlistItemsQty.value > 0); + const wishlistHasProducts = computed(() => wishlist.value.items_count > 0); const accountIcon = computed(() => (isAuthenticated.value ? 'profile_fill' : 'profile')); - const categoryTree = categoryGetters.getCategoryTree(categoryList.value?.[0])?.items.filter((c) => c.count > 0); + const categoryTree = ref([]); const handleAccountClick = async () => { if (isAuthenticated.value) { @@ -190,6 +190,7 @@ export default defineComponent({ useFetch(async () => { await categoriesListSearch({ pageSize: 20 }); + categoryTree.value = categoryGetters.getCategoryTree(categoryList.value?.[0])?.items.filter((c) => c.count > 0); }); onMounted(() => { @@ -201,7 +202,7 @@ export default defineComponent({ return { accountIcon, - cartTotalItems, + cartTotalItems: computed(() => cart.value.total_quantity), categoryTree, getAgnosticCatLink, handleAccountClick, @@ -212,7 +213,7 @@ export default defineComponent({ toggleCartSidebar, toggleWishlistSidebar, wishlistHasProducts, - wishlistItemsQty, + wishlistItemsQty: computed(() => wishlist.value.items_count), }; }, }); diff --git a/packages/theme/components/BottomNavigation.vue b/packages/theme/components/BottomNavigation.vue index 3e5240fd5..d3511a36c 100644 --- a/packages/theme/components/BottomNavigation.vue +++ b/packages/theme/components/BottomNavigation.vue @@ -78,9 +78,8 @@