Commit 7e90de04 authored by Wietse Kuipers's avatar Wietse Kuipers
Browse files

Linting fixes

parent 92412959
......@@ -3,7 +3,7 @@ import * as types from './actionTypes';
export function calendarRetrieved(eventList) {
return {
type: types.CALENDARRETREIVED,
eventList:eventList
eventList,
};
}
......@@ -13,13 +13,13 @@ export function calendarNotRetrieved() {
};
}
export function retrieveCalendar(){
return (dispatch)=> {
let start = new Date().toISOString().substring(0, 10);
export function retrieveCalendar() {
return (dispatch) => {
const start = new Date().toISOString().substring(0, 10);
let end = new Date();
end.setMonth(end.getMonth() + 6);
end = end.toISOString().substring(0, 10);
return fetch('http://localhost:8000/api/events?start='+start+'&end='+end)
return fetch(`http://localhost:8000/api/events?start=${start}&end=${end}`)
.then(
response => response.json())
.then(
......@@ -30,6 +30,6 @@ export function retrieveCalendar(){
.catch((error) => {
console.log(error);
dispatch(calendarNotRetrieved());
})
};
}
\ No newline at end of file
});
};
}
......@@ -5,7 +5,7 @@ import * as actions from '../actions/calendar';
import Event from './Event';
const Calendar = (props) => {
if(!props.calendarFetched) {
if (!props.calendarFetched) {
props.retrieveCalendar();
return (
<View>
......@@ -13,25 +13,24 @@ const Calendar = (props) => {
No calendar retrieved!
</Text>
</View>
)
}
else {
console.log(props);
const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
let events = [];
for (let i = 0; i < props.eventList.length; i++) {
events.push(Event(props.eventList[i]));
}
const dataSource = ds.cloneWithRows(events);
return (
<View>
<ListView
dataSource={dataSource}
renderRow={(rowData) => rowData}
/>
</View>
);
}
console.log(props);
const ds = new ListView.DataSource({ rowHasChanged: (r1, r2) => r1 !== r2 });
const events = [];
for (let i = 0; i < props.eventList.length; i++) {
events.push(Event(props.eventList[i]));
}
const dataSource = ds.cloneWithRows(events);
return (
<View>
<ListView
dataSource={dataSource}
renderRow={rowData => rowData}
/>
</View>
);
};
const mapStateToProps = state => state.calendar;
......
import React from 'react';
import { View, Text } from 'react-native';
const Event = (event) =>
const Event = event =>
<View>
<Text> <b>{event.title}</b> </Text>
<Text> {new Date(event.start).toISOString().substring(0, 10)}</Text>
......@@ -10,4 +10,4 @@ const Event = (event) =>
</View>
;
export default Event;
\ No newline at end of file
export default Event;
import * as types from '../actions/actionTypes';
const initialState = {
eventList:'',
eventList: '',
calendarFetched: false,
};
export default function calendar(state = initialState, action = {}) {
switch (action.type) {
case types.CALENDARRETREIVED:
return{...state, eventList:action.eventList, calendarFetched:true};
return { ...state, eventList: action.eventList, calendarFetched: true };
case types.CALENDARERROR:
return{...state, calendarFetched:true};
return { ...state, calendarFetched: true };
default:
return { ...state };
}
......
import login from './login';
import navigation from './navigation';
import calendar from './calendar'
import calendar from './calendar';
export {
login,
......
import * as types from '../actions/actionTypes';
import * as console from "react-native";
import * as console from 'react-native';
const initialState = {
loginState: '',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment