Skip to content

Commit

Permalink
fix(pci-vouchers): use translation component for the banners
Browse files Browse the repository at this point in the history
ref: PRB0040912

Signed-off-by: Sachin Ramesh <[email protected]>
  • Loading branch information
sachinrameshn committed Oct 18, 2024
1 parent 5f9f457 commit 211e7b8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 23 deletions.
22 changes: 15 additions & 7 deletions packages/manager/apps/pci-vouchers/src/pages/AddVoucherPage.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { useNavigate, useParams } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { Translation } from 'react-i18next';
import { useNotifications } from '@ovh-ux/manager-react-components';
import AddVoucherModal from '@/components/vouchers/AddVoucherModal';

export default function AddVoucherPage() {
const { projectId } = useParams();
const { t } = useTranslation('common');
const { addError, addSuccess } = useNotifications();
const navigate = useNavigate();
const onClose = () => {
Expand All @@ -17,14 +16,23 @@ export default function AddVoucherPage() {
projectId={projectId}
onClose={onClose}
onSuccess={() => {
addSuccess(t('cpb_vouchers_add_success'));
addSuccess(
<Translation ns="common">
{(t) => t('cpb_vouchers_add_success')}
</Translation>,
true,
);
}}
onError={(error: Error) => {
addError(
<>
{t('cpb_vouchers_add_error')}
{error && ` (${error.message})`}
</>,
<Translation ns="common">
{(t) =>
t('cpb_vouchers_add_error', {
message: error?.message || null,
})
}
</Translation>,
true,
);
}}
/>
Expand Down
40 changes: 24 additions & 16 deletions packages/manager/apps/pci-vouchers/src/pages/BuyCreditPage.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { useNavigate, useParams } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { Translation } from 'react-i18next';
import { useNotifications } from '@ovh-ux/manager-react-components';
import BuyCreditModal from '@/components/vouchers/BuyCreditModal';
import style from '@/components/common.module.css';

export default function BuyCreditPage() {
const { projectId } = useParams();
const { t } = useTranslation('common');
const { addError, addSuccess } = useNotifications();
const navigate = useNavigate();
const onClose = () => {
Expand All @@ -20,24 +19,33 @@ export default function BuyCreditPage() {
onClose={onClose}
onSuccess={(amount, url) => {
addSuccess(
<span
className={style.linkContainer}
dangerouslySetInnerHTML={{
__html: t('cpb_vouchers_add_credit_success', {
amount,
url,
interpolation: { escapeValue: false },
}),
}}
></span>,
<Translation ns="common">
{(t) => (
<span
className={style.linkContainer}
dangerouslySetInnerHTML={{
__html: t('cpb_vouchers_add_credit_success', {
amount,
url,
interpolation: { escapeValue: false },
}),
}}
></span>
)}
</Translation>,
true,
);
}}
onError={(error: Error) => {
addError(
<>
{t('cpb_vouchers_add_error')}
{error && ` (${error.message})`}
</>,
<Translation ns="common">
{(t) =>
t('cpb_vouchers_add_error', {
message: error?.message || null,
})
}
</Translation>,
true,
);
}}
/>
Expand Down

0 comments on commit 211e7b8

Please sign in to comment.