Skip to content
Snippets Groups Projects
bars.reducers.ts 606 B
Newer Older
import { PhotosAction, PhotosActionsTypes } from "./photos.actions";
import { Photo } from "../models/photo.model";
import { Bar } from "../../models/bar.model";
import { BarsAction, BarsActionsTypes } from "../actions/bars.actions";

export interface BarsState {
	bars: Bar[];
	currentBar: Bar;
}

const defaultBarState = {
	bars: [],
	currentBar: null
}

export function barsReducer(state: BarsState = defaultBarState, action: BarsAction): BarsState {
	switch (action.type) {

		case BarsActionsTypes.FETCH_BARS_SUCCESS: {
			return {
				...state,
				bars: action.payload
			};
		}
	}

	return state;
}