Skip to content

Commit

Permalink
fix(mrc): fix ignore translation in component property
Browse files Browse the repository at this point in the history
fixes: #gh-15421

Signed-off-by: David Arsène <[email protected]>
  • Loading branch information
darsene committed Mar 6, 2025
1 parent 8ad0f2c commit 39e51d8
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
import { OdsButton, OdsText } from '@ovhcloud/ods-components/react';
import { Trans, useTranslation } from 'react-i18next';
import React, { useEffect } from 'react';
import { Links, LinkType } from '../typography';
import { useOrderContext } from './Order.context';
import { Links, LinkType } from '../typography';

export type TOrderSummary = {
onFinish: () => void;
Expand Down Expand Up @@ -52,7 +52,7 @@ export const OrderSummary: React.FC<TOrderSummary> = ({
t={t}
i18nKey="order_summary_order_initiated_subtitle"
components={{
OrderLink: (
ExternalLink: (
<Links
type={LinkType.external}
target="_blank"
Expand All @@ -62,7 +62,7 @@ export const OrderSummary: React.FC<TOrderSummary> = ({
/>
),
}}
></Trans>
/>
</OdsText>
<OdsText preset={ODS_TEXT_PRESET.paragraph}>
{t('order_summary_order_initiated_info', { product })}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"order_summary_finish": "Terminer",
"order_summary_product_default_label": "service",
"order_summary_order_initiated_title": "Commande de votre {{product}} initiée",
"order_summary_order_initiated_subtitle": "Si vous n'avez pas pu finaliser votre commande, merci de la compléter en cliquant sur le <OrderLink label=\"lien suivant\">{{label}}</OrderLink>",
"order_summary_order_initiated_subtitle": "Si vous n'avez pas pu finaliser votre commande, merci de la compléter en cliquant sur le <ExternalLink>lien suivant</ExternalLink>",
"order_summary_order_initiated_info": "Nous vous informerons de la disponibilité de votre {{product}} par e-mail."
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { PropsWithChildren } from 'react';
import {
ODS_ICON_NAME,
ODS_LINK_COLOR,
Expand All @@ -21,6 +21,7 @@ export interface LinksProps {
color?: ODS_LINK_COLOR;
download?: string;
label?: string;
children?: string;
href?: string;
rel?: string;
target?: string;
Expand All @@ -30,7 +31,8 @@ export interface LinksProps {
isDisabled?: boolean;
}

export const Links: React.FC<LinksProps> = ({
export const Links: React.FC<LinksProps & PropsWithChildren> = ({
children,
label,
onClickReturn,
type,
Expand All @@ -39,7 +41,7 @@ export const Links: React.FC<LinksProps> = ({
iconAlignment,
className = '',
...props
}: LinksProps) => (
}) => (
<OdsLink
className={className}
href={href}
Expand All @@ -55,7 +57,7 @@ export const Links: React.FC<LinksProps> = ({
})}
{...(type === LinkType.next && { icon: ODS_ICON_NAME.arrowRight })}
{...(type === LinkType.external && { icon: ODS_ICON_NAME.externalLink })}
label={label}
label={label ?? children}
/>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('Links component', () => {
const linkElement = container.querySelector('[label="Next Page"]');
expect(linkElement).toBeInTheDocument();
});
it('renders a external link correctly', () => {
it('renders a external link correctly with label as prop', () => {
const props = {
href: 'https://www.ovhcloud.com/',
target: '_blank',
Expand All @@ -37,4 +37,17 @@ describe('Links component', () => {

expect(linkElement).toBeInTheDocument();
});

it('renders a external link correctly with label as children', () => {
const props = {
href: 'https://www.ovhcloud.com/',
target: '_blank',
type: LinkType.external,
};

const { container } = render(<Links {...props}>External Page</Links>);
const linkElement = container.querySelector('[label="External Page"]');

expect(linkElement).toBeInTheDocument();
});
});

0 comments on commit 39e51d8

Please sign in to comment.