Skip to content

Commit

Permalink
Disable future years on leave management screen (#1749)
Browse files Browse the repository at this point in the history
Co-authored-by: Nishant Samel <[email protected]>
  • Loading branch information
nisusam and Nishant Samel authored Mar 22, 2024
1 parent 5bc6e48 commit 81c0337
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
18 changes: 16 additions & 2 deletions app/javascript/src/common/CustomYearPicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type customYearPickerProps = {
yearClassName?: string;
currentYear: number;
setCurrentYear: React.Dispatch<React.SetStateAction<number>>;
nextYearButtonDisabled?: boolean;
};

const defaultWrapperClassName = "flex items-center justify-center";
Expand All @@ -20,6 +21,7 @@ const CustomYearPicker = ({
yearClassName,
currentYear,
setCurrentYear,
nextYearButtonDisabled = false,
}: customYearPickerProps) => {
const range = (start, end) => {
const ans = [];
Expand All @@ -31,6 +33,10 @@ const CustomYearPicker = ({
};

const years = range(1920, currentYear + 1);
const actualYear = new Date().getFullYear();
const isNextYearButtonDisabled = nextYearButtonDisabled
? currentYear >= actualYear
: false;

const handleOnChange = selected => {
const current = parseInt(selected);
Expand Down Expand Up @@ -67,8 +73,16 @@ const CustomYearPicker = ({
))}
</select>
)}
<button className="pl-2" onClick={handleNext}>
<CaretCircleRightIcon size={13} weight="bold" />
<button
className="pl-2"
disabled={isNextYearButtonDisabled}
onClick={handleNext}
>
{isNextYearButtonDisabled ? (
<CaretCircleRightIcon color="#ADA4CE" size={13} weight="bold" />
) : (
<CaretCircleRightIcon size={13} weight="bold" />
)}
</button>
</div>
);
Expand Down
1 change: 1 addition & 0 deletions app/javascript/src/components/LeaveManagement/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const Header = ({
Leave Management
</span>
<CustomYearPicker
nextYearButtonDisabled
currentYear={currentYear}
setCurrentYear={setCurrentYear}
wrapperClassName="text-miru-han-purple-1000"
Expand Down

0 comments on commit 81c0337

Please sign in to comment.