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:
Frane Polić
2024-09-23 17:57:26 +02:00
committed by GitHub
parent 3320f13f5a
commit ab9051d3f5
3 changed files with 10 additions and 1 deletions

View File

@@ -612,6 +612,7 @@
"subtitle": "Organize products into collections.",
"createCollection": "Create Collection",
"createCollectionHint": "Create a new collection to organize your products.",
"createSuccess": "Collection created successfully.",
"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.",

View File

@@ -1,5 +1,5 @@
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 { useTranslation } from "react-i18next"
import * as zod from "zod"
@@ -35,6 +35,10 @@ export const CreateCollectionForm = () => {
await mutateAsync(data, {
onSuccess: ({ collection }) => {
handleSuccess(`/collections/${collection.id}`)
toast.success(t("general.success"), {
description: t("collections.createSuccess"),
dismissLabel: t("actions.close"),
})
},
})
})

View File

@@ -4,6 +4,7 @@ import { Container, Heading, Text, usePrompt } from "@medusajs/ui"
import { useTranslation } from "react-i18next"
import { ActionMenu } from "../../../../../components/common/action-menu"
import { useDeleteCollection } from "../../../../../hooks/api/collections"
import { useNavigate } from "react-router-dom"
type CollectionGeneralSectionProps = {
collection: HttpTypes.AdminCollection
@@ -14,6 +15,7 @@ export const CollectionGeneralSection = ({
}: CollectionGeneralSectionProps) => {
const { t } = useTranslation()
const prompt = usePrompt()
const navigate = useNavigate()
const { mutateAsync } = useDeleteCollection(collection.id!)
@@ -22,6 +24,7 @@ export const CollectionGeneralSection = ({
title: t("general.areYouSure"),
description: t("collections.deleteWarning", {
count: 1,
title: collection.title,
}),
})
@@ -30,6 +33,7 @@ export const CollectionGeneralSection = ({
}
await mutateAsync()
navigate("../", { replace: true })
}
return (