File size: 1,294 Bytes
f5071ca |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
import * as BookingAPIUtil from '../util/booking_api_util';
export const RECEIVE_BOOKINGS = 'RECEIVE_BOOKINGS';
export const RECEIVE_BOOKING = 'RECEIVE_BOOKING';
export const REMOVE_BOOKING = 'REMOVE_BOOKING';
const receiveBookings = bookings => ({
type: RECEIVE_BOOKINGS,
bookings
});
const receiveBooking = payload => ({
type: RECEIVE_BOOKING,
payload
});
const removeBooking = (booking) => ({
type: REMOVE_BOOKING,
bookingId: booking.id
})
export const fetchBookings = () => dispatch => {
return (
BookingAPIUtil.fetchBookings()
.then(spots => (dispatch(receiveBookings(spots))
))
)
};
export const fetchBooking = id => dispatch => (
BookingAPIUtil.fetchBooking(id)
.then(spot => (dispatch(receiveBooking(spot))
))
);
export const createBooking = (booking) => dispatch => (
BookingAPIUtil.createBooking(booking)
.then((booking) => dispatch(receiveBooking(booking)))
)
export const updateBooking = (booking) => dispatch => (
BookingAPIUtil.updateBooking(booking)
.then((booking) => dispatch(receiveBooking(booking)))
)
export const deleteBooking = (id) => dispatch => (
BookingAPIUtil.deleteBooking(id)
.then((booking) => dispatch(removeBooking(booking)))
) |