Example #1
0
 neu = neu.update('start', start => moment(start).add({ days: diff.distance + diff.start }).toDate());
Example #2
0
 neu = neu.update('end', end => moment(end).add({ days: diff.distance + diff.end }).toDate());
import { CalendarActions, CalendarActionTypes } from './calendar.actions';
import { List, Record } from 'immutable';
import { CalendarEvent, Diff } from 'app/calendar/event';
import * as moment from 'moment-mini-ts';
import * as faker from 'faker';

export interface CalendarState {
  events: List<CalendarEvent>;
  startDate: moment.Moment,
  inFlight: CalendarEvent | null;
  original: CalendarEvent | null;
  diff: Diff;
}

const dayOne = moment().startOf('month');

export const CalendarStateRecord = Record({
  events: List([
    CalendarEvent.standard(`Meeting with ${faker.name.findName()}`, dayOne.clone().add({ days: 3, hours: 13 }).toDate()),
    CalendarEvent.allDay("Conference in Berlin", dayOne.clone().add({ days: 7 }).toDate(), dayOne.clone().add({ days: 11 }).toDate()),
  ]),
  startDate: dayOne,
  inFlight: null as CalendarEvent,
  original: null as CalendarEvent,
  diff: new Diff()
});

export function reducer(state = new CalendarStateRecord(), action: CalendarActions): CalendarState {
  // console.log(action);
  switch (action.type) {