From a5c8cc992ce9f1dbed6b30048f99fa5bae4af05a Mon Sep 17 00:00:00 2001
From: Kasper Fabricius Kristensen
<45367945+kasperkristensen@users.noreply.github.com>
Date: Wed, 4 Dec 2024 10:44:04 +0100
Subject: [PATCH] fix(dashboard): Prevent language ptBR from breaking dashboard
(#10422)
---
.changeset/odd-lamps-invite.md | 5 +++++
packages/admin/dashboard/src/i18n/translations/index.ts | 2 +-
.../src/providers/i18n-provider/i18n-provider.tsx | 6 +++++-
.../components/edit-profile-form/edit-profile-form.tsx | 4 ++--
.../src/routes/profile/profile-edit/profile-edit.tsx | 8 ++++----
5 files changed, 17 insertions(+), 8 deletions(-)
create mode 100644 .changeset/odd-lamps-invite.md
diff --git a/.changeset/odd-lamps-invite.md b/.changeset/odd-lamps-invite.md
new file mode 100644
index 0000000000000..da82ac147f9bc
--- /dev/null
+++ b/.changeset/odd-lamps-invite.md
@@ -0,0 +1,5 @@
+---
+"@medusajs/dashboard": patch
+---
+
+fix(dashboard): Prevent language ptBR from breaking dashboard
diff --git a/packages/admin/dashboard/src/i18n/translations/index.ts b/packages/admin/dashboard/src/i18n/translations/index.ts
index 0e7918f05c0d5..cca0a445277b7 100644
--- a/packages/admin/dashboard/src/i18n/translations/index.ts
+++ b/packages/admin/dashboard/src/i18n/translations/index.ts
@@ -5,8 +5,8 @@ import fr from "./fr.json"
import it from "./it.json"
import pl from "./pl.json"
import ptBR from "./ptBR.json"
-import tr from "./tr.json"
import th from "./th.json"
+import tr from "./tr.json"
export default {
de: {
diff --git a/packages/admin/dashboard/src/providers/i18n-provider/i18n-provider.tsx b/packages/admin/dashboard/src/providers/i18n-provider/i18n-provider.tsx
index 6da3118eb8772..29944ef2b96eb 100644
--- a/packages/admin/dashboard/src/providers/i18n-provider/i18n-provider.tsx
+++ b/packages/admin/dashboard/src/providers/i18n-provider/i18n-provider.tsx
@@ -5,6 +5,10 @@ import { languages } from "../../i18n/languages"
type I18nProviderProps = PropsWithChildren
+const formatLocaleCode = (code: string) => {
+ return code.replace(/([a-z])([A-Z])/g, "$1-$2")
+}
+
export const I18nProvider = ({ children }: I18nProviderProps) => {
const { i18n } = useTranslation()
@@ -12,5 +16,5 @@ export const I18nProvider = ({ children }: I18nProviderProps) => {
languages.find((lan) => lan.code === i18n.language)?.code ||
languages[0].code
- return {children}
+ return {children}
}
diff --git a/packages/admin/dashboard/src/routes/profile/profile-edit/components/edit-profile-form/edit-profile-form.tsx b/packages/admin/dashboard/src/routes/profile/profile-edit/components/edit-profile-form/edit-profile-form.tsx
index a8439cff35e5f..2f65a48f5d49e 100644
--- a/packages/admin/dashboard/src/routes/profile/profile-edit/components/edit-profile-form/edit-profile-form.tsx
+++ b/packages/admin/dashboard/src/routes/profile/profile-edit/components/edit-profile-form/edit-profile-form.tsx
@@ -4,7 +4,7 @@ import { useForm } from "react-hook-form"
import { useTranslation } from "react-i18next"
import * as zod from "zod"
-import { UserDTO } from "@medusajs/types"
+import { HttpTypes } from "@medusajs/types"
import { Form } from "../../../../../components/common/form"
import { RouteDrawer, useRouteModal } from "../../../../../components/modals"
import { KeyboundForm } from "../../../../../components/utilities/keybound-form"
@@ -12,7 +12,7 @@ import { useUpdateUser } from "../../../../../hooks/api/users"
import { languages } from "../../../../../i18n/languages"
type EditProfileProps = {
- user: Partial>
+ user: HttpTypes.AdminUser
// usageInsights: boolean
}
diff --git a/packages/admin/dashboard/src/routes/profile/profile-edit/profile-edit.tsx b/packages/admin/dashboard/src/routes/profile/profile-edit/profile-edit.tsx
index 4bc89eb4e55c1..5ed2412284f22 100644
--- a/packages/admin/dashboard/src/routes/profile/profile-edit/profile-edit.tsx
+++ b/packages/admin/dashboard/src/routes/profile/profile-edit/profile-edit.tsx
@@ -16,11 +16,11 @@ export const ProfileEdit = () => {
return (
- {t("profile.edit.header")}
+
+ {t("profile.edit.header")}
+
- {!isLoading && user && (
-
- )}
+ {!isLoading && user && }
)
}