feat: featured products

:%s
This commit is contained in:
lytrankieio123
2021-10-04 19:36:47 +07:00
parent 6ad8f75c67
commit 47107e2702
9 changed files with 174 additions and 159 deletions

View File

@@ -1,4 +1,4 @@
import { CurrencyCode } from './../../vendure/schema.d';
import { CurrencyCode, FacetValue } from './../../vendure/schema.d';
import { FacetValueFilterInput, LogicalOperator, SearchResultSortParameter } from "@framework/schema"
export type ProductImage = {
@@ -54,9 +54,11 @@ export type ProductCard = {
imageSrc: string
price: number
currencyCode: CurrencyCode
oldPrice?: number,
oldPrice?: number
discount?: number
weight?: number
facetValueIds?: string[],
collectionIds?: string[],
// TODO: collection
category?: string,
isNotSell?: boolean

View File

@@ -1,3 +1,4 @@
import { FacetValue } from './schema.d';
export type Maybe<T> = T | null
export type Exact<T extends { [key: string]: unknown }> = {
[K in keyof T]: T[K]
@@ -3038,7 +3039,7 @@ export type SearchResultFragment = { __typename?: 'SearchResult' } & Pick<
SearchResult,
'productId' | 'sku' | 'productName' | 'description' | 'slug' | 'sku' | 'currencyCode'
| 'productAsset' | 'price' | 'priceWithTax' | 'currencyCode'
| 'collectionIds'
| 'collectionIds' | 'facetValueIds' | 'collectionIds'
> & {
productAsset?: Maybe<
{ __typename?: 'SearchResultAsset' } & Pick<

View File

@@ -19,6 +19,8 @@ export const searchResultFragment = /* GraphQL */ `
min
max
}
}
},
facetValueIds,
collectionIds,
}
`

View File

@@ -1,16 +1,17 @@
import { Product, ProductCard } from '@commerce/types/product'
import { Cart } from '@commerce/types/cart'
import { ProductCard } from '@commerce/types/product'
import { CartFragment, SearchResultFragment } from '../schema'
export function normalizeSearchResult(item: SearchResultFragment): ProductCard {
return {
id: item.productId,
name: item.productName,
slug: item.slug,
imageSrc: item.productAsset?.preview ? item.productAsset?.preview + '?w=800&mode=crop' : '',
price: (item.priceWithTax as any).min / 100,
currencyCode: item.currencyCode,
facetValueIds: item.facetValueIds,
collectionIds: item.collectionIds,
// TODO:
// oldPrice: item.price