diff --git a/src/react-components/ory/helpers/error-messages.tsx b/src/react-components/ory/helpers/error-messages.tsx index a1902d3a5..2b2608b21 100644 --- a/src/react-components/ory/helpers/error-messages.tsx +++ b/src/react-components/ory/helpers/error-messages.tsx @@ -1,8 +1,10 @@ import { UiNode, UiText } from "@ory/client" import { JSX } from "react" +import { useIntl } from "react-intl" import { GridStyle, gridStyle, Severity } from "../../../theme" import { Message, MessageStyleProps } from "../../message" +import { uiTextToFormattedMessage } from "./node" export type NodeMessagesProps = { nodes?: UiNode[] @@ -11,22 +13,23 @@ export type NodeMessagesProps = { MessageStyleProps type nodeMessageProps = { - text: string - id: number + message: UiText key: string - type: string } & MessageStyleProps -const nodeMessage = ({ text, id, type, key, ...props }: nodeMessageProps) => ( - - {text} - -) +const nodeMessage = ({ key, message, ...props }: nodeMessageProps) => { + const intl = useIntl() + return ( + + {uiTextToFormattedMessage(message, intl)} + + ) +} export const NodeMessages = ({ nodes, @@ -38,12 +41,10 @@ export const NodeMessages = ({ (groups, { messages }) => { groups.push( ...messages - .map(({ text, id, type }, key) => { + .map((message, key) => { return nodeMessage({ - text, - id, - type, - key: `node-group-message-${id}-${key}`, + message, + key: `node-group-message-${message.id}-${key}`, ...messageProps, }) }) @@ -54,8 +55,8 @@ export const NodeMessages = ({ [], ) - const $messages = uiMessages?.map(({ text, id, type }, key) => - nodeMessage({ text, id, type, key: `ui-messsage-${id}-${key}` }), + const $messages = uiMessages?.map((message, key) => + nodeMessage({ message, key: `ui-messsage-${message.id}-${key}` }), ) const $allMessages = [...($groupMessages || []), ...($messages || [])] diff --git a/src/react-components/ory/helpers/node.tsx b/src/react-components/ory/helpers/node.tsx index dfb451fbc..5bb8905aa 100644 --- a/src/react-components/ory/helpers/node.tsx +++ b/src/react-components/ory/helpers/node.tsx @@ -56,8 +56,8 @@ export const getNodeLabel = (node: UiNode): UiText | undefined => { return node.meta.label } -const uiTextToFormattedMessage = ( - { id, context = {}, text }: UiText, +export const uiTextToFormattedMessage = ( + { id, context = {}, text }: Omit, intl: IntlShape, ) => intl.formatMessage(