feat(dashboard, medusa) add metadata to pages (#9433)

**WIP**
- add metadata component and edit route to missing pages
- fix API issues around metadata in certain domains

---

FIXES CC-554
This commit is contained in:
Frane Polić
2024-10-06 11:57:56 +00:00
committed by GitHub
parent ffc35f2b6e
commit d6b452b734
25 changed files with 358 additions and 98 deletions
@@ -7,6 +7,7 @@ import { userLoader } from "./loader"
import after from "virtual:medusa/widgets/user/details/after"
import before from "virtual:medusa/widgets/user/details/before"
import { SingleColumnPage } from "../../../components/layout/pages"
export const UserDetail = () => {
const initialData = useLoaderData() as Awaited<ReturnType<typeof userLoader>>
@@ -34,7 +35,16 @@ export const UserDetail = () => {
}
return (
<div className="flex flex-col gap-y-2">
<SingleColumnPage
widgets={{
before,
after,
}}
data={user}
hasOutlet
showMetadata
showJSON
>
{before.widgets.map((w, i) => (
<div key={i}>
<w.Component data={user} />
@@ -46,8 +56,6 @@ export const UserDetail = () => {
<w.Component data={user} />
</div>
))}
<JsonViewSection data={user} />
<Outlet />
</div>
</SingleColumnPage>
)
}
@@ -0,0 +1 @@
export { UserMetadata as Component } from "./user-metadata"
@@ -0,0 +1,27 @@
import { useParams } from "react-router-dom"
import { MetadataForm } from "../../../components/forms/metadata-form"
import { RouteDrawer } from "../../../components/modals"
import { useUpdateUser, useUser } from "../../../hooks/api"
export const UserMetadata = () => {
const { id } = useParams()
const { user, isPending, isError, error } = useUser(id)
const { mutateAsync, isPending: isMutating } = useUpdateUser(id)
if (isError) {
throw error
}
return (
<RouteDrawer>
<MetadataForm
isPending={isPending}
isMutating={isMutating}
hook={mutateAsync}
metadata={user?.metadata}
/>
</RouteDrawer>
)
}