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:
committed by
GitHub
parent
7162972318
commit
cdd91974f9
@@ -3,6 +3,7 @@ import {
|
||||
AdminSalesChannelsRes,
|
||||
AdminPostSalesChannelsSalesChannelReq,
|
||||
AdminSalesChannelsDeleteRes,
|
||||
AdminDeleteSalesChannelsChannelProductsBatchReq
|
||||
} from "@medusajs/medusa"
|
||||
import { Response } from "@medusajs/medusa-js"
|
||||
import { useMutation, UseMutationOptions, useQueryClient } from "react-query"
|
||||
@@ -87,3 +88,33 @@ export const useAdminDeleteSalesChannel = (
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @param id
|
||||
* @param options
|
||||
*/
|
||||
export const useAdminDeleteProductsFromSalesChannel = (
|
||||
id: string,
|
||||
options?: UseMutationOptions<
|
||||
Response<AdminSalesChannelsRes>,
|
||||
Error,
|
||||
AdminDeleteSalesChannelsChannelProductsBatchReq
|
||||
>
|
||||
) => {
|
||||
const { client } = useMedusa()
|
||||
const queryClient = useQueryClient()
|
||||
return useMutation(
|
||||
(payload: AdminDeleteSalesChannelsChannelProductsBatchReq) => {
|
||||
return client.admin.salesChannels.removeProducts(id, payload)
|
||||
},
|
||||
buildOptions(
|
||||
queryClient,
|
||||
[adminSalesChannelsKeys.lists(), adminSalesChannelsKeys.detail(id)],
|
||||
options
|
||||
)
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user