import { IRoomsAction } from '../actions/rooms';
import { ROOMS } from '../actions/actionsTypes';
export interface IRooms {
isFetching: boolean;
refreshing: boolean;
failure: boolean;
errorMessage: Record<string, any> | string;
searchText: string;
showServerDropdown: boolean;
closeServerDropdown: boolean;
showSearchHeader: boolean;
}
export const initialState: IRooms = {
isFetching: false,
refreshing: false,
failure: false,
errorMessage: {},
searchText: '',
showServerDropdown: false,
closeServerDropdown: false,
showSearchHeader: false
};
export default function rooms(state = initialState, action: IRoomsAction): IRooms {
switch (action.type) {
case ROOMS.REQUEST:
return {
...state,
isFetching: true,
errorMessage: {}
case ROOMS.SUCCESS:
refreshing: false
case ROOMS.FAILURE:
failure: true,
errorMessage: action.err
case ROOMS.REFRESH:
refreshing: true
case ROOMS.SET_SEARCH:
searchText: action.searchText
case ROOMS.CLOSE_SERVER_DROPDOWN:
closeServerDropdown: !state.closeServerDropdown
case ROOMS.TOGGLE_SERVER_DROPDOWN:
showServerDropdown: !state.showServerDropdown
case ROOMS.OPEN_SEARCH_HEADER:
showSearchHeader: true
case ROOMS.CLOSE_SEARCH_HEADER:
default:
return state;