diff --git a/src/components/Calendar.tsx b/src/components/Calendar.tsx index f67ca63..2c27892 100644 --- a/src/components/Calendar.tsx +++ b/src/components/Calendar.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import BigCalendar from 'react-big-calendar'; +import BigCalendar, { View } from 'react-big-calendar'; import 'react-big-calendar/lib/css/react-big-calendar.css'; import * as moment from 'moment'; import 'moment/locale/en-gb'; @@ -27,6 +27,7 @@ function agendaHeaderFormat(date: {start: Date, end: Date}, culture: string, loc class Calendar extends React.PureComponent { state: { currentDate?: Date; + view?: View; }; props: { @@ -40,6 +41,7 @@ class Calendar extends React.PureComponent { this.state = {}; this.onNavigate = this.onNavigate.bind(this); + this.onView = this.onView.bind(this); this.slotClicked = this.slotClicked.bind(this); } @@ -47,6 +49,10 @@ class Calendar extends React.PureComponent { this.setState({currentDate}); } + onView(view: string) { + this.setState({view}); + } + slotClicked(slotInfo: {start: Date, end: Date}) { if (this.props.onSlotClick) { this.props.onSlotClick(slotInfo.start, slotInfo.end); @@ -66,6 +72,8 @@ class Calendar extends React.PureComponent { eventPropGetter={eventPropGetter} date={this.state.currentDate} onNavigate={this.onNavigate} + view={this.state.view} + onView={this.onView} /> );