Skip to content

Commit

Permalink
Fixed duration options for yearly cadence (#18989)
Browse files Browse the repository at this point in the history
no issue

---

<!-- Leave the line below if you'd like GitHub Copilot to generate a
summary from your commit -->
<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at b84f2a0</samp>

This change improves the offer creation modal by filtering the duration
options based on the tier's cadence. This avoids showing irrelevant or
invalid options to the user and simplifies the selection process.
  • Loading branch information
ronaldlangeveld authored Nov 15, 2023
1 parent 199baac commit 44b4b16
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ const Sidebar: React.FC<SidebarProps> = ({tierOptions,
handleNameInput,
handleTextAreaInput,
amountOptions}) => {
const getFilteredDurationOptions = () => {
// Check if the selected tier's cadence is 'yearly'
if (selectedTier?.label?.includes('Yearly')) {
// Filter out 'repeating' from duration options
return durationOptions.filter(option => option.value !== 'repeating');
}
return durationOptions;
};
const filteredDurationOptions = getFilteredDurationOptions();
return (
<div className='pt-7'>
<Form>
Expand Down Expand Up @@ -124,8 +133,8 @@ const Sidebar: React.FC<SidebarProps> = ({tierOptions,
</div>
</div>
<Select
options={durationOptions}
selectedOption={overrides.duration === 'once' ? durationOptions[0] : overrides.duration === 'repeating' ? durationOptions[1] : durationOptions[2]}
options={filteredDurationOptions}
selectedOption={filteredDurationOptions.find(option => option.value === overrides.duration)}
title='Duration'
onSelect={e => handleDurationChange(e?.value || '')}
/>
Expand Down

0 comments on commit 44b4b16

Please sign in to comment.