fix(admin-ui): display SC update notification (#3755)
Co-authored-by: fPolic <frane@medusajs.com>
This commit is contained in:
5
.changeset/thirty-scissors-buy.md
Normal file
5
.changeset/thirty-scissors-buy.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@medusajs/admin-ui": patch
|
||||
---
|
||||
|
||||
fix(admin-ui): display SC update notification
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Product, SalesChannel } from "@medusajs/medusa"
|
||||
import { useAdminUpdateProduct } from "medusa-react"
|
||||
import SalesChannelsModal from "../../forms/product/sales-channels-modal"
|
||||
import useNotification from "../../../hooks/use-notification"
|
||||
|
||||
type Props = {
|
||||
product: Product
|
||||
@@ -9,13 +10,19 @@ type Props = {
|
||||
}
|
||||
|
||||
const ChannelsModal = ({ product, open, onClose }: Props) => {
|
||||
const { mutate } = useAdminUpdateProduct(product.id)
|
||||
const notification = useNotification()
|
||||
|
||||
const onUpdate = (channels: SalesChannel[]) => {
|
||||
// @ts-ignore
|
||||
mutate({
|
||||
sales_channels: channels.map((c) => ({ id: c.id })),
|
||||
})
|
||||
const { mutateAsync } = useAdminUpdateProduct(product.id)
|
||||
|
||||
const onUpdate = async (channels: SalesChannel[]) => {
|
||||
try {
|
||||
await mutateAsync({
|
||||
sales_channels: channels.map((c) => ({ id: c.id })),
|
||||
})
|
||||
notification("Success", "Successfully updated sales channels", "success")
|
||||
} catch (e) {
|
||||
notification("Error", "Failed to update sales channels", "error")
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user