Skip to content

Commit

Permalink
not highlighting the end date in red if the date in future
Browse files Browse the repository at this point in the history
  • Loading branch information
Nebyt committed Sep 30, 2024
1 parent c02d6c2 commit 92280a0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { DatePicker } from '@mui/x-date-pickers/DatePicker';
import { observer } from 'mobx-react';
import { defineMessages, intlShape } from 'react-intl';
import type { $npm$ReactIntl$IntlFormat } from 'react-intl';
import moment from 'moment';

const messages = defineMessages({
startDate: {
Expand Down Expand Up @@ -71,7 +70,6 @@ export default class ExportTransactionDialog extends Component<Props> {
key={id}
label={intl.formatMessage(label)}
value={value}
maxDate={moment()} // Today
minDate={minDate}
onChange={setDateHandler}
slotProps={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import globalMessages from '../../../i18n/global-messages';
import CheckboxLabel from '../../common/CheckboxLabel';
import DateRange from './DateRange';
import { Box } from '@mui/system';
import moment, { Moment } from 'moment';
import { Moment } from 'moment';
import { withLayout } from '../../../styles/context/layout';
import type { InjectedLayoutProps } from '../../../styles/context/layout';
import { Checkbox, FormControlLabel } from '@mui/material';
Expand Down Expand Up @@ -85,20 +85,15 @@ class ExportTransactionDialog extends Component<Props & InjectedLayoutProps, Sta
</Box>
);

const startDateIsCorrect = (): boolean => {
return startDate !== null && startDate.isValid() && startDate.isSameOrBefore(endDate)
}

const endDateIsCorrect = (): boolean => {
return endDate !== null && endDate.isValid() && endDate.isSameOrBefore(moment());
}
const startDateIsCorrect = startDate !== null && startDate.isValid() && startDate.isSameOrBefore(endDate);
const endDateIsCorrect = endDate !== null && endDate.isValid();

const dialogActions = [
{
label: intl.formatMessage(globalMessages.exportButtonLabel),
primary: true,
isSubmitting: isActionProcessing || false,
disabled: !startDateIsCorrect() || !endDateIsCorrect(),
disabled: !startDateIsCorrect || !endDateIsCorrect,
onClick: () => submit({ startDate, endDate }),
},
];
Expand Down

0 comments on commit 92280a0

Please sign in to comment.