diff --git a/src/Calendars/EventEdit.tsx b/src/Calendars/EventEdit.tsx index 372d761..f7db070 100644 --- a/src/Calendars/EventEdit.tsx +++ b/src/Calendars/EventEdit.tsx @@ -26,51 +26,46 @@ import ConfirmationDialog from "../widgets/ConfirmationDialog"; import TimezonePicker from "../widgets/TimezonePicker"; import Toast from "../widgets/Toast"; -import { Location } from "history"; -import { withRouter } from "react-router"; - import * as uuid from "uuid"; import * as ICAL from "ical.js"; -import * as EteSync from "etesync"; - import { getCurrentTimezone } from "../helpers"; import { EventType, timezoneLoadFromName } from "../pim-types"; import RRule, { RRuleOptions } from "../widgets/RRule"; import { History } from "history"; +import { CachedCollection } from "../Pim/helpers"; interface PropsType { - collections: EteSync.CollectionInfo[]; + collections: CachedCollection[]; initialCollection?: string; item?: EventType; - onSave: (event: EventType, journalUid: string, originalEvent?: EventType) => Promise; - onDelete: (event: EventType, journalUid: string) => void; + onSave: (event: EventType, collectionUid: string, originalEvent?: EventType) => Promise; + onDelete: (event: EventType, collectionUid: string) => void; onCancel: () => void; - location: Location; history: History; - duplicate: boolean; + duplicate?: boolean; } -class EventEdit extends React.PureComponent { +export default class EventEdit extends React.PureComponent { public state: { uid: string; title: string; + description: string; allDay: boolean; start?: Date; end?: Date; timezone: string | null; rrule?: RRuleOptions; location: string; - description: string; - journalUid: string; + collectionUid: string; error?: string; showDeleteDialog: boolean; }; - constructor(props: any) { + constructor(props: PropsType) { super(props); this.state = { uid: "", @@ -80,11 +75,11 @@ class EventEdit extends React.PureComponent { description: "", timezone: null, - journalUid: "", + collectionUid: "", showDeleteDialog: false, }; - const locState = this.props.location.state; + const locState = this.props.history.location.state as EventType; if (locState) { // FIXME: Hack to determine if all day. Should be passed as a proper state. this.state.allDay = (locState.start && @@ -133,9 +128,9 @@ class EventEdit extends React.PureComponent { this.state.timezone = this.state.timezone || getCurrentTimezone(); if (props.initialCollection) { - this.state.journalUid = props.initialCollection; + this.state.collectionUid = props.initialCollection; } else if (props.collections[0]) { - this.state.journalUid = props.collections[0].uid; + this.state.collectionUid = props.collections[0].collection.uid; } this.onSubmit = this.onSubmit.bind(this); @@ -238,7 +233,7 @@ class EventEdit extends React.PureComponent { event.component.updatePropertyWithValue("last-modified", ICAL.Time.now()); - this.props.onSave(event, this.state.journalUid, this.props.item) + this.props.onSave(event, this.state.collectionUid, this.props.item) .then(() => { this.props.history.goBack(); }); @@ -298,13 +293,13 @@ class EventEdit extends React.PureComponent { Saving to @@ -438,5 +433,3 @@ class EventEdit extends React.PureComponent { ); } } - -export default withRouter(EventEdit);