Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/components/modal/v2/parts/OfferAccordion.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @jsx h */
import { h } from 'preact';
import { useEffect, useState } from 'preact/hooks';
import { delocalize, localize } from '../lib';
import Icon from './Icon';

const OfferAccordion = ({
Expand All @@ -16,7 +17,18 @@ const OfferAccordion = ({
const [open, setOpen] = useState('');
const { termsLabel } = content;
const currencySymbolFormat = str => {
return str.replace(/(\s?EUR)/g, ' €');
let result = str?.replace(/(\s?EUR)/g, ' €') ?? '';
if (offerCountry === 'AT' && result) {
// Reformat the numeric part using the locale's number style so the thousands separator
// matches what the calculator input field displays (de-AT number format uses narrow
// no-break space, whereas de-AT currency format uses period).
const withoutSymbol = result.replace(/\s*€/, '').trim();
const numericValue = parseFloat(delocalize(withoutSymbol, offerCountry));
if (!Number.isNaN(numericValue)) {
result = `${localize(numericValue, offerCountry, 2)} €`;
}
}
return result;
};

useEffect(() => {
Expand Down
Loading