import * as React from 'react'; import { Route, Switch, withRouter } from 'react-router'; import * as ICAL from 'ical.js'; import * as EteSync from './api/EteSync'; import { routeResolver } from './App'; import AddressBook from './AddressBook'; import Contact from './Contact'; class JournalAddressBook extends React.Component { props: { journal: EteSync.Journal, entries: Array, history?: any, }; constructor(props: any) { super(props); this.contactClicked = this.contactClicked.bind(this); } contactClicked(contact: ICAL.Component) { const uid = contact.getFirstPropertyValue('uid'); this.props.history.push( routeResolver.getRoute('journals._id.items._id', { journalUid: this.props.journal.uid, itemUid: uid })); } render() { if (this.props.journal === undefined) { return (
Loading
); } let items: Map = new Map(); for (const syncEntry of this.props.entries) { let comp = new ICAL.Component(ICAL.parse(syncEntry.content)); const uid = comp.getFirstPropertyValue('uid'); if ((syncEntry.action === EteSync.SyncEntryAction.Add) || (syncEntry.action === EteSync.SyncEntryAction.Change)) { items.set(uid, comp); } else if (syncEntry.action === EteSync.SyncEntryAction.Delete) { items.delete(uid); } } return (
( ) } /> { return ( ); }} />
); } } export default withRouter(JournalAddressBook);