diff --git a/package.json b/package.json index feb59f6..d28e2bb 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,8 @@ "redux-persist": "^5.4.0", "redux-thunk": "^2.2.0", "sjcl": "git+https://github.com/etesync/sjcl", - "urijs": "^1.16.1" + "urijs": "^1.16.1", + "uuid": "^3.1.0" }, "scripts": { "start": "react-scripts-ts start", @@ -42,6 +43,7 @@ "@types/redux-actions": "^2.2.3", "@types/redux-logger": "^3.0.5", "@types/sjcl": "^1.0.28", - "@types/urijs": "^1.15.34" + "@types/urijs": "^1.15.34", + "@types/uuid": "^3.4.3" } } diff --git a/src/EventEdit.tsx b/src/EventEdit.tsx index 863720c..53ad48b 100644 --- a/src/EventEdit.tsx +++ b/src/EventEdit.tsx @@ -7,6 +7,7 @@ import MenuItem from 'material-ui/MenuItem'; import DateTimePicker from './DateTimePicker'; +import * as uuid from 'uuid'; import * as ICAL from 'ical.js'; import * as EteSync from './api/EteSync'; @@ -15,6 +16,7 @@ import { EventType } from './pim-types'; class EventEdit extends React.Component { state: { + uid: string, title: string; allDay: boolean; start: string; @@ -34,6 +36,7 @@ class EventEdit extends React.Component { constructor(props: any) { super(props); this.state = { + uid: '', title: '', allDay: false, location: '', @@ -45,12 +48,15 @@ class EventEdit extends React.Component { if (this.props.event !== undefined) { const event = this.props.event; + this.state.uid = event.uid; this.state.title = event.title ? event.title : ''; this.state.allDay = event.startDate.isDate; this.state.start = event.startDate.toString(); this.state.end = event.endDate.toString(); this.state.location = event.location ? event.location : ''; this.state.description = event.description ? event.description : ''; + } else { + this.state.uid = uuid.v4(); } if (props.journalUid) { @@ -89,6 +95,7 @@ class EventEdit extends React.Component { } let event = new EventType(); + event.uid = this.state.uid; event.summary = this.state.title; event.startDate = ICAL.Time.fromString(this.state.start); event.endDate = ICAL.Time.fromString(this.state.end); diff --git a/yarn.lock b/yarn.lock index 7867691..745d4b4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -94,6 +94,12 @@ dependencies: "@types/jquery" "*" +"@types/uuid@^3.4.3": + version "3.4.3" + resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-3.4.3.tgz#121ace265f5569ce40f4f6d0ff78a338c732a754" + dependencies: + "@types/node" "*" + abab@^1.0.3: version "1.0.4" resolved "https://registry.yarnpkg.com/abab/-/abab-1.0.4.tgz#5faad9c2c07f60dd76770f71cf025b62a63cfd4e"