diff --git a/.changeset/thirty-scissors-buy.md b/.changeset/thirty-scissors-buy.md new file mode 100644 index 0000000000..30aba2473c --- /dev/null +++ b/.changeset/thirty-scissors-buy.md @@ -0,0 +1,5 @@ +--- +"@medusajs/admin-ui": patch +--- + +fix(admin-ui): display SC update notification diff --git a/packages/admin-ui/ui/src/components/organisms/product-general-section/channels-modal.tsx b/packages/admin-ui/ui/src/components/organisms/product-general-section/channels-modal.tsx index 36579c57a6..b2250510bc 100644 --- a/packages/admin-ui/ui/src/components/organisms/product-general-section/channels-modal.tsx +++ b/packages/admin-ui/ui/src/components/organisms/product-general-section/channels-modal.tsx @@ -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 (