Commit ad76bcde authored by AuckeBos's avatar AuckeBos
Browse files

Fixed lint errors

parent 32429070
...@@ -6,7 +6,7 @@ const TOKENKEY = '@MyStore:token'; ...@@ -6,7 +6,7 @@ const TOKENKEY = '@MyStore:token';
export function calendarRetrieved(eventList) { export function calendarRetrieved(eventList) {
return { return {
type: types.CALENDARRETREIVED, type: types.CALENDARRETREIVED,
eventList:eventList eventList,
}; };
} }
...@@ -21,7 +21,7 @@ export function retrieveCalendar() { ...@@ -21,7 +21,7 @@ export function retrieveCalendar() {
AsyncStorage.getItem(TOKENKEY) AsyncStorage.getItem(TOKENKEY)
.then( .then(
(token) => { (token) => {
let start = new Date().toISOString().substring(0, 10); const start = new Date().toISOString().substring(0, 10);
let end = new Date(); let end = new Date();
end.setMonth(end.getMonth() + 6); end.setMonth(end.getMonth() + 6);
end = end.toISOString().substring(0, 10); end = end.toISOString().substring(0, 10);
...@@ -30,22 +30,18 @@ export function retrieveCalendar() { ...@@ -30,22 +30,18 @@ export function retrieveCalendar() {
headers: { headers: {
Accept: 'application/json', Accept: 'application/json',
'Content-Type': '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( .then(
response => response.json()) response => response.json())
.then( .then(
(responseJson) => { responseJson => dispatch(calendarRetrieved(responseJson)))
console.log(responseJson); .catch(() => {
return dispatch(calendarRetrieved(responseJson));
})
.catch((error) => {
console.log(error);
dispatch(calendarNotRetrieved()); dispatch(calendarNotRetrieved());
}) });
} },
); );
}; };
} }
\ No newline at end of file
import * as types from "./actionTypes";
export function openEvent(eventId) {
console.log("opening event");
return {
};
}
...@@ -5,7 +5,7 @@ import * as actions from '../actions/calendar'; ...@@ -5,7 +5,7 @@ import * as actions from '../actions/calendar';
import EventCard from './EventCard'; import EventCard from './EventCard';
const Calendar = (props) => { const Calendar = (props) => {
if(!props.calendarFetched) { if (!props.calendarFetched) {
props.retrieveCalendar(); props.retrieveCalendar();
return ( return (
<View> <View>
...@@ -13,28 +13,28 @@ const Calendar = (props) => { ...@@ -13,28 +13,28 @@ const Calendar = (props) => {
No calendar retrieved! No calendar retrieved!
</Text> </Text>
</View> </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]}/>);
}
console.log(events);
const dataSource = ds.cloneWithRows(events);
return (
<View>
<ListView
dataSource={dataSource}
renderRow={(rowData) => rowData}
/>
</View>
); );
} }
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]} />);
}
const dataSource = ds.cloneWithRows(events);
return (
<View>
<ListView
dataSource={dataSource}
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; const mapStateToProps = state => state.calendar;
......
import React from 'react'; import React from 'react';
import { View, Text, Button } from 'react-native'; import { View, Text } from 'react-native';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import * as actions from '../actions/eventCard';
const EventCard = (props) => const EventCard = props =>
<View> <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> <Text> {new Date(props.event.start).toISOString().substring(0, 10)}</Text>
<i>{props.event.description}</i> <i>{props.event.description}</i>
<Text>-----------------------------------------</Text> <Text>-----------------------------------------</Text>
...@@ -13,12 +12,7 @@ const EventCard = (props) => ...@@ -13,12 +12,7 @@ const EventCard = (props) =>
; ;
EventCard.propTypes = { EventCard.propTypes = {
openEvent: React.PropTypes.func.isRequired, event: React.PropTypes.objectOf(EventCard).isRequired,
event: React.PropTypes.object.isRequired,
}; };
const mapDispatchToProps = dispatch => ({ export default connect(() => ({}), () => ({}))(EventCard);
openEvent: (event_id) => dispatch(actions.openEvent(event_id)),
});
export default connect(() => ({}), mapDispatchToProps)(EventCard);
\ No newline at end of file
...@@ -6,7 +6,6 @@ import Login from './Login'; ...@@ -6,7 +6,6 @@ import Login from './Login';
import Welcome from './Welcome'; import Welcome from './Welcome';
import Sidebar from './Sidebar'; import Sidebar from './Sidebar';
import Calendar from './Calendar'; import Calendar from './Calendar';
import Agenda from './Calendar';
import * as actions from '../actions/navigation'; import * as actions from '../actions/navigation';
......
import * as types from '../actions/actionTypes'; import * as types from '../actions/actionTypes';
const initialState = { const initialState = {
eventList:'', eventList: '',
calendarFetched: false, calendarFetched: false,
}; };
export default function calendar(state = initialState, action = {}) { export default function calendar(state = initialState, action = {}) {
switch (action.type) { switch (action.type) {
case types.CALENDARRETREIVED: case types.CALENDARRETREIVED:
return{...state, eventList:action.eventList, calendarFetched:true}; return { ...state, eventList: action.eventList, calendarFetched: true };
case types.CALENDARERROR: case types.CALENDARERROR:
return{...state, calendarFetched:true}; return { ...state, calendarFetched: true };
default: default:
return { ...state }; return { ...state };
} }
......
import login from './login'; import login from './login';
import navigation from './navigation'; import navigation from './navigation';
import calendar from './calendar' import calendar from './calendar';
export { export {
login, login,
......
import * as types from '../actions/actionTypes'; import * as types from '../actions/actionTypes';
import * as console from "react-native";
const initialState = { const initialState = {
loginState: '', 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