debeerify in account as user profile can have dots (#26680)
fixes: #26635 Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
This commit is contained in:
parent
750bc2c09c
commit
8d3d94f904
3 changed files with 13 additions and 2 deletions
|
@ -14,6 +14,7 @@ import { ErrorOption, useForm } from "react-hook-form";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import {
|
import {
|
||||||
UserProfileFields,
|
UserProfileFields,
|
||||||
|
debeerify,
|
||||||
setUserProfileServerError,
|
setUserProfileServerError,
|
||||||
useAlerts,
|
useAlerts,
|
||||||
} from "ui-shared";
|
} from "ui-shared";
|
||||||
|
@ -58,8 +59,14 @@ export const PersonalInfo = () => {
|
||||||
|
|
||||||
const onSubmit = async (user: UserRepresentation) => {
|
const onSubmit = async (user: UserRepresentation) => {
|
||||||
try {
|
try {
|
||||||
await savePersonalInfo(context, user);
|
const attributes = Object.fromEntries(
|
||||||
const locale = user.attributes?.["locale"]?.toString();
|
Object.entries(user.attributes || {}).map(([k, v]) => [
|
||||||
|
debeerify(k),
|
||||||
|
v,
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
await savePersonalInfo(context, { ...user, attributes });
|
||||||
|
const locale = attributes["locale"]?.toString();
|
||||||
i18n.changeLanguage(locale, (error) => {
|
i18n.changeLanguage(locale, (error) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.warn("Error(s) loading locale", locale, error);
|
console.warn("Error(s) loading locale", locale, error);
|
||||||
|
|
|
@ -20,6 +20,7 @@ export {
|
||||||
setUserProfileServerError,
|
setUserProfileServerError,
|
||||||
isUserProfileError,
|
isUserProfileError,
|
||||||
label,
|
label,
|
||||||
|
debeerify,
|
||||||
} from "./user-profile/utils";
|
} from "./user-profile/utils";
|
||||||
export type { UserFormFields } from "./user-profile/utils";
|
export type { UserFormFields } from "./user-profile/utils";
|
||||||
export { ScrollForm, mainPageContentId } from "./scroll-form/ScrollForm";
|
export { ScrollForm, mainPageContentId } from "./scroll-form/ScrollForm";
|
||||||
|
|
|
@ -49,6 +49,9 @@ export const fieldName = (name?: string) =>
|
||||||
"🍺",
|
"🍺",
|
||||||
)}` as FieldPath<UserFormFields>;
|
)}` as FieldPath<UserFormFields>;
|
||||||
|
|
||||||
|
export const debeerify = <T extends string>(name: T) =>
|
||||||
|
name.replaceAll("🍺", ".");
|
||||||
|
|
||||||
export function setUserProfileServerError<T>(
|
export function setUserProfileServerError<T>(
|
||||||
error: UserProfileError,
|
error: UserProfileError,
|
||||||
setError: (field: keyof T, params: object) => void,
|
setError: (field: keyof T, params: object) => void,
|
||||||
|
|
Loading…
Reference in a new issue