fix(dashboard): Add Shipping Profile metadata route (#10430)
This commit is contained in:
committed by
GitHub
parent
665eea8e75
commit
c6f955f0b5
5
.changeset/rotten-spoons-brake.md
Normal file
5
.changeset/rotten-spoons-brake.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@medusajs/dashboard": patch
|
||||
---
|
||||
|
||||
fix(dashboard): Add Shipping Profile metadata route
|
||||
@@ -80,6 +80,32 @@ export const useShippingProfiles = (
|
||||
return { ...data, ...rest }
|
||||
}
|
||||
|
||||
export const useUpdateShippingProfile = (
|
||||
id: string,
|
||||
options?: UseMutationOptions<
|
||||
HttpTypes.AdminShippingProfileResponse,
|
||||
FetchError,
|
||||
HttpTypes.AdminUpdateShippingProfile
|
||||
>
|
||||
) => {
|
||||
const { data, ...rest } = useMutation({
|
||||
mutationFn: (payload) => sdk.admin.shippingProfile.update(id, payload),
|
||||
onSuccess: (data, variables, context) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: shippingProfileQueryKeys.detail(id),
|
||||
})
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: shippingProfileQueryKeys.lists(),
|
||||
})
|
||||
|
||||
options?.onSuccess?.(data, variables, context)
|
||||
},
|
||||
...options,
|
||||
})
|
||||
|
||||
return { ...data, ...rest }
|
||||
}
|
||||
|
||||
export const useDeleteShippingProfile = (
|
||||
id: string,
|
||||
options?: UseMutationOptions<
|
||||
|
||||
@@ -1095,6 +1095,15 @@ export const RouteMap: RouteObject[] = [
|
||||
},
|
||||
}
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: "metadata/edit",
|
||||
lazy: () =>
|
||||
import(
|
||||
"../../routes/shipping-profiles/shipping-profile-metadata"
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export { ShippingProfileMetadata as Component } from "./shipping-profile-metadata"
|
||||
@@ -0,0 +1,31 @@
|
||||
import { useParams } from "react-router-dom"
|
||||
import { MetadataForm } from "../../../components/forms/metadata-form/metadata-form"
|
||||
import {
|
||||
useShippingProfile,
|
||||
useUpdateShippingProfile,
|
||||
} from "../../../hooks/api"
|
||||
|
||||
export const ShippingProfileMetadata = () => {
|
||||
const { shipping_profile_id } = useParams()
|
||||
|
||||
const { shipping_profile, isPending, isError, error } = useShippingProfile(
|
||||
shipping_profile_id!
|
||||
)
|
||||
|
||||
const { mutateAsync, isPending: isMutating } = useUpdateShippingProfile(
|
||||
shipping_profile?.id!
|
||||
)
|
||||
|
||||
if (isError) {
|
||||
throw error
|
||||
}
|
||||
|
||||
return (
|
||||
<MetadataForm
|
||||
metadata={shipping_profile?.metadata}
|
||||
hook={mutateAsync}
|
||||
isPending={isPending}
|
||||
isMutating={isMutating}
|
||||
/>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user