Skip to content

Commit

Permalink
added isButtonDisabled
Browse files Browse the repository at this point in the history
  • Loading branch information
kslazykv committed Jul 23, 2024
1 parent 5811b15 commit 5ce330e
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ const InvitationsFilter = ({
};

const handleExportToExcel = async () => {
const { punchOutDateFromUtc, punchOutDateToUtc } = localFilter;
setIsExporting(true);
try {
await exportInvitationsToExcel();
Expand All @@ -309,6 +310,16 @@ const InvitationsFilter = ({
setIsExporting(false);
}
};
const isButtonDisabled = () => {
const { punchOutDateFromUtc, punchOutDateToUtc } = localFilter;
if (punchOutDateFromUtc && !punchOutDateToUtc) {
return true;
}
if (punchOutDateFromUtc && punchOutDateToUtc) {
return new Date(punchOutDateFromUtc) > new Date(punchOutDateToUtc);
}
return false;
};

return (
<Container>
Expand All @@ -319,8 +330,8 @@ const InvitationsFilter = ({
variant="ghost"
title="Export filtered IPOs to Excel"
onClick={handleExportToExcel}
disabled={isExporting}
aria-disabled={isExporting ? true : false}
disabled={isExporting || isButtonDisabled()}
aria-disabled={isExporting || isButtonDisabled() ? true : false}
aria-label={isExporting ? 'loading data' : null}
>
{isExporting ? (
Expand Down

0 comments on commit 5ce330e

Please sign in to comment.