From 81c27e35247b10c2ef834ff2d8749eaccc3e6637 Mon Sep 17 00:00:00 2001 From: Kasper Fabricius Kristensen <45367945+kasperkristensen@users.noreply.github.com> Date: Mon, 27 May 2024 17:45:51 +0200 Subject: [PATCH] feat(dashboard,admin-shared): InjectionZones for Profile, Store, Users and Login (#7471) --- .../src/extensions/widgets/constants.ts | 20 +++ .../dashboard/src/routes/login/login.tsx | 124 ++++++++++-------- .../profile/profile-detail/profile-detail.tsx | 14 ++ .../store/store-detail/store-detail.tsx | 13 ++ .../routes/users/user-detail/user-detail.tsx | 14 ++ .../src/routes/users/user-list/user-list.tsx | 14 ++ 6 files changed, 147 insertions(+), 52 deletions(-) diff --git a/packages/admin-next/admin-shared/src/extensions/widgets/constants.ts b/packages/admin-next/admin-shared/src/extensions/widgets/constants.ts index e12cec4037..6c3c6f095c 100644 --- a/packages/admin-next/admin-shared/src/extensions/widgets/constants.ts +++ b/packages/admin-next/admin-shared/src/extensions/widgets/constants.ts @@ -82,6 +82,23 @@ const GIFT_CARD_INJECTION_ZONES = [ "custom_gift_card.after", ] as const +const USER_INJECTION_ZONES = [ + "user.details.before", + "user.details.after", + "user.list.before", + "user.list.after", +] as const + +const STORE_INJECTION_ZONES = [ + "store.details.before", + "store.details.after", +] as const + +const PROFILE_INJECTION_ZONES = [ + "profile.details.before", + "profile.details.after", +] as const + const REGION_INJECTION_ZONES = [ "region.details.before", "region.details.after", @@ -122,6 +139,9 @@ export const INJECTION_ZONES = [ ...PRICE_LIST_INJECTION_ZONES, ...PROMOTION_INJECTION_ZONES, ...GIFT_CARD_INJECTION_ZONES, + ...USER_INJECTION_ZONES, + ...STORE_INJECTION_ZONES, + ...PROFILE_INJECTION_ZONES, ...REGION_INJECTION_ZONES, ...SHIPPING_PROFILE_INJECTION_ZONES, ...LOCATION_INJECTION_ZONES, diff --git a/packages/admin-next/dashboard/src/routes/login/login.tsx b/packages/admin-next/dashboard/src/routes/login/login.tsx index b9938fafd9..3829d21849 100644 --- a/packages/admin-next/dashboard/src/routes/login/login.tsx +++ b/packages/admin-next/dashboard/src/routes/login/login.tsx @@ -5,11 +5,15 @@ import { Trans, useTranslation } from "react-i18next" import { Link, useLocation, useNavigate } from "react-router-dom" import * as z from "zod" +import { Divider } from "../../components/common/divider" import { Form } from "../../components/common/form" import { LogoBox } from "../../components/common/logo-box" import { useEmailPassLogin } from "../../hooks/api/auth" import { isAxiosError } from "../../lib/is-axios-error" +import after from "virtual:medusa/widgets/login/after" +import before from "virtual:medusa/widgets/login/before" + const LoginSchema = z.object({ email: z.string().email(), password: z.string(), @@ -76,58 +80,74 @@ export const Login = () => { {t("login.hint")} -
- -
- { - return ( - - {t("fields.email")} - - - - - - ) - }} - /> - { - return ( - - {t("fields.password")} - - - - - - ) - }} - /> -
- -
- {serverError && ( - - {serverError} - - )} - -
+
+ {before.widgets.map((w, i) => { + return ( +
+ +
+ ) + })} +
+ +
+ { + return ( + + {t("fields.email")} + + + + + + ) + }} + /> + { + return ( + + {t("fields.password")} + + + + + + ) + }} + /> +
+ +
+ {serverError && ( + + {serverError} + + )} + + {after.widgets.map((w, i) => { + return ( +
+ +
+ ) + })} +
+ { const { user, isPending: isLoading, isError, error } = useMe() @@ -19,7 +23,17 @@ export const ProfileDetail = () => { return (
+ {before.widgets.map((w, i) => ( +
+ +
+ ))} + {after.widgets.map((w, i) => ( +
+ +
+ ))}
) diff --git a/packages/admin-next/dashboard/src/routes/store/store-detail/store-detail.tsx b/packages/admin-next/dashboard/src/routes/store/store-detail/store-detail.tsx index bba37aeb41..204713b35a 100644 --- a/packages/admin-next/dashboard/src/routes/store/store-detail/store-detail.tsx +++ b/packages/admin-next/dashboard/src/routes/store/store-detail/store-detail.tsx @@ -6,6 +6,9 @@ import { StoreCurrencySection } from "./components/store-currency-section/store- import { StoreGeneralSection } from "./components/store-general-section/index.ts" import { storeLoader } from "./loader.ts" +import after from "virtual:medusa/widgets/store/details/after" +import before from "virtual:medusa/widgets/store/details/before" + export const StoreDetail = () => { const initialData = useLoaderData() as Awaited> @@ -28,8 +31,18 @@ export const StoreDetail = () => { return (
+ {before.widgets.map((w, i) => ( +
+ +
+ ))} + {after.widgets.map((w, i) => ( +
+ +
+ ))}
diff --git a/packages/admin-next/dashboard/src/routes/users/user-detail/user-detail.tsx b/packages/admin-next/dashboard/src/routes/users/user-detail/user-detail.tsx index 66df154209..c4d554da59 100644 --- a/packages/admin-next/dashboard/src/routes/users/user-detail/user-detail.tsx +++ b/packages/admin-next/dashboard/src/routes/users/user-detail/user-detail.tsx @@ -1,9 +1,13 @@ import { Outlet, json, useLoaderData, useParams } from "react-router-dom" + import { JsonViewSection } from "../../../components/common/json-view-section" import { useUser } from "../../../hooks/api/users" import { UserGeneralSection } from "./components/user-general-section" import { userLoader } from "./loader" +import after from "virtual:medusa/widgets/user/details/after" +import before from "virtual:medusa/widgets/user/details/before" + export const UserDetail = () => { const initialData = useLoaderData() as Awaited> @@ -31,7 +35,17 @@ export const UserDetail = () => { return (
+ {before.widgets.map((w, i) => ( +
+ +
+ ))} + {after.widgets.map((w, i) => ( +
+ +
+ ))}
diff --git a/packages/admin-next/dashboard/src/routes/users/user-list/user-list.tsx b/packages/admin-next/dashboard/src/routes/users/user-list/user-list.tsx index c90a5215fd..4822380c16 100644 --- a/packages/admin-next/dashboard/src/routes/users/user-list/user-list.tsx +++ b/packages/admin-next/dashboard/src/routes/users/user-list/user-list.tsx @@ -1,10 +1,24 @@ import { Outlet } from "react-router-dom" + import { UserListTable } from "./components/user-list-table" +import after from "virtual:medusa/widgets/user/list/after" +import before from "virtual:medusa/widgets/user/list/before" + export const UserList = () => { return (
+ {before.widgets.map((w, i) => ( +
+ +
+ ))} + {after.widgets.map((w, i) => ( +
+ +
+ ))}
)