Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Add default currency value for Storybook #8332

Closed
wants to merge 4 commits into from
Closed
Changes from 2 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
7 changes: 5 additions & 2 deletions assets/js/base/components/formatted-monetary-amount/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ const FormattedMonetaryAmount = ( {
return null;
}

const priceValue = value / 10 ** currency.minorUnit;
const minorUnit =
typeof currency?.minorUnit === 'undefined' ? 2 : currency.minorUnit;

const priceValue = value / 10 ** minorUnit;

if ( ! Number.isFinite( priceValue ) ) {
return null;
Expand All @@ -94,7 +97,7 @@ const FormattedMonetaryAmount = ( {
// Wrapper for NumberFormat onValueChange which handles subunit conversion.
const onValueChangeWrapper = onValueChange
? ( values: NumberFormatValues ) => {
const minorUnitValue = +values.value * 10 ** currency.minorUnit;
const minorUnitValue = +values.value * 10 ** minorUnit;
onValueChange( minorUnitValue );
}
: () => void 0;
Expand Down