Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
thalia
ThaliApp
Commits
92412959
Commit
92412959
authored
Apr 12, 2017
by
AuckeBos
Committed by
Wietse Kuipers
Apr 19, 2017
Browse files
Calendar retrieval fixed
parent
25342103
Changes
9
Hide whitespace changes
Inline
Side-by-side
app/actions/actionTypes.js
View file @
92412959
...
@@ -6,3 +6,6 @@ export const LOGINSUCCESS = 'LOGINSUCCESS';
...
@@ -6,3 +6,6 @@ export const LOGINSUCCESS = 'LOGINSUCCESS';
export
const
LOGINFAILURE
=
'
LOGINFAILURE
'
;
export
const
LOGINFAILURE
=
'
LOGINFAILURE
'
;
export
const
LOGOUT
=
'
LOGOUT
'
;
export
const
LOGOUT
=
'
LOGOUT
'
;
export
const
OPENDRAWER
=
'
OPENDRAWER
'
;
export
const
OPENDRAWER
=
'
OPENDRAWER
'
;
export
const
CALENDARRETREIVED
=
'
CALENDARRETREIVED
'
;
export
const
CALENDARERROR
=
'
CALENDARERROR
'
;
app/actions/calendar.js
View file @
92412959
/**
import
*
as
types
from
'
./actionTypes
'
;
* Created by aucke on 3/8/17.
*/
export
function
calendarRetrieved
(
eventList
)
{
return
{
type
:
types
.
CALENDARRETREIVED
,
eventList
:
eventList
};
}
export
function
calendarNotRetrieved
()
{
return
{
type
:
types
.
CALENDARERROR
,
};
}
export
function
retrieveCalendar
(){
return
(
dispatch
)
=>
{
let
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
)
.
then
(
response
=>
response
.
json
())
.
then
(
(
responseJson
)
=>
{
console
.
log
(
responseJson
);
return
dispatch
(
calendarRetrieved
(
responseJson
));
})
.
catch
((
error
)
=>
{
console
.
log
(
error
);
dispatch
(
calendarNotRetrieved
());
})
};
}
\ No newline at end of file
app/components/Calendar.js
View file @
92412959
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
{
Text
,
View
}
from
'
react-native
'
;
import
{
Text
,
View
,
ListView
}
from
'
react-native
'
;
import
{
connect
}
from
'
react-redux
'
;
import
*
as
actions
from
'
../actions/calendar
'
;
import
Event
from
'
./Event
'
;
const
Calendar
=
()
=>
const
Calendar
=
(
props
)
=>
{
<
View
>
if
(
!
props
.
calendarFetched
)
{
<
Text
>
props
.
retrieveCalendar
();
Algemene
Ledenvergadering
return
(
<
/Text
>
<
View
>
<
Text
>
<
Text
>
Lunchlezing
Rijksoverheid
No
calendar
retrieved
!
<
/Text
>
<
/Text
>
<
Text
>
<
/View
>
Benefietborrel
)
<
/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
>
);
}
};
export
default
Calendar
;
const
mapStateToProps
=
state
=>
state
.
calendar
;
const
mapDispatchToProps
=
dispatch
=>
({
retrieveCalendar
:
()
=>
dispatch
(
actions
.
retrieveCalendar
()),
});
export
default
connect
(
mapStateToProps
,
mapDispatchToProps
)(
Calendar
);
app/components/Event.js
0 → 100644
View file @
92412959
import
React
from
'
react
'
;
import
{
View
,
Text
}
from
'
react-native
'
;
const
Event
=
(
event
)
=>
<
View
>
<
Text
>
<
b
>
{
event
.
title
}
<
/b> </
Text
>
<
Text
>
{
new
Date
(
event
.
start
).
toISOString
().
substring
(
0
,
10
)}
<
/Text
>
<
i
>
{
event
.
description
}
<
/i
>
<
Text
>-----------------------------------------<
/Text
>
<
/View
>
;
export
default
Event
;
\ No newline at end of file
app/components/Sidebar.js
View file @
92412959
...
@@ -12,7 +12,7 @@ const Sidebar = props =>
...
@@ -12,7 +12,7 @@ const Sidebar = props =>
>
>
<
Text
style
=
{
styles
.
header
}
>
MENU
<
/Text
>
<
Text
style
=
{
styles
.
header
}
>
MENU
<
/Text
>
<
Text
onPress
=
{()
=>
props
.
navigate
(
'
welcome
'
)}
style
=
{
styles
.
button
}
>
Welcome
<
/Text
>
<
Text
onPress
=
{()
=>
props
.
navigate
(
'
welcome
'
)}
style
=
{
styles
.
button
}
>
Welcome
<
/Text
>
<
Text
onPress
=
{()
=>
props
.
navigate
(
'
agenda
'
)}
style
=
{
styles
.
button
}
>
Ag
enda
<
/Text
>
<
Text
onPress
=
{()
=>
props
.
navigate
(
'
eventList
'
)}
style
=
{
styles
.
button
}
>
Cal
enda
r
<
/Text
>
<
/View
>
<
/View
>
;
;
...
...
app/components/navigator.js
View file @
92412959
...
@@ -5,7 +5,8 @@ import PropTypes from 'prop-types';
...
@@ -5,7 +5,8 @@ import PropTypes from 'prop-types';
import
Login
from
'
./Login
'
;
import
Login
from
'
./Login
'
;
import
Welcome
from
'
./Welcome
'
;
import
Welcome
from
'
./Welcome
'
;
import
Sidebar
from
'
./Sidebar
'
;
import
Sidebar
from
'
./Sidebar
'
;
import
Agenda
from
'
./Agenda
'
;
import
Calendar
from
'
./Calendar
'
;
import
Agenda
from
'
./Calendar
'
;
import
*
as
actions
from
'
../actions/navigation
'
;
import
*
as
actions
from
'
../actions/navigation
'
;
...
@@ -23,8 +24,8 @@ const sceneToComponent = (scene) => {
...
@@ -23,8 +24,8 @@ const sceneToComponent = (scene) => {
switch
(
scene
)
{
switch
(
scene
)
{
case
'
welcome
'
:
case
'
welcome
'
:
return
<
Welcome
/>
;
return
<
Welcome
/>
;
case
'
agenda
'
:
case
'
eventList
'
:
return
<
Ag
enda
/>
;
return
<
Cal
enda
r
/>
;
default
:
default
:
return
<
Welcome
/>
;
return
<
Welcome
/>
;
}
}
...
...
app/reducers/calendar.js
View file @
92412959
import
*
as
types
from
'
../actions/actionTypes
'
;
import
*
as
types
from
'
../actions/actionTypes
'
;
const
initialState
=
{
const
initialState
=
{
eventList
:
''
,
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
:
return
{...
state
,
eventList
:
action
.
eventList
,
calendarFetched
:
true
};
case
types
.
CALENDARERROR
:
return
{...
state
,
calendarFetched
:
true
};
default
:
default
:
return
{
...
state
};
return
{
...
state
};
}
}
}
/**
}
* Created by aucke on 3/8/17.
*/
app/reducers/index.js
View file @
92412959
import
login
from
'
./login
'
;
import
login
from
'
./login
'
;
import
navigation
from
'
./navigation
'
;
import
navigation
from
'
./navigation
'
;
import
calendar
from
'
./calendar
'
export
{
export
{
login
,
login
,
navigation
,
navigation
,
calendar
,
};
};
app/reducers/login.js
View file @
92412959
import
*
as
types
from
'
../actions/actionTypes
'
;
import
*
as
types
from
'
../actions/actionTypes
'
;
import
*
as
console
from
"
react-native
"
;
const
initialState
=
{
const
initialState
=
{
loginState
:
''
,
loginState
:
''
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment