diff --git a/src/EventEdit.tsx b/src/EventEdit.tsx index 4bd8ec9..43d9e33 100644 --- a/src/EventEdit.tsx +++ b/src/EventEdit.tsx @@ -24,6 +24,8 @@ class EventEdit extends React.Component { location: string; description: string; journalUid: string; + + error?: string; }; props: { @@ -41,9 +43,10 @@ class EventEdit extends React.Component { allDay: false, location: '', description: '', - journalUid: '', start: '', - end: '' + end: '', + + journalUid: '', }; if (this.props.event !== undefined) { const event = this.props.event; @@ -110,12 +113,14 @@ class EventEdit extends React.Component { e.preventDefault(); if ((this.state.start === '') || (this.state.end === '')) { + this.setState({error: 'Both start and end time must be set!'}); return; } const startDate = ICAL.Time.fromString(this.state.start); let endDate = ICAL.Time.fromString(this.state.end); if (startDate.compare(endDate) >= 0) { + this.setState({error: 'End time must be later than start time!'}); return; } @@ -159,6 +164,9 @@ class EventEdit extends React.Component {

{this.props.event ? 'Edit Event' : 'New Event'}

+ {this.state.error && ( +
ERROR! {this.state.error}
+ )}