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