diff --git a/CHANGELOG.md b/CHANGELOG.md index 57b6c31a..60dd973c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ * ECS - Display all consortium tenants in the affiliation selection of the location lookup. Refs UISACQCOMP-202. * Add isMultiSelect prop to DonorsLookup component. Refs UISACQCOMP-212. * ECS - Add `isLoading` prop for `ConsortiumFieldInventory` component. Refs UISACQCOMP-215. +* Allow TypeToggle component to accept values in format `'\"Value\"'`. Refs UISACQCOMP-216. ## [5.1.1](https://github.com/folio-org/stripes-acq-components/tree/v5.1.1) (2024-04-22) [Full Changelog](https://github.com/folio-org/stripes-acq-components/compare/v5.1.0...v5.1.1) diff --git a/lib/TypeToggle/TypeToggle.js b/lib/TypeToggle/TypeToggle.js index 6e8abb6a..db66d290 100644 --- a/lib/TypeToggle/TypeToggle.js +++ b/lib/TypeToggle/TypeToggle.js @@ -19,19 +19,21 @@ const TypeToggle = ({ onChangeToAmount, onChangeToPercent, }) => { + const normalizedValue = value.replace(/"/g, '').toLowerCase(); + const switchToAmount = useCallback(() => { - if (value !== FUND_DISTR_TYPE.amount) { + if (normalizedValue !== FUND_DISTR_TYPE.amount) { onChange(FUND_DISTR_TYPE.amount); if (onChangeToAmount) onChangeToAmount(name); } - }, [name, onChange, onChangeToAmount, value]); + }, [name, onChange, onChangeToAmount, normalizedValue]); const switchToPercent = useCallback(() => { - if (value !== FUND_DISTR_TYPE.percent) { + if (normalizedValue !== FUND_DISTR_TYPE.percent) { onChange(FUND_DISTR_TYPE.percent); if (onChangeToPercent) onChangeToPercent(name); } - }, [name, onChange, onChangeToPercent, value]); + }, [name, onChange, onChangeToPercent, normalizedValue]); return ( @@ -41,7 +43,7 @@ const TypeToggle = ({ >