From 25402639b678c7bed58d450e910dac7861cd7745 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 7 Dec 2017 21:11:24 +0000 Subject: [PATCH] Split off the pim view and implement viewing contacts. --- src/App.tsx | 8 ++++++-- src/Pim.tsx | 46 ++++++++++++++++++++++++--------------------- src/PimMain.tsx | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 23 deletions(-) create mode 100644 src/PimMain.tsx diff --git a/src/App.tsx b/src/App.tsx index 703cc18..cd2e385 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -41,8 +41,12 @@ export function getPalette(part: string): string { export const routeResolver = new RouteResolver({ home: '', pim: { - contacts: 'contacts/:contactUid', - events: 'events/:contactUid', + contacts: { + _id: ':contactUid', + }, + events: { + _id: ':eventUid', + }, }, journals: { _id: { diff --git a/src/Pim.tsx b/src/Pim.tsx index 8bb1112..578e229 100644 --- a/src/Pim.tsx +++ b/src/Pim.tsx @@ -1,10 +1,12 @@ import * as React from 'react'; -import { Tabs, Tab } from 'material-ui/Tabs'; +import { Route, Switch } from 'react-router'; import * as EteSync from './api/EteSync'; -import AddressBook from './AddressBook'; -import Calendar from './Calendar'; +import Contact from './Contact'; +import PimMain from './PimMain'; + +import { routeResolver } from './App'; import { JournalsData, EntriesType, CredentialsData } from './store'; @@ -20,16 +22,6 @@ class Pim extends React.Component { constructor(props: any) { super(props); - this.eventClicked = this.eventClicked.bind(this); - this.contactClicked = this.contactClicked.bind(this); - } - - eventClicked(contact: any) { - // FIXME - } - - contactClicked(contact: any) { - // FIXME } render() { @@ -73,14 +65,26 @@ class Pim extends React.Component { let calendarItems = syncEntriesToCalendarItemMap(syncEntriesCalendar); return ( - - - - - - - - + + ( + + )} + /> + ( + + )} + /> + ); } } diff --git a/src/PimMain.tsx b/src/PimMain.tsx new file mode 100644 index 0000000..9155799 --- /dev/null +++ b/src/PimMain.tsx @@ -0,0 +1,50 @@ +import * as React from 'react'; +import { Tabs, Tab } from 'material-ui/Tabs'; + +import * as ICAL from 'ical.js'; + +import AddressBook from './AddressBook'; +import Calendar from './Calendar'; + +import { routeResolver } from './App'; + +class Pim extends React.Component { + props: { + contacts: Array, + events: Array, + history?: any, + }; + + constructor(props: any) { + super(props); + this.eventClicked = this.eventClicked.bind(this); + this.contactClicked = this.contactClicked.bind(this); + } + + eventClicked(contact: any) { + // FIXME + } + + contactClicked(contact: ICAL.Component) { + const uid = contact.getFirstPropertyValue('uid'); + + this.props.history.push( + routeResolver.getRoute('pim.contacts._id', { contactUid: uid })); + } + + render() { + + return ( + + + + + + + + + ); + } +} + +export default Pim;