The complete open source platform to run your entire marketplace. Storefront, vendor panel, admin console, and integrations in one enterprise-grade platform you own.
TypeScript b2b-marketplacecomposable-commerceecommerceenterpriseheadless-commercemarketplacemedusamedusajsmulti-vendortypescript
fix(admin): consistent collection create/update/delete toasts (#1179)
Viktor Holik31af16a66747
diff --git a/packages/admin/src/i18n/translations/$schema.json b/packages/admin/src/i18n/translations/$schema.jsonindex 20c757a0f..3b14019b1 100644--- a/packages/admin/src/i18n/translations/$schema.json+++ b/packages/admin/src/i18n/translations/$schema.json@@ -3350,6 +3350,12 @@"createSuccess": {"type": "string"},+ "deleteSuccess": {+ "type": "string"+ },+ "updateSuccess": {+ "type": "string"+ },"editCollection": {"type": "string"},@@ -3643,6 +3649,8 @@"createCollection","createCollectionHint","createSuccess",+ "deleteSuccess",+ "updateSuccess","editCollection","handleTooltip","deleteWarning",diff --git a/packages/admin/src/i18n/translations/en.json b/packages/admin/src/i18n/translations/en.jsonindex bfd3a6dbd..527afb3a6 100644--- a/packages/admin/src/i18n/translations/en.json+++ b/packages/admin/src/i18n/translations/en.json@@ -876,7 +876,9 @@"subtitle": "Organize products into collections.","createCollection": "Create Collection","createCollectionHint": "Create a new collection to organize your products.",- "createSuccess": "Collection created successfully.",+ "createSuccess": "Collection was successfully created.",+ "deleteSuccess": "Collection was successfully deleted.",+ "updateSuccess": "Collection was successfully updated.","editCollection": "Edit Collection","handleTooltip": "The handle is used to reference the collection in your storefront. If not specified, the handle will be generated from the collection title.","deleteWarning": "You are about to delete the collection {{title}}. This action cannot be undone.",diff --git a/packages/admin/src/pages/collections/collection-detail/components/collection-general-section/collection-general-section.tsx b/packages/admin/src/pages/collections/collection-detail/components/collection-general-section/collection-general-section.tsxindex 8bad23000..b1cc42856 100644--- a/packages/admin/src/pages/collections/collection-detail/components/collection-general-section/collection-general-section.tsx+++ b/packages/admin/src/pages/collections/collection-detail/components/collection-general-section/collection-general-section.tsx@@ -1,6 +1,6 @@import { PencilSquare, Trash } from "@medusajs/icons"import { HttpTypes } from "@medusajs/types"-import { Container, Heading, Text, usePrompt } from "@medusajs/ui"+import { Container, Heading, Text, toast, usePrompt } from "@medusajs/ui"import { DisplayExtensionZone, DisplayField } from "@mercurjs/dashboard-shared"import { useTranslation } from "react-i18next"import { ActionMenu } from "../../../../../components/common/action-menu"@@ -33,7 +33,14 @@ export const CollectionGeneralSection = ({return}- await mutateAsync()+ await mutateAsync(undefined, {+ onSuccess: () => {+ toast.success(t("collections.deleteSuccess"))+ },+ onError: (error) => {+ toast.error(error.message)+ },+ })navigate("../", { replace: true })}diff --git a/packages/admin/src/pages/collections/collection-edit/components/edit-collection-form/edit-collection-form.tsx b/packages/admin/src/pages/collections/collection-edit/components/edit-collection-form/edit-collection-form.tsxindex 22b5594b9..c951078f2 100644--- a/packages/admin/src/pages/collections/collection-edit/components/edit-collection-form/edit-collection-form.tsx+++ b/packages/admin/src/pages/collections/collection-edit/components/edit-collection-form/edit-collection-form.tsx@@ -1,4 +1,4 @@-import { Button, Input, Text } from "@medusajs/ui"+import { Button, Input, Text, toast } from "@medusajs/ui"import { useTranslation } from "react-i18next"import * as zod from "zod"@@ -40,8 +40,12 @@ export const EditCollectionForm = ({ collection }: EditCollectionFormProps) => {const handleSubmit = form.handleSubmit(async (data) => {await mutateAsync(data, {onSuccess: () => {+ toast.success(t("collections.updateSuccess"))handleSuccess()},+ onError: (error) => {+ toast.error(error.message)+ },})})diff --git a/packages/admin/src/pages/collections/collection-list/components/collection-list-table/collection-row-actions.tsx b/packages/admin/src/pages/collections/collection-list/components/collection-list-table/collection-row-actions.tsxindex b1f703b28..23e2bf50d 100644--- a/packages/admin/src/pages/collections/collection-list/components/collection-list-table/collection-row-actions.tsx+++ b/packages/admin/src/pages/collections/collection-list/components/collection-list-table/collection-row-actions.tsx@@ -1,6 +1,6 @@import { PencilSquare, Trash } from "@medusajs/icons"import { HttpTypes } from "@medusajs/types"-import { usePrompt } from "@medusajs/ui"+import { toast, usePrompt } from "@medusajs/ui"import { useTranslation } from "react-i18next"import { ActionMenu } from "../../../../../components/common/action-menu"@@ -32,7 +32,14 @@ export const CollectionRowActions = ({return}- await mutateAsync()+ await mutateAsync(undefined, {+ onSuccess: () => {+ toast.success(t("collections.deleteSuccess"))+ },+ onError: (error) => {+ toast.error(error.message)+ },+ })}return (