Commit ad76bcde authored by AuckeBos's avatar AuckeBos
Browse files

Fixed lint errors

parent 32429070
......@@ -6,7 +6,7 @@ const TOKENKEY = '@MyStore:token';
export function calendarRetrieved(eventList) {
return {
type: types.CALENDARRETREIVED,
eventList:eventList
eventList,
};
}
......@@ -21,7 +21,7 @@ export function retrieveCalendar() {
AsyncStorage.getItem(TOKENKEY)
.then(
(token) => {
let start = new Date().toISOString().substring(0, 10);
const start = new Date().toISOString().substring(0, 10);
let end = new Date();
end.setMonth(end.getMonth() + 6);
end = end.toISOString().substring(0, 10);
......@@ -30,22 +30,18 @@ export function retrieveCalendar() {
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Token ' + token,
Authorization: `Token ${token}`,
},
};
return fetch('http://localhost:8000/api/events/eventlist/?start=' + start + '&end=' + end, data)
return fetch(`http://localhost:8000/api/events/eventlist/?start=${start}&end=${end}`, data)
.then(
response => response.json())
.then(
(responseJson) => {
console.log(responseJson);
return dispatch(calendarRetrieved(responseJson));
})
.catch((error) => {
console.log(error);
responseJson => dispatch(calendarRetrieved(responseJson)))
.catch(() => {
dispatch(calendarNotRetrieved());
})
}
});
},
);
};
}
import * as types from "./actionTypes";
export function openEvent(eventId) {
console.log("opening event");
return {
};
}
......@@ -5,7 +5,7 @@ import * as actions from '../actions/calendar';
import EventCard from './EventCard';
const Calendar = (props) => {
if(!props.calendarFetched) {
if (!props.calendarFetched) {
props.retrieveCalendar();
return (
<View>
......@@ -13,28 +13,28 @@ const Calendar = (props) => {
No calendar retrieved!
</Text>
</View>
)
);
}
else {
console.log('calendar is retrieved');
console.log(props);
const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
let events = [];
for (let i = 0; i < props.eventList.length; i++) {
console.log(props.eventList[i]);
events.push(<EventCard event={props.eventList[i]}/>);
const ds = new ListView.DataSource({ rowHasChanged: (r1, r2) => r1 !== r2 });
const events = [];
for (let i = 0; i < props.eventList.length; i += 1) {
events.push(<EventCard event={props.eventList[i]} />);
}
console.log(events);
const dataSource = ds.cloneWithRows(events);
return (
<View>
<ListView
dataSource={dataSource}
renderRow={(rowData) => rowData}
renderRow={rowData => rowData}
/>
</View>
);
}
};
Calendar.propTypes = {
eventList: React.PropTypes.arrayOf(EventCard).isRequired,
calendarFetched: React.PropTypes.bool.isRequired,
retrieveCalendar: React.PropTypes.func.isRequired,
};
const mapStateToProps = state => state.calendar;
......
import React from 'react';
import { View, Text, Button } from 'react-native';
import { View, Text } from 'react-native';
import { connect } from 'react-redux';
import * as actions from '../actions/eventCard';
const EventCard = (props) =>
const EventCard = props =>
<View>
<Text> onPress={() => actions.openEvent(props.event.id)} <b>{props.event.title}</b> </Text>
<Text> <b>{props.event.title}</b> </Text>
<Text> {new Date(props.event.start).toISOString().substring(0, 10)}</Text>
<i>{props.event.description}</i>
<Text>-----------------------------------------</Text>
......@@ -13,12 +12,7 @@ const EventCard = (props) =>
;
EventCard.propTypes = {
openEvent: React.PropTypes.func.isRequired,
event: React.PropTypes.object.isRequired,
event: React.PropTypes.objectOf(EventCard).isRequired,
};
const mapDispatchToProps = dispatch => ({
openEvent: (event_id) => dispatch(actions.openEvent(event_id)),
});
export default connect(() => ({}), mapDispatchToProps)(EventCard);
\ No newline at end of file
export default connect(() => ({}), () => ({}))(EventCard);
......@@ -6,7 +6,6 @@ import Login from './Login';
import Welcome from './Welcome';
import Sidebar from './Sidebar';
import Calendar from './Calendar';
import Agenda from './Calendar';
import * as actions from '../actions/navigation';
......
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";
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