forked from crowetic/commerce
Minor fixes
This commit is contained in:
parent
9c1372acb7
commit
5bf93038c2
@ -53,6 +53,13 @@ export type GetAllProductsResult<
|
|||||||
T extends Record<keyof GetAllProductsResult, any[]> = { products: Products }
|
T extends Record<keyof GetAllProductsResult, any[]> = { products: Products }
|
||||||
> = T
|
> = T
|
||||||
|
|
||||||
|
const FIELDS = [
|
||||||
|
'products',
|
||||||
|
'featuredProducts',
|
||||||
|
'bestSellingProducts',
|
||||||
|
'newestProducts',
|
||||||
|
]
|
||||||
|
|
||||||
export type ProductTypes =
|
export type ProductTypes =
|
||||||
| 'products'
|
| 'products'
|
||||||
| 'featuredProducts'
|
| 'featuredProducts'
|
||||||
@ -92,21 +99,14 @@ async function getAllProducts({
|
|||||||
...vars,
|
...vars,
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (field) {
|
if (!FIELDS.includes(field)) {
|
||||||
case 'products':
|
throw new Error(
|
||||||
variables.products = true
|
`The field variable has to match one of ${FIELDS.join(', ')}`
|
||||||
break
|
)
|
||||||
case 'featuredProducts':
|
|
||||||
variables.featuredProducts = true
|
|
||||||
break
|
|
||||||
case 'bestSellingProducts':
|
|
||||||
variables.bestSellingProducts = true
|
|
||||||
break
|
|
||||||
case 'newestProducts':
|
|
||||||
variables.newestProducts = true
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variables[field] = true
|
||||||
|
|
||||||
// RecursivePartial forces the method to check for every prop in the data, which is
|
// RecursivePartial forces the method to check for every prop in the data, which is
|
||||||
// required in case there's a custom `query`
|
// required in case there's a custom `query`
|
||||||
const data = await config.fetch<RecursivePartial<GetAllProductsQuery>>(
|
const data = await config.fetch<RecursivePartial<GetAllProductsQuery>>(
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { BigcommerceApiError } from '../../utils/errors'
|
|
||||||
import type { Wishlist, WishlistHandlers } from '..'
|
import type { Wishlist, WishlistHandlers } from '..'
|
||||||
|
|
||||||
// Return wishlist info
|
// Return wishlist info
|
||||||
|
Loading…
x
Reference in New Issue
Block a user