Feat: Medusa react price list (#1258)
* export everything from price lists in core * medusa-js price list * feat: add product list for price lists * feat: add product list for price lists * add price list to admin module * add price list hooks initial * refactor: product list controller * fix: add integration test for price list products * update types * add tests for price lists * update medusa react tests * update update request for price lists * Apply suggestions from code review Co-authored-by: Sebastian Rindom <skrindom@gmail.com> * rename methods * pr feedback * list products from price list * fix errors after merge * update medusa react with medusa-js method name changes * redo changes * update hook names * fix: routes in msw handler Co-authored-by: Sebastian Rindom <skrindom@gmail.com> Co-authored-by: Zakaria El Asri <zakaria.elas@gmail.com>
This commit is contained in:
co-authored by
Sebastian Rindom
Zakaria El Asri
parent
fb33dbaca3
commit
b164977a19
@@ -1076,6 +1076,18 @@
|
||||
"deleted_at": null,
|
||||
"metadata": null
|
||||
},
|
||||
"price_list": {
|
||||
"id": "pl_ZXDBABWJVW6115VEMZXDBAB",
|
||||
"name": "test price list",
|
||||
"description": "test price list",
|
||||
"type": "products",
|
||||
"status": "active",
|
||||
"starts_at": null,
|
||||
"ends_at": null,
|
||||
"created_at": "2021-03-16T21:24:35.828Z",
|
||||
"updated_at": "2021-03-16T21:24:35.828Z",
|
||||
"deleted_at": null
|
||||
},
|
||||
"note": {
|
||||
"id": "note_01F0ZXDBAB9KVZWJVW6115VEM7",
|
||||
"value": "customer contacted",
|
||||
|
||||
@@ -170,6 +170,89 @@ export const adminHandlers = [
|
||||
)
|
||||
}),
|
||||
|
||||
rest.post("/admin/price-lists/", (req, res, ctx) => {
|
||||
const body = req.body as Record<string, any>
|
||||
return res(
|
||||
ctx.status(200),
|
||||
ctx.json({
|
||||
price_list: {
|
||||
...fixtures.get("price_list"),
|
||||
...body,
|
||||
},
|
||||
})
|
||||
)
|
||||
}),
|
||||
|
||||
rest.get("/admin/price-lists/", (req, res, ctx) => {
|
||||
return res(
|
||||
ctx.status(200),
|
||||
ctx.json({
|
||||
price_lists: fixtures.list("price_list"),
|
||||
count: 2,
|
||||
offset: 0,
|
||||
limit: 10,
|
||||
})
|
||||
)
|
||||
}),
|
||||
|
||||
rest.get("/admin/price-lists/:id", (req, res, ctx) => {
|
||||
return res(
|
||||
ctx.status(200),
|
||||
ctx.json({
|
||||
price_list: fixtures.get("price_list"),
|
||||
})
|
||||
)
|
||||
}),
|
||||
|
||||
rest.post("/admin/price-lists/:id", (req, res, ctx) => {
|
||||
const body = req.body as Record<string, any>
|
||||
return res(
|
||||
ctx.status(200),
|
||||
ctx.json({
|
||||
price_list: {
|
||||
...fixtures.get("price_list"),
|
||||
...body,
|
||||
id: req.params.id,
|
||||
},
|
||||
})
|
||||
)
|
||||
}),
|
||||
|
||||
rest.delete("/admin/price-lists/:id", (req, res, ctx) => {
|
||||
return res(
|
||||
ctx.status(200),
|
||||
ctx.json({
|
||||
id: req.params.id,
|
||||
object: "price_list",
|
||||
deleted: true,
|
||||
})
|
||||
)
|
||||
}),
|
||||
|
||||
rest.delete("/admin/price-lists/:id/prices/batch", (req, res, ctx) => {
|
||||
const body = req.body as Record<string, any>
|
||||
return res(
|
||||
ctx.status(200),
|
||||
ctx.json({
|
||||
ids: body.price_ids,
|
||||
object: "money-amount",
|
||||
deleted: true,
|
||||
})
|
||||
)
|
||||
}),
|
||||
|
||||
rest.post("/admin/price-lists/:id/prices/batch", (req, res, ctx) => {
|
||||
return res(
|
||||
ctx.status(200),
|
||||
ctx.json({
|
||||
price_list: {
|
||||
...fixtures.get("price_list"),
|
||||
id: req.params.id,
|
||||
},
|
||||
})
|
||||
)
|
||||
}),
|
||||
|
||||
rest.post("/admin/return-reasons/", (req, res, ctx) => {
|
||||
const body = req.body as Record<string, any>
|
||||
return res(
|
||||
|
||||
Reference in New Issue
Block a user