Skip to content

Commit

Permalink
resolve feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
SemenStruchev committed Sep 27, 2024
1 parent e9209a1 commit 8107912
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/components/DatePicker/RelativeDateRange.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ export const dateRanges = {
},
};

const filterFutureDates = (options, isFutureDatesAllowed, futureDates) => {
if (!isFutureDatesAllowed) {
return options.filter((option) => !futureDates.has(option.value));
}

return options;
};

// List of future date options
const futureDates = new Set([
options.NEXT_DAY,
Expand Down Expand Up @@ -250,15 +258,6 @@ export const RelativeDateRange = ({
onChange(rangeName, range);
};

const filterFutureDates = (options) => {
if (!isFutureDatesAllowed) {
// Filter out options if they are in the futureDates Set
return options.filter((option) => !futureDates.has(option.value));
}

return options;
};

return (
<div className="flex space-x-2">
<Select size="medium" value={value} className="pr-8 leading-5" onChange={handleChange}>
Expand All @@ -268,7 +267,7 @@ export const RelativeDateRange = ({

return (
<optgroup key={rangeKey} label={range.label}>
{filterFutureDates(range.options).map((option) => (
{filterFutureDates(range.options, isFutureDatesAllowed, futureDates).map((option) => (
<option key={option.value} value={option.value}>
{option.label}
</option>
Expand Down

0 comments on commit 8107912

Please sign in to comment.