Skip to content

Commit

Permalink
refactor: replace descriptions with label
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaHungDinh committed Apr 15, 2024
1 parent 98f4b7c commit d72334b
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,9 @@ const Inspector = ({attributes, setAttributes}) => {
const [donationLevels, setDonationLevels] = useState<OptionProps[]>(
levels.map((level, index) => ({
id: String(Math.floor(Math.random() * 1000000)),
label: formatCurrencyAmount(level.toString()),
label: descriptions[index] || '',
value: level.toString(),
checked: defaultLevel === level,
description: descriptions[index] || '',
}))
);

Expand Down Expand Up @@ -165,7 +164,7 @@ const Inspector = ({attributes, setAttributes}) => {
const handleLevelsChange = (options: OptionProps[]) => {
const checkedLevel = options.filter((option) => option.checked);
const newLevels = options.filter((option) => option.value).map((option) => Number(option.value));
const newDescriptions = options.map((option) => option.description);
const newDescriptions = options.map((option) => option.label);

setDonationLevels(donationLevels);
setAttributes({
Expand Down Expand Up @@ -236,7 +235,7 @@ const Inspector = ({attributes, setAttributes}) => {
onAddOption={handleLevelAdded}
onRemoveOption={handleLevelRemoved}
defaultControlsTooltip={__('Default Level', 'give')}
hasDescriptions={!!descriptions}
toggleLabel={__('Enable amount description', 'give')}
/>
)}
</PanelBody>
Expand Down

0 comments on commit d72334b

Please sign in to comment.