add beerify to account-ui (#28042)
fixes: #27966 Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
This commit is contained in:
parent
3c6a473316
commit
ceed62213d
3 changed files with 9 additions and 1 deletions
|
@ -13,6 +13,7 @@ import { ErrorOption, useForm } from "react-hook-form";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import {
|
import {
|
||||||
UserProfileFields,
|
UserProfileFields,
|
||||||
|
beerify,
|
||||||
debeerify,
|
debeerify,
|
||||||
setUserProfileServerError,
|
setUserProfileServerError,
|
||||||
useAlerts,
|
useAlerts,
|
||||||
|
@ -39,7 +40,7 @@ export const PersonalInfo = () => {
|
||||||
useState<UserProfileMetadata>();
|
useState<UserProfileMetadata>();
|
||||||
const [supportedLocales, setSupportedLocales] = useState<string[]>([]);
|
const [supportedLocales, setSupportedLocales] = useState<string[]>([]);
|
||||||
const form = useForm<UserRepresentation>({ mode: "onChange" });
|
const form = useForm<UserRepresentation>({ mode: "onChange" });
|
||||||
const { handleSubmit, reset, setError } = form;
|
const { handleSubmit, reset, setValue, setError } = form;
|
||||||
const { addAlert, addError } = useAlerts();
|
const { addAlert, addError } = useAlerts();
|
||||||
|
|
||||||
usePromise(
|
usePromise(
|
||||||
|
@ -52,6 +53,9 @@ export const PersonalInfo = () => {
|
||||||
setUserProfileMetadata(personalInfo.userProfileMetadata);
|
setUserProfileMetadata(personalInfo.userProfileMetadata);
|
||||||
setSupportedLocales(supportedLocales);
|
setSupportedLocales(supportedLocales);
|
||||||
reset(personalInfo);
|
reset(personalInfo);
|
||||||
|
Object.entries(personalInfo.attributes || {}).forEach(([k, v]) =>
|
||||||
|
setValue(`attributes[${beerify(k)}]`, v),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ export {
|
||||||
setUserProfileServerError,
|
setUserProfileServerError,
|
||||||
isUserProfileError,
|
isUserProfileError,
|
||||||
label,
|
label,
|
||||||
|
beerify,
|
||||||
debeerify,
|
debeerify,
|
||||||
} from "./user-profile/utils";
|
} from "./user-profile/utils";
|
||||||
export type { UserFormFields } from "./user-profile/utils";
|
export type { UserFormFields } from "./user-profile/utils";
|
||||||
|
|
|
@ -49,6 +49,9 @@ export const fieldName = (name?: string) =>
|
||||||
"🍺",
|
"🍺",
|
||||||
)}` as FieldPath<UserFormFields>;
|
)}` as FieldPath<UserFormFields>;
|
||||||
|
|
||||||
|
export const beerify = <T extends string>(name: T) =>
|
||||||
|
name.replaceAll(".", "🍺");
|
||||||
|
|
||||||
export const debeerify = <T extends string>(name: T) =>
|
export const debeerify = <T extends string>(name: T) =>
|
||||||
name.replaceAll("🍺", ".");
|
name.replaceAll("🍺", ".");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue