feat: customer groups react hooks (#1153)

* fix: msw handlers for medusa-react storybook

* feat: add customer groups query hooks

* feat: add create/update customer groups hooks

* feat: add customer group batch  hooks

* feat: add test files, fix import

* add customer groups fixture

* add customer gorup mock endpoints

* add test cases

* add hook comments

* fix: typos

* fix: comments refactor

* fix: comment

Co-authored-by: fPolic <frane@medusajs.com>
This commit is contained in:
Frane Polić
2022-03-07 12:52:48 +01:00
committed by GitHub
co-authored by fPolic
parent a6f352d9f1
commit daf49bcaf3
11 changed files with 335 additions and 8 deletions
@@ -516,6 +516,14 @@
"deleted_at": null,
"metadata": null
},
"customer_group": {
"name": "test group",
"id": "cgrp_01FX8NJYPPDEH7YK9NYM6BXPHV",
"deleted_at": null,
"metadata": null,
"created_at": "2022-03-03T19:54:53.014Z",
"updated_at": "2022-03-03T19:54:53.014Z"
},
"shipping_profile": {
"id": "sp_01F0YESTZQFW15SFEZSS29EZ5R",
"name": "Default Shipping Profile",
@@ -509,6 +509,48 @@ export const adminHandlers = [
)
}),
rest.get("/admin/customer-groups/", (req, res, ctx) => {
return res(
ctx.status(200),
ctx.json({
customer_groups: fixtures.list("customer_group"),
})
)
}),
rest.get("/admin/customer-groups/:id", (req, res, ctx) => {
return res(
ctx.status(200),
ctx.json({
customer_group: fixtures.get("customer_group"),
})
)
}),
rest.post("/admin/customer-groups/", (req, res, ctx) => {
return res(
ctx.status(200),
ctx.json({
customer_group: {
...fixtures.get("customer_group"),
...(req.body as any),
},
})
)
}),
rest.post("/admin/customer-groups/:id", (req, res, ctx) => {
return res(
ctx.status(200),
ctx.json({
customer_group: {
...fixtures.get("customer_group"),
...(req.body as any),
},
})
)
}),
rest.get("/admin/discounts/", (req, res, ctx) => {
return res(
ctx.status(200),
+1 -1
View File
@@ -1,4 +1,4 @@
import { setupServer } from "msw/node"
import { storeHandlers, adminHandlers } from "./handlers"
export const server = setupServer(...[...storeHandlers, ...adminHandlers])
export const server = setupServer(...storeHandlers, ...adminHandlers)