mirror of
https://github.com/vercel/commerce.git
synced 2025-06-19 05:31:22 +00:00
Fixes
This commit is contained in:
parent
9309ca9487
commit
ca703ad2a0
@ -1,9 +1,16 @@
|
|||||||
import { SWRHook } from '@commerce/utils/types'
|
import { SWRHook } from '@commerce/utils/types'
|
||||||
import useSearch, { UseSearch } from '@commerce/product/use-search'
|
import useSearch, { UseSearch } from '@commerce/product/use-search'
|
||||||
import { SearchProductsData, SearchProductsInput } from '@commerce/types'
|
import type { SearchProductsData } from '../api/catalog/products'
|
||||||
|
|
||||||
export default useSearch as UseSearch<typeof handler>
|
export default useSearch as UseSearch<typeof handler>
|
||||||
|
|
||||||
|
export type SearchProductsInput = {
|
||||||
|
search?: string
|
||||||
|
categoryId?: number
|
||||||
|
brandId?: number
|
||||||
|
sort?: string
|
||||||
|
}
|
||||||
|
|
||||||
export const handler: SWRHook<
|
export const handler: SWRHook<
|
||||||
SearchProductsData,
|
SearchProductsData,
|
||||||
SearchProductsInput,
|
SearchProductsInput,
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import type { Wishlist as BCWishlist } from '../bigcommerce/api/wishlist'
|
import type { Wishlist as BCWishlist } from '../bigcommerce/api/wishlist'
|
||||||
import type { Customer as BCCustomer } from '../bigcommerce/api/customers'
|
import type { Customer as BCCustomer } from '../bigcommerce/api/customers'
|
||||||
|
import type { SearchProductsData as BCSearchProductsData } from '../bigcommerce/api/catalog/products'
|
||||||
|
|
||||||
export type Discount = {
|
export type Discount = {
|
||||||
// The value of the discount, can be an amount or percentage
|
// The value of the discount, can be an amount or percentage
|
||||||
@ -96,18 +97,8 @@ export interface Wishlist extends BCWishlist {}
|
|||||||
// TODO: Properly define this type
|
// TODO: Properly define this type
|
||||||
export interface Customer extends BCCustomer {}
|
export interface Customer extends BCCustomer {}
|
||||||
|
|
||||||
export type SearchProductsData = {
|
// TODO: Properly define this type
|
||||||
products: Product[]
|
export interface SearchProductsData extends BCSearchProductsData {}
|
||||||
found: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export type SearchProductsInput = {
|
|
||||||
search?: string
|
|
||||||
categoryId?: string
|
|
||||||
brandId?: string
|
|
||||||
sort?: string
|
|
||||||
locale?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cart mutations
|
* Cart mutations
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { SWRHook } from '@commerce/utils/types'
|
import { SWRHook } from '@commerce/utils/types'
|
||||||
|
import { Product } from '@commerce/types'
|
||||||
import useSearch, { UseSearch } from '@commerce/product/use-search'
|
import useSearch, { UseSearch } from '@commerce/product/use-search'
|
||||||
import { SearchProductsInput, SearchProductsData } from '@commerce/types'
|
|
||||||
|
|
||||||
import { ProductEdge } from '../schema'
|
import { ProductEdge } from '../schema'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -11,6 +10,19 @@ import {
|
|||||||
normalizeProduct,
|
normalizeProduct,
|
||||||
} from '../utils'
|
} from '../utils'
|
||||||
|
|
||||||
|
export type SearchProductsInput = {
|
||||||
|
search?: string
|
||||||
|
categoryId?: string
|
||||||
|
brandId?: string
|
||||||
|
sort?: string
|
||||||
|
locale?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SearchProductsData = {
|
||||||
|
products: Product[]
|
||||||
|
found: boolean
|
||||||
|
}
|
||||||
|
|
||||||
export default useSearch as UseSearch<typeof handler>
|
export default useSearch as UseSearch<typeof handler>
|
||||||
|
|
||||||
export const handler: SWRHook<
|
export const handler: SWRHook<
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
import { SearchProductsInput } from '@framework/product/use-search'
|
||||||
import getSortVariables from './get-sort-variables'
|
import getSortVariables from './get-sort-variables'
|
||||||
import type { SearchProductsInput } from '@commerce/types'
|
|
||||||
|
|
||||||
export const getSearchVariables = ({
|
export const getSearchVariables = ({
|
||||||
brandId,
|
brandId,
|
||||||
|
@ -23,14 +23,14 @@ export async function getStaticProps({
|
|||||||
})
|
})
|
||||||
|
|
||||||
// const { categories, brands } = await getSiteInfo({ config, preview })
|
// const { categories, brands } = await getSiteInfo({ config, preview })
|
||||||
// const { pages } = await getAllPages({ config, preview })
|
const { pages } = await getAllPages({ config, preview })
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
products,
|
products,
|
||||||
categories: [],
|
categories: [],
|
||||||
brands: [],
|
brands: [],
|
||||||
pages: [],
|
pages,
|
||||||
},
|
},
|
||||||
revalidate: 14400,
|
revalidate: 14400,
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,9 @@ export default function Search({
|
|||||||
categoryId: activeCategory?.entityId,
|
categoryId: activeCategory?.entityId,
|
||||||
brandId: (activeBrand as any)?.entityId,
|
brandId: (activeBrand as any)?.entityId,
|
||||||
sort: typeof sort === 'string' ? sort : '',
|
sort: typeof sort === 'string' ? sort : '',
|
||||||
locale,
|
...(process.env.COMMERCE_PROVIDER === 'shopify' && {
|
||||||
|
locale,
|
||||||
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
const handleClick = (event: any, filter: string) => {
|
const handleClick = (event: any, filter: string) => {
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
"@components/*": ["components/*"],
|
"@components/*": ["components/*"],
|
||||||
"@commerce": ["framework/commerce"],
|
"@commerce": ["framework/commerce"],
|
||||||
"@commerce/*": ["framework/commerce/*"],
|
"@commerce/*": ["framework/commerce/*"],
|
||||||
"@framework": ["framework/vendure"],
|
"@framework": ["framework/bigcommerce"],
|
||||||
"@framework/*": ["framework/vendure/*"]
|
"@framework/*": ["framework/bigcommerce/*"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"include": ["next-env.d.ts", "**/*.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"],
|
"include": ["next-env.d.ts", "**/*.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user