forked from crowetic/commerce
Update ordercloud types (#532)
This commit is contained in:
parent
55b917489d
commit
e3471db3eb
@ -1,5 +1,4 @@
|
||||
|
||||
import { normalize as normalizeProduct } from '@framework/utils/product'
|
||||
import { normalize as normalizeProduct } from '../../../../utils/product'
|
||||
import { ProductsEndpoint } from '.'
|
||||
|
||||
// Get products for the product list page. Search and category filter implemented. Sort and brand filter not implemented.
|
||||
@ -12,28 +11,27 @@ const getProducts: ProductsEndpoint['handlers']['getProducts'] = async ({
|
||||
//Use a dummy base as we only care about the relative path
|
||||
const url = new URL('/me/products', 'http://a')
|
||||
|
||||
if (search) {
|
||||
url.searchParams.set('search', search)
|
||||
if (search) {
|
||||
url.searchParams.set('search', search)
|
||||
}
|
||||
if (categoryId) {
|
||||
url.searchParams.set('categoryID', String(categoryId))
|
||||
url.searchParams.set('categoryID', String(categoryId))
|
||||
}
|
||||
|
||||
// Get token from cookies
|
||||
const token = req.cookies[tokenCookie];
|
||||
const token = req.cookies[tokenCookie]
|
||||
|
||||
var rawProducts = await restBuyerFetch(
|
||||
'GET',
|
||||
url.pathname + url.search,
|
||||
null,
|
||||
{ token }
|
||||
);
|
||||
)
|
||||
|
||||
const products = rawProducts.Items.map(normalizeProduct);
|
||||
const found = rawProducts?.Items?.length > 0;
|
||||
const products = rawProducts.Items.map(normalizeProduct)
|
||||
const found = rawProducts?.Items?.length > 0
|
||||
|
||||
res.status(200).json({ data: { products, found } })
|
||||
}
|
||||
|
||||
export default getProducts
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { createEndpoint, GetAPISchema } from "@commerce/api"
|
||||
import { ProductsSchema } from "@commerce/types/product"
|
||||
import { OrdercloudAPI } from "@framework/api"
|
||||
import getProducts from "./get-products";
|
||||
import type { OrdercloudAPI } from '../../../../api'
|
||||
|
||||
import { createEndpoint, GetAPISchema } from '@commerce/api'
|
||||
import { ProductsSchema } from '@commerce/types/product'
|
||||
import getProducts from './get-products'
|
||||
import productsEndpoint from '@commerce/api/endpoints/catalog/products'
|
||||
|
||||
export type ProductsAPI = GetAPISchema<OrdercloudAPI, ProductsSchema>
|
||||
|
Loading…
x
Reference in New Issue
Block a user