Skip to content

Commit

Permalink
fix(admin-ui): Fix affix logic of CurrencyInputComponent
Browse files Browse the repository at this point in the history
Relates to #971
  • Loading branch information
michaelbromley committed Jul 8, 2021
1 parent bf728d6 commit bcb57b0
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,18 @@ export class CurrencyInputComponent implements ControlValueAccessor, OnInit, OnC
return '';
}
const locale = languageCode.replace(/_/g, '-');
const parts = new Intl.NumberFormat(locale, {
style: 'currency',
currency: currencyCode,
currencyDisplay: 'symbol',
}).formatToParts();
const NaNString = parts.find(p => p.type === 'nan')?.value ?? 'NaN';
const localised = new Intl.NumberFormat(locale, {
style: 'currency',
currency: currencyCode,
currencyDisplay: 'symbol',
}).format(undefined as any);
return localised.indexOf('NaN') > 0;
return localised.indexOf(NaNString) > 0;
}),
);
this.prefix$ = shouldPrefix$.pipe(map(shouldPrefix => (shouldPrefix ? this.currencyCode : '')));
Expand Down

0 comments on commit bcb57b0

Please sign in to comment.