Feat(medusa-js, medusa-react): Upload endpoints in medusa js and react (#1716)

* export types from admin uploads

* add delete and download to medusa-js

* add upload endpoints to hooks

* remove upload from js and react

* pr feedback

* Apply suggestions from code review

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>

* rename types for admin uploads

Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
Philip Korsholm
2022-06-29 11:36:19 +02:00
committed by GitHub
co-authored by Oliver Windall Juhl
parent bf47d1aecd
commit 9018d270be
11 changed files with 187 additions and 25 deletions
@@ -1258,6 +1258,9 @@
"updated_at": "2021-03-16T21:24:00.389Z",
"created_at": "2021-03-16T21:24:00.389Z",
"deleted_at": null
},
"upload": {
"url": "test-url"
}
}
}
@@ -1,4 +1,5 @@
import { rest } from "msw"
import { body } from "msw/lib/types/context"
import { fixtures } from "../data"
export const adminHandlers = [
@@ -1651,4 +1652,24 @@ export const adminHandlers = [
rest.delete("/admin/auth", (req, res, ctx) => {
return res(ctx.status(200))
}),
rest.delete("/admin/uploads", (req, res, ctx) => {
return res(
ctx.status(200),
ctx.json({
id: (req.body as any).file_key,
object: "file",
deleted: true,
})
)
}),
rest.post("/admin/uploads/download-url", (req, res, ctx) => {
return res(
ctx.status(200),
ctx.json({
download_url: fixtures.get("upload").url,
})
)
}),
]