Add attendees and suggestions (except for UI)

This commit is contained in:
2016-12-26 08:29:18 -05:00
parent c4f07d3b3e
commit c8232050da
11 changed files with 283 additions and 14 deletions

View File

@ -32,6 +32,19 @@ function attendeeCreated(attendee) {
}
}
function fetchPopularAttendees() {
return {
type: AttendeeConstants.FETCH_POPULAR_ATTENDEES
}
}
function popularAttendeesFetched(attendees) {
return {
type: AttendeeConstants.POPULAR_ATTENDEES_FETCHED,
attendees: attendees
}
}
function fetchAll() {
return function (dispatch) {
dispatch(fetchAttendees());
@ -87,7 +100,36 @@ function create(attendee) {
};
}
function fetchPopular() {
return function (dispatch) {
dispatch(fetchPopularAttendees());
$.ajax({
type: "GET",
dataType: "json",
url: "popularattendees/",
success: function(data, status, jqXHR) {
var e = new Error();
e.fromJSON(data);
if (e.isError()) {
ErrorActions.serverError(e);
} else {
dispatch(popularAttendeesFetched(data.attendees.map(function(json) {
var a = new Attendee();
a.fromJSON(json);
return a;
})));
}
},
error: function(jqXHR, status, error) {
ErrorActions.ajaxError(e);
}
});
};
}
module.exports = {
fetchAll: fetchAll,
create: create
create: create,
fetchPopular: fetchPopular
};