Skip to content

Commit

Permalink
Fix expiry date validation by updating onChange handler
Browse files Browse the repository at this point in the history
  • Loading branch information
rsnyman committed May 9, 2023
1 parent b7bd3c2 commit 3af9444
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions frontend/src/components/add-token-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@ import {
import { ExclamationCircleIcon } from '@patternfly/react-icons';


function getToday() {
const now = new Date();
return now.toISOString().split('T')[0];
}

function dateParse(val) {
return val && val.split('-').length === 3 && new Date(`${val}T00:00:00`);
}

export class AddTokenModal extends React.Component {
static propTypes = {
onSave: PropTypes.func,
Expand All @@ -34,7 +25,7 @@ export class AddTokenModal extends React.Component {
super(props);
this.state = {
name: '',
expiryDate: getToday(),
expiryDate: '',
isNameValid: true,
isExpiryValid: true
};
Expand All @@ -44,7 +35,7 @@ export class AddTokenModal extends React.Component {
this.setState({name});
}

onExpiryDateChange = (expiryStr) => {
onExpiryDateChange = (_event, expiryStr) => {
this.setState({expiryDate: expiryStr});
}

Expand Down Expand Up @@ -124,7 +115,6 @@ export class AddTokenModal extends React.Component {
>
<DatePicker
appendTo={() => document.getElementById('add-token-modal')}
dateParse={dateParse}
onChange={this.onExpiryDateChange}
value={this.state.expiryDate}
inputProps={{
Expand Down

0 comments on commit 3af9444

Please sign in to comment.