Skip to content

Commit

Permalink
resolve feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
SemenStruchev committed Sep 18, 2024
1 parent 7861839 commit 3226262
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/DatePicker/DatePicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,9 @@ export const DatePicker = ({
value={rangeName}
ranges={ranges}
timezoneName={timezoneName}
isFutureDatesAllowed={isFutureDatesAllowed}
onChange={handleRelativeRangeChanged}
onSubmit={onSubmitDateRange}
isFutureDatesAllowed={isFutureDatesAllowed}
/>
</div>
</div>
Expand Down
9 changes: 6 additions & 3 deletions src/components/DatePicker/RelativeDateRange.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ export const dateRanges = {
},
};

// List of future date options
const futureDates = [options.NEXT_DAY, options.NEXT_WEEK, options.NEXT_MONTH, options.NEXT_QUARTER, options.NEXT_YEAR];

Check failure on line 89 in src/components/DatePicker/RelativeDateRange.jsx

View workflow job for this annotation

GitHub Actions / View Lint Report

src/components/DatePicker/RelativeDateRange.jsx#L89

[unicorn/prefer-set-has] `futureDates` should be a `Set`, and use `futureDates.has()` to check existence or non-existence.

const handlers = {
[options.YESTERDAY]: (timezone) => {
const yesterday = now(null, timezone).subtract(1, "day");
Expand Down Expand Up @@ -233,7 +236,7 @@ export const RelativeDateRange = ({
onChange,
onSubmit,
timezoneName,
isFutureDatesAllowed = false, // New prop
isFutureDatesAllowed = false // This prop used to be able to select Future Dates in RelativeDateRange,

Check failure on line 239 in src/components/DatePicker/RelativeDateRange.jsx

View workflow job for this annotation

GitHub Actions / View Lint Report

src/components/DatePicker/RelativeDateRange.jsx#L239

[prettier/prettier] Insert `,`
}) => {
const handleChange = (e) => {
const rangeName = e.target.value;
Expand All @@ -243,8 +246,8 @@ export const RelativeDateRange = ({

const filterFutureDates = (options) => {
if (!isFutureDatesAllowed) {
// Filter out future date options
return options.filter((option) => !option.value.includes("next"));
// Filter out options if they are in the futureDates array
return options.filter((option) => !futureDates.includes(option.value));
}
return options;

Check failure on line 252 in src/components/DatePicker/RelativeDateRange.jsx

View workflow job for this annotation

GitHub Actions / View Lint Report

src/components/DatePicker/RelativeDateRange.jsx#L252

[padding-line-between-statements] Expected blank line before this statement.
};
Expand Down

0 comments on commit 3226262

Please sign in to comment.