fix(dashboard): Add Shipping Profile metadata route (#10430)
This commit is contained in:
1 parent
665eea8e75
commit
c6f955f0b5
5 files changed
+72
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/dashboard": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(dashboard): Add Shipping Profile metadata route
|
||||||
@@ -80,6 +80,32 @@ export const useShippingProfiles = (
|
|||||||
return { ...data, ...rest }
|
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 = (
|
export const useDeleteShippingProfile = (
|
||||||
id: string,
|
id: string,
|
||||||
options?: UseMutationOptions<
|
options?: UseMutationOptions<
|
||||||
|
|||||||
@@ -1095,6 +1095,15 @@ export const RouteMap: RouteObject[] = [
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: "metadata/edit",
|
||||||
|
lazy: () =>
|
||||||
|
import(
|
||||||
|
"../../routes/shipping-profiles/shipping-profile-metadata"
|
||||||
|
),
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
export { ShippingProfileMetadata as Component } from "./shipping-profile-metadata"
|
||||||
+31
@@ -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