diff --git a/framework/vendure/schema.d.ts b/framework/vendure/schema.d.ts index d83b0276a..a6ab64d19 100644 --- a/framework/vendure/schema.d.ts +++ b/framework/vendure/schema.d.ts @@ -3198,10 +3198,15 @@ export type ActiveCustomerQuery = { __typename?: 'Query' } & { activeCustomer?: Maybe< { __typename?: 'Customer' } & Pick< Customer, - 'id' | 'firstName' | 'lastName' | 'emailAddress' - > + 'id' | 'firstName' | 'lastName' | 'emailAddress' | 'favorites' + >, > } +export type FavoriteList = { + items: [Favorite!]! + totalItems: Int! +} + export type GetAllProductPathsQueryVariables = Exact<{ first?: Maybe diff --git a/src/components/common/ProductList/ProductList.tsx b/src/components/common/ProductList/ProductList.tsx index 5c3d9058a..59884eca8 100644 --- a/src/components/common/ProductList/ProductList.tsx +++ b/src/components/common/ProductList/ProductList.tsx @@ -1,12 +1,13 @@ import classNames from 'classnames' import { useRouter } from 'next/router' import React from 'react' +import { useActiveCustomer } from 'src/components/hooks/auth' import { DEFAULT_PAGE_SIZE, ROUTE } from 'src/utils/constanst.utils' import { ButtonCommon, EmptyCommon } from '..' import PaginationCommon from '../PaginationCommon/PaginationCommon' import ProductCard, { ProductCardProps } from '../ProductCard/ProductCard' import s from "./ProductList.module.scss" - +import { FavoriteList } from '@framework/schema' interface ProductListProps { data: ProductCardProps[], total?: number, @@ -16,6 +17,8 @@ interface ProductListProps { const ProductList = ({ data, total = data.length, defaultCurrentPage, onPageChange }: ProductListProps) => { const router = useRouter() + const {wishlist:FavoriteList } = useActiveCustomer(); + const handlePageChange = (page: number) => { onPageChange && onPageChange(page) } @@ -33,8 +36,7 @@ const ProductList = ({ data, total = data.length, defaultCurrentPage, onPageChan
{ data.map((product, index) => { - console.log(product); - + return }) } diff --git a/src/components/hooks/auth/useActiveCustomer.tsx b/src/components/hooks/auth/useActiveCustomer.tsx index f0f4f6fef..b4891c44d 100644 --- a/src/components/hooks/auth/useActiveCustomer.tsx +++ b/src/components/hooks/auth/useActiveCustomer.tsx @@ -1,11 +1,14 @@ -import { ActiveCustomerQuery } from '@framework/schema' +import { ActiveCustomerQuery,FavoriteList } from '@framework/schema' import { activeCustomerQuery } from '@framework/utils/queries/active-customer-query' import gglFetcher from 'src/utils/gglFetcher' import useSWR from 'swr' - const useActiveCustomer = () => { const { data, ...rest } = useSWR([activeCustomerQuery], gglFetcher) - return { customer: data?.activeCustomer, ...rest } + + return { + customer: data?.activeCustomer, + wishlist:data?.activeCustomer?.favorites, + ...rest } } export default useActiveCustomer