Skip to content

Commit

Permalink
fixed year mode possible values for DatePicker
Browse files Browse the repository at this point in the history
  • Loading branch information
siarhei-epam committed Jul 10, 2024
1 parent e53cdcf commit 8842954
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions uui/components/datePickers/DatePickerHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ export interface DatePickerHeaderProps extends IHasCX {
navIconRight?: Icon;
}

const isSoberYear = (value: Dayjs) => {
return value.year() >= 1990 && value.year() <= 2099;
const MIN_SOBER_YEAR = 1000;
const MAX_SOBER_YEAR = 2200;

const isYearWithinSoberRange = (value: Dayjs) => {
const year = value.year();
return year >= MIN_SOBER_YEAR && year <= MAX_SOBER_YEAR;
};

export function DatePickerHeader({
Expand Down Expand Up @@ -115,8 +119,8 @@ export function DatePickerHeader({
[view, month],
);

const disablePrev = view === 'YEAR_SELECTION' && !isSoberYear(getPrevYearsList(month));
const disableNext = view === 'YEAR_SELECTION' && !isSoberYear(getNextYearsList(month));
const disablePrev = view === 'YEAR_SELECTION' && !isYearWithinSoberRange(getPrevYearsList(month));
const disableNext = view === 'YEAR_SELECTION' && !isYearWithinSoberRange(getNextYearsList(month));

return (
<div className={ cx(css.container, uuiHeader.container, cx) }>
Expand Down

0 comments on commit 8842954

Please sign in to comment.