feat(medusa, medusa-js, medusa-react): Bulk add Products to a SalesChannel (#1833)
This commit is contained in:
committed by
GitHub
parent
cdd91974f9
commit
f35ea5156a
@@ -3,7 +3,8 @@ import {
|
||||
AdminSalesChannelsRes,
|
||||
AdminPostSalesChannelsSalesChannelReq,
|
||||
AdminSalesChannelsDeleteRes,
|
||||
AdminDeleteSalesChannelsChannelProductsBatchReq
|
||||
AdminDeleteSalesChannelsChannelProductsBatchReq,
|
||||
AdminPostSalesChannelsChannelProductsBatchReq,
|
||||
} from "@medusajs/medusa"
|
||||
import { Response } from "@medusajs/medusa-js"
|
||||
import { useMutation, UseMutationOptions, useQueryClient } from "react-query"
|
||||
@@ -117,4 +118,34 @@ export const useAdminDeleteProductsFromSalesChannel = (
|
||||
options
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add products to 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 Add products to a sales channel
|
||||
* @param id
|
||||
* @param options
|
||||
*/
|
||||
export const useAdminAddProductsToSalesChannel = (
|
||||
id: string,
|
||||
options?: UseMutationOptions<
|
||||
Response<AdminSalesChannelsRes>,
|
||||
Error,
|
||||
AdminPostSalesChannelsChannelProductsBatchReq
|
||||
>
|
||||
) => {
|
||||
const { client } = useMedusa()
|
||||
const queryClient = useQueryClient()
|
||||
return useMutation(
|
||||
(payload: AdminPostSalesChannelsChannelProductsBatchReq) => {
|
||||
return client.admin.salesChannels.addProducts(id, payload)
|
||||
},
|
||||
buildOptions(
|
||||
queryClient,
|
||||
[adminSalesChannelsKeys.lists(), adminSalesChannelsKeys.detail(id)],
|
||||
options
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user