fix: default language if missing in profile

This commit is contained in:
Christel Westerberg
2024-08-26 10:42:55 +02:00
parent e3b97fcdf9
commit 231edbe944
5 changed files with 24 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
import { languageSelect } from "@/constants/languages"
import { languages, languageSelect } from "@/constants/languages"
import { profileEdit } from "@/constants/routes/myPages"
import { serverClient } from "@/lib/trpc/server"
@@ -29,6 +29,8 @@ export default async function Profile({ params }: PageArgs<LangParams>) {
if (!user || "error" in user) {
return null
}
const defaultLanguage = languages[params.lang]
const language = languageSelect.find((l) => l.value === user.language)
return (
<>
@@ -68,7 +70,7 @@ export default async function Profile({ params }: PageArgs<LangParams>) {
<Body color="burgundy" textTransform="bold">
{formatMessage({ id: "Language" })}
</Body>
<Body color="burgundy">{language?.label ?? "N/A"}</Body>
<Body color="burgundy">{language?.label ?? defaultLanguage}</Body>
</div>
<div className={styles.item}>
<EmailIcon color="burgundy" />