feat: /store api product types (#2552)

## What
Allow users to fetch ProductTypes from the storefront API.

## Why
This endpoint will allow developers to implement better faceted product search in Medusa without the need for search plugin. Developers will be able to use this to render refinement lists based on types, like this:
![image](https://user-images.githubusercontent.com/116003638/200417828-863065de-3607-49db-bd72-62a6815129fa.png)

## How
Endpoint `GET /store/products/types` and `GET /store/product-types` (use [product types listing in admin](https://github.com/medusajs/medusa/blob/master/packages/medusa/src/api/routes/admin/products/list-types.ts) as reference)

Support added in @medusajs/medusa-js
Support added in medusa-react

## Testing
Similar automated tests as `GET /admin/products/types` and `GET /admin/product-types`

---

Resolves CORE-699
This commit is contained in:
Patrick
2022-11-09 11:10:17 -05:00
committed by GitHub
parent 2d095a0ce1
commit 7b0ceeffb4
18 changed files with 517 additions and 32 deletions

View File

@@ -55,11 +55,7 @@ describe("/admin/product-types", () => {
it("returns a list of product types", async () => {
const api = useApi()
const res = await api
.get("/admin/product-types", adminReqConfig)
.catch((err) => {
console.log(err)
})
const res = await api.get("/admin/product-types", adminReqConfig)
expect(res.status).toEqual(200)
@@ -74,11 +70,10 @@ describe("/admin/product-types", () => {
it("returns a list of product types matching free text search param", async () => {
const api = useApi()
const res = await api
.get("/admin/product-types?q=test-type-new", adminReqConfig)
.catch((err) => {
console.log(err)
})
const res = await api.get(
"/admin/product-types?q=test-type-new",
adminReqConfig
)
expect(res.status).toEqual(200)