s/restaurants/suggestions/

This commit is contained in:
2016-12-24 10:00:21 -05:00
parent 4c7b9310c0
commit c4f07d3b3e
14 changed files with 237 additions and 215 deletions

View File

@ -1,40 +1,40 @@
var RestaurantConstants = require('../constants/RestaurantConstants');
var SuggestionConstants = require('../constants/SuggestionConstants');
var ErrorActions = require('./ErrorActions');
var models = require('../models.js');
var Restaurant = models.Restaurant;
var Suggestion = models.Suggestion;
var Error = models.Error;
function fetchRestaurants() {
function fetchSuggestions() {
return {
type: RestaurantConstants.FETCH_RESTAURANTS
type: SuggestionConstants.FETCH_SUGGESTIONS
}
}
function restaurantsFetched(restaurants) {
return {
type: RestaurantConstants.RESTAURANTS_FETCHED,
type: SuggestionConstants.SUGGESTIONS_FETCHED,
restaurants: restaurants
}
}
function createRestaurant() {
function createSuggestion() {
return {
type: RestaurantConstants.CREATE_RESTAURANT
type: SuggestionConstants.CREATE_SUGGESTION
}
}
function restaurantCreated(restaurant) {
return {
type: RestaurantConstants.RESTAURANT_CREATED,
type: SuggestionConstants.SUGGESTION_CREATED,
restaurant: restaurant
}
}
function fetchAll() {
return function (dispatch) {
dispatch(fetchRestaurants());
dispatch(fetchSuggestions());
$.ajax({
type: "GET",
@ -47,7 +47,7 @@ function fetchAll() {
ErrorActions.serverError(e);
} else {
dispatch(restaurantsFetched(data.restaurants.map(function(json) {
var a = new Restaurant();
var a = new Suggestion();
a.fromJSON(json);
return a;
})));
@ -62,7 +62,7 @@ function fetchAll() {
function create(restaurant) {
return function (dispatch) {
dispatch(createRestaurant());
dispatch(createSuggestion());
$.ajax({
type: "POST",
@ -75,7 +75,7 @@ function create(restaurant) {
if (e.isError()) {
ErrorActions.serverError(e);
} else {
var a = new Restaurant();
var a = new Suggestion();
a.fromJSON(data);
dispatch(restaurantCreated(a));
}

View File

@ -1,7 +1,7 @@
var UserConstants = require('../constants/UserConstants');
var AttendeeActions = require('./AttendeeActions');
var RestaurantActions = require('./RestaurantActions');
var SuggestionActions = require('./SuggestionActions');
var ErrorActions = require('./ErrorActions');
var models = require('../models.js');
@ -92,7 +92,7 @@ function initializeSession(dispatch, session) {
dispatch(userLoggedIn(session));
dispatch(fetch(session.UserId));
dispatch(AttendeeActions.fetchAll());
dispatch(RestaurantActions.fetchAll());
dispatch(SuggestionActions.fetchAll());
}
function login(user) {