feat(medusa, medusa-js, medusa-react): Start implementing remove batch products on a sales channel (#1842)

What
Support sales channel remove product batch in medusa, medusa-js and medusa-react

How
By implementing a new endpoint and the associated service method as well as the repository methods.

Medusa-js new removeProductd method in the resource

Medusa-react new hook in the mutations

Tests

Endpoint test
Service test
Integration test
Hook tests

Fixes CORE-292
This commit is contained in:
Adrien de Peretti
2022-07-13 19:40:23 +00:00
committed by GitHub
parent 7162972318
commit cdd91974f9
19 changed files with 396 additions and 218 deletions
@@ -5,6 +5,7 @@ import {
AdminPostSalesChannelsSalesChannelReq,
AdminSalesChannelsDeleteRes,
AdminSalesChannelsListRes,
AdminDeleteSalesChannelsChannelProductsBatchReq,
} from "@medusajs/medusa"
import { ResponsePromise } from "../../typings"
import BaseResource from "../base"
@@ -87,6 +88,22 @@ class AdminSalesChannelsResource extends BaseResource {
const path = `/admin/sales-channels/${salesChannelId}`
return this.client.request("DELETE", path, {}, {}, customHeaders)
}
/**
* Remove products from a sales channel
* @experimental This feature is under development and may change in the future.
* To use this feature please enable featureflag `sales_channels` in your medusa backend project.
* @description Remove products from a sales channel
* @returns a medusa sales channel
*/
removeProducts(
salesChannelId: string,
payload: AdminDeleteSalesChannelsChannelProductsBatchReq,
customHeaders: Record<string, any> = {}
): ResponsePromise<AdminSalesChannelsRes> {
const path = `/admin/sales-channels/${salesChannelId}/products/batch`
return this.client.request("DELETE", path, payload, {}, customHeaders)
}
}
export default AdminSalesChannelsResource