fix(dashboard): minor collection bugs (#9255)
**What** - toast on create - fix delete prompt message - fix 404 on delete --- FIXES CC-508
This commit is contained in:
1 parent
3320f13f5a
commit
ab9051d3f5
3 files changed
+10
-1
No files matched your search
@@ -612,6 +612,7 @@
|
|||||||
"subtitle": "Organize products into collections.",
|
"subtitle": "Organize products into collections.",
|
||||||
"createCollection": "Create Collection",
|
"createCollection": "Create Collection",
|
||||||
"createCollectionHint": "Create a new collection to organize your products.",
|
"createCollectionHint": "Create a new collection to organize your products.",
|
||||||
|
"createSuccess": "Collection created successfully.",
|
||||||
"editCollection": "Edit Collection",
|
"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.",
|
"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.",
|
"deleteWarning": "You are about to delete the collection {{title}}. This action cannot be undone.",
|
||||||
|
|||||||
+5
-1
@@ -1,5 +1,5 @@
|
|||||||
import { zodResolver } from "@hookform/resolvers/zod"
|
import { zodResolver } from "@hookform/resolvers/zod"
|
||||||
import { Button, Heading, Input, Text } from "@medusajs/ui"
|
import { Button, Heading, Input, Text, toast } from "@medusajs/ui"
|
||||||
import { useForm } from "react-hook-form"
|
import { useForm } from "react-hook-form"
|
||||||
import { useTranslation } from "react-i18next"
|
import { useTranslation } from "react-i18next"
|
||||||
import * as zod from "zod"
|
import * as zod from "zod"
|
||||||
@@ -35,6 +35,10 @@ export const CreateCollectionForm = () => {
|
|||||||
await mutateAsync(data, {
|
await mutateAsync(data, {
|
||||||
onSuccess: ({ collection }) => {
|
onSuccess: ({ collection }) => {
|
||||||
handleSuccess(`/collections/${collection.id}`)
|
handleSuccess(`/collections/${collection.id}`)
|
||||||
|
toast.success(t("general.success"), {
|
||||||
|
description: t("collections.createSuccess"),
|
||||||
|
dismissLabel: t("actions.close"),
|
||||||
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
+4
@@ -4,6 +4,7 @@ import { Container, Heading, Text, usePrompt } from "@medusajs/ui"
|
|||||||
import { useTranslation } from "react-i18next"
|
import { useTranslation } from "react-i18next"
|
||||||
import { ActionMenu } from "../../../../../components/common/action-menu"
|
import { ActionMenu } from "../../../../../components/common/action-menu"
|
||||||
import { useDeleteCollection } from "../../../../../hooks/api/collections"
|
import { useDeleteCollection } from "../../../../../hooks/api/collections"
|
||||||
|
import { useNavigate } from "react-router-dom"
|
||||||
|
|
||||||
type CollectionGeneralSectionProps = {
|
type CollectionGeneralSectionProps = {
|
||||||
collection: HttpTypes.AdminCollection
|
collection: HttpTypes.AdminCollection
|
||||||
@@ -14,6 +15,7 @@ export const CollectionGeneralSection = ({
|
|||||||
}: CollectionGeneralSectionProps) => {
|
}: CollectionGeneralSectionProps) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const prompt = usePrompt()
|
const prompt = usePrompt()
|
||||||
|
const navigate = useNavigate()
|
||||||
|
|
||||||
const { mutateAsync } = useDeleteCollection(collection.id!)
|
const { mutateAsync } = useDeleteCollection(collection.id!)
|
||||||
|
|
||||||
@@ -22,6 +24,7 @@ export const CollectionGeneralSection = ({
|
|||||||
title: t("general.areYouSure"),
|
title: t("general.areYouSure"),
|
||||||
description: t("collections.deleteWarning", {
|
description: t("collections.deleteWarning", {
|
||||||
count: 1,
|
count: 1,
|
||||||
|
title: collection.title,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -30,6 +33,7 @@ export const CollectionGeneralSection = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
await mutateAsync()
|
await mutateAsync()
|
||||||
|
navigate("../", { replace: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in new issue
Block a user