fix(dashboard): Add Metadata form to variant page (#10285)
Adds Metadata form to the Product Variant details page.
This commit is contained in:
committed by
GitHub
parent
acdcbacd87
commit
344a6c9ea0
5
.changeset/silent-bears-teach.md
Normal file
5
.changeset/silent-bears-teach.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@medusajs/dashboard": patch
|
||||
---
|
||||
|
||||
fix(dashboard): Add Metadata form to Variant page
|
||||
@@ -174,6 +174,13 @@ export const RouteMap: RouteObject[] = [
|
||||
"../../routes/product-variants/product-variant-manage-inventory-items"
|
||||
),
|
||||
},
|
||||
{
|
||||
path: "metadata/edit",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../routes/product-variants/product-variant-metadata"
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export { ProductVariantMetadata as Component } from "./product-variant-metadata"
|
||||
@@ -0,0 +1,30 @@
|
||||
import { useParams } from "react-router-dom"
|
||||
import { MetadataForm } from "../../../components/forms/metadata-form/metadata-form"
|
||||
import { useProductVariant, useUpdateProductVariant } from "../../../hooks/api"
|
||||
|
||||
export const ProductVariantMetadata = () => {
|
||||
const { id, variant_id } = useParams()
|
||||
|
||||
const { variant, isPending, isError, error } = useProductVariant(
|
||||
id!,
|
||||
variant_id!
|
||||
)
|
||||
|
||||
const { mutateAsync, isPending: isMutating } = useUpdateProductVariant(
|
||||
id!,
|
||||
variant_id!
|
||||
)
|
||||
|
||||
if (isError) {
|
||||
throw error
|
||||
}
|
||||
|
||||
return (
|
||||
<MetadataForm
|
||||
metadata={variant?.metadata}
|
||||
hook={mutateAsync}
|
||||
isPending={isPending}
|
||||
isMutating={isMutating}
|
||||
/>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user