components: EventEdit state name "rruleOptions" to "rrule"

master
Tal Leibman 5 years ago committed by Tom Hacohen
parent bd98d833aa
commit 0661190aef

@ -57,7 +57,7 @@ class EventEdit extends React.PureComponent<PropsType> {
location: string; location: string;
description: string; description: string;
journalUid: string; journalUid: string;
rruleOptions?: RRuleOptions; rrule?: RRuleOptions;
error?: string; error?: string;
showDeleteDialog: boolean; showDeleteDialog: boolean;
}; };
@ -105,7 +105,7 @@ class EventEdit extends React.PureComponent<PropsType> {
this.state.location = event.location ? event.location : ''; this.state.location = event.location ? event.location : '';
this.state.description = event.description ? event.description : ''; this.state.description = event.description ? event.description : '';
this.state.timezone = event.timezone; this.state.timezone = event.timezone;
this.state.rruleOptions = this.props.item?.component.getFirstPropertyValue('rrule'); this.state.rrule = this.props.item?.component.getFirstPropertyValue('rrule');
} else { } else {
this.state.uid = uuid.v4(); this.state.uid = uuid.v4();
} }
@ -159,14 +159,13 @@ class EventEdit extends React.PureComponent<PropsType> {
this.setState({ allDay: !this.state.allDay }); this.setState({ allDay: !this.state.allDay });
} }
public toggleRecurring() { public toggleRecurring() {
const value = this.state.rruleOptions ? undefined : { freq: 'WEEKLY', interval: 1 }; const value = this.state.rrule ? undefined : { freq: 'WEEKLY', interval: 1 };
this.setState({ rruleOptions: value }); this.setState({ rrule: value });
} }
public handleRRuleChange(rrule: RRuleOptions): void { public handleRRuleChange(rrule: RRuleOptions): void {
this.setState({ rruleOptions: rrule }); this.setState({ rrule: rrule });
console.log(rrule);
} }
public onSubmit(e: React.FormEvent<any>) { public onSubmit(e: React.FormEvent<any>) {
e.preventDefault(); e.preventDefault();
@ -354,7 +353,7 @@ class EventEdit extends React.PureComponent<PropsType> {
control={ control={
<Switch <Switch
name="recurring" name="recurring"
checked={!!this.state.rruleOptions} checked={!!this.state.rrule}
onChange={this.toggleRecurring} onChange={this.toggleRecurring}
color="primary" color="primary"
/> />
@ -362,9 +361,10 @@ class EventEdit extends React.PureComponent<PropsType> {
label="Recurring" label="Recurring"
/> />
</FormGroup> </FormGroup>
{this.state.rrule &&
<RRule <RRule
onChange={this.handleRRuleChange} onChange={this.handleRRuleChange}
rrule={this.state.rruleOptions ? this.state.rruleOptions : { freq: 'DAILY', interval: 1 }} rrule={this.state.rrule ? this.state.rrule : { freq: 'DAILY', interval: 1 }}
/> />
} }
<div style={styles.submit}> <div style={styles.submit}>

Loading…
Cancel
Save