feat: Add support for product imports (#8298)

* feat: Add support for product imports

* fix: Add product import template to import UI
This commit is contained in:
Stevche Radevski
2024-07-30 16:46:08 +02:00
committed by GitHub
parent a9fea986b0
commit 1066499402
14 changed files with 482 additions and 39 deletions
+40 -6
View File
@@ -1,9 +1,4 @@
import {
AdminBatchProductVariantInventoryItemRequest,
AdminBatchProductVariantInventoryItemResponse,
HttpTypes,
SelectParams,
} from "@medusajs/types"
import { HttpTypes, SelectParams } from "@medusajs/types"
import { Client } from "../client"
import { ClientHeaders } from "../types"
@@ -13,6 +8,45 @@ export class Product {
this.client = client
}
async import(
body: HttpTypes.AdminImportProductRequest,
query?: {},
headers?: ClientHeaders
) {
const form = new FormData()
form.append("file", body.file)
return await this.client.fetch<HttpTypes.AdminImportProductResponse>(
`/admin/products/import`,
{
method: "POST",
headers: {
...headers,
// Let the browser determine the content type.
"content-type": null,
},
body: form,
query,
}
)
}
async confirmImport(
transactionId: string,
query?: {},
headers?: ClientHeaders
) {
return await this.client.fetch<{}>(
`/admin/products/import/${transactionId}/confirm`,
{
method: "POST",
headers,
body: {},
query,
}
)
}
async export(
body: HttpTypes.AdminExportProductRequest,
query?: HttpTypes.AdminProductListParams,